For example, if there is something like xl(‘new patient’), and a language has a translation for ‘patient’ but not for ‘new patient’, there is no translation. Would it be a problem to make it so if no translation is found for a phrase, xl() looks at each word in the string for translations? I am thinking of ‘languages’ which are not actual spoken languages but terms to transform OpenEMR into something else. For example, ‘patient’ might translate to ‘customer’ in the language ‘retail store’.
I mean xl(‘new patient’). I changed the code for the xl function on my system to do what I am talking about and it seemed to work ok, but it also seemed to noticeably slow down my system, which is not a very fast cpu. Maybe it’s best to leave it the way it is or at least do this more efficiently than I have done it. Here’s my change to xl() below since I don’t want to mess with the cvs code:
function xl($constant,$mode=‘r’,$prepend=’’,$append=’’) {
$string = xl_query($constant);
if ($string==’’) {
$string = preg_replace(’/\W+/’,’ ‘,$constant); //account for words separated by a comma and no space and such
$string_array = explode(’ ‘,$string);
$string_hash = array();
foreach($string_array as $val) {
if (!$string_hash[$val]) { //don’t retranslate the same word over
$string_hash[$val] = xl_query($val);
}
}
foreach($string_hash as $key => $val) {
if ($key != ‘’) {
$constant = preg_replace(’/$key/’,$val,$constant);
}
}
$string=ucfirst(strtolower($constant));
}
$string="$prepend"."$string"."$append";
if ($mode==‘e’){
echo $string;
} else {
return $string;
}
}
function xl_query($constant) {
$lang_id=LANGUAGE;
$sql="SELECT * FROM lang_definitions JOIN lang_constants ON " .
"lang_definitions.cons_id = lang_constants.cons_id WHERE " .
“lang_id=’$lang_id’ AND constant_name = '” .
addslashes($constant) . “’ LIMIT 1”;
$res=SqlStatement($sql);
$row=SqlFetchArray($res);
$string=$row[‘definition’];
return $string;
}