<?php
function translate( $search ) { global $translation_table, $translation_loaded;
if ( ! $translation_loaded ) load_translation_table(); $rc = $search; reset( $translation_table ); for( $i = 0; $i < count( $translation_table ); $i++ ) { if ( strlen(strstr($translation_table[$i][0],$search))==strlen($search) ) { $rc = $translation_table[$i][1]; break; } } return( $rc ); }
function load_translation_table() { global $cfg,$translation_table, $translation_loaded; $fn = $cfg["translation-file"]; if ( ! file_exists( $fn ) ) { Fatal( "Couldn't load translation table $fn" ); } $f = fopen( $fn, "r" ); if ( !$f ) Fatal ( "Couldn't open/read file $fn" ); while( $ls = fgets( $f, 4096 ) ) { $a = explode(":",$ls,2); $translation_table[] = $a; } reset( $translation_table ); $translation_loaded = true; fclose($f); }
?>
|