From 0098dd01c24d651aa1d7e3c78aa5da7b78cada9e Mon Sep 17 00:00:00 2001 From: Mafoo Date: Tue, 13 Jun 2017 06:19:02 +0100 Subject: [PATCH] Enhance - text class autofill (#2679) Try and auto fill a value when its blank an the same baseline language has a value --- resources/classes/text.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/resources/classes/text.php b/resources/classes/text.php index 659f0685f3..29970f4b3b 100644 --- a/resources/classes/text.php +++ b/resources/classes/text.php @@ -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); }