Enhance - text class autofill (#2679)

Try and auto fill a value when its blank an the same baseline language
has a value
This commit is contained in:
Mafoo 2017-06-13 06:19:02 +01:00 committed by FusionPBX
parent 1c58c1c1f9
commit 0098dd01c2
1 changed files with 11 additions and 1 deletions

View File

@ -210,6 +210,16 @@ class text {
if(strlen($value) == 0 and array_key_exists($target_lang, $this->legacy_map)) {
$value = $text[$lang_label][$this->legacy_map[$target_lang]];
}
if(strlen($value) == 0){
$base_code = substr($target_lang, 0, 2);
foreach($this->languages as $lang_code){
if(substr($lang_code, 0, 2) == $base_code and strlen($text[$lang_label][$lang_code]) > 0){
$value = $text[$lang_label][$lang_code];
$append = " //copied from $lang_code";
continue;
}
}
}
fwrite($lang_file, "\$text['$lang_label']['$target_lang'$spacer] = \"".$this->escape_str($value)."\";$append\n");
}
}
@ -217,7 +227,7 @@ class text {
}
//close the language file
fwrite($lang_file, "\n?>");
fwrite($lang_file, "\n?>\n");
fclose($lang_file);
}