From: vyshane Date: Wed, 5 Apr 2006 04:07:16 +0000 (+0000) Subject: Fix for Bug #4910 - stringnames with - . and / don't show up in translation editor X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=5723bc6f09a98e351d094c979d65a5dd98725eab;p=moodle.git Fix for Bug #4910 - stringnames with - . and / don't show up in translation editor Modified /admin/lang.php to allow us to still use periods in language string keys. The lang.php script just replaces the periods with ##46# for the form inputs and then puts the periods back in before saving to the language file. This means that there is no need to update language files at all. They will just work even with periods in the string keys. --- diff --git a/admin/lang.php b/admin/lang.php index c87caf3125..dd4c9fba3c 100644 --- a/admin/lang.php +++ b/admin/lang.php @@ -176,7 +176,14 @@ if (!confirm_sesskey()) { error(get_string('confirmsesskeybad', 'error')); } - $newstrings = $_POST; + + $newstrings = array(); + + foreach ($_POST as $postkey => $postval) { + $stringkey = lang_file_string_key($postkey); + $newstrings[$stringkey] = $postval; + } + unset($newstrings['currentfile']); if (lang_save_file($langdir, $currentfile, $newstrings)) { notify(get_string("changessaved")." ($langdir/$currentfile)", "green"); @@ -272,12 +279,12 @@ $cols=50; if (strstr($value, "\r") or strstr($value, "\n") or $valuelen > $cols) { $rows = ceil($valuelen / $cols); - echo ''."\n"; + echo ''."\n"; } else { if ($valuelen) { $cols = $valuelen + 2; } - echo ''; + echo ''; } echo ''; @@ -343,4 +350,19 @@ function lang_save_file($path, $file, $strings) { return true; } -?> + + +/// Following functions are required because '.' in form input names +/// get replaced by '_' by PHP. + +function lang_form_string_key($keyfromfile) { + return str_replace('.', '##46#', $keyfromfile); /// Derived from ., the ascii value for a period. +} + + +function lang_file_string_key($keyfromform) { + return str_replace('##46#', '.', $keyfromform); +} + + +?> \ No newline at end of file