Index: theme/standard/styles_layout.css =================================================================== RCS file: /cvsroot/moodle/moodle/theme/standard/styles_layout.css,v retrieving revision 1.543 diff -u -r1.543 styles_layout.css --- theme/standard/styles_layout.css 19 Dec 2007 18:26:12 -0000 1.543 +++ theme/standard/styles_layout.css 19 Dec 2007 18:38:45 -0000 @@ -959,13 +959,45 @@ border-style: solid; } -#admin-langimport .generalbox { +#admin-lang .generalbox { text-align:center; margin:auto; border-width: 1px; border-style: solid; } +#admin-lang .lang_versionrestricted .lang_version { + background:black; + color:white; + font-weight:bold; + font-size:0.8em; + float:left; + padding:0 2px; + margin-top:0.35em; +} + +#admin-lang table.lang_except { + margin:0 0 0 1em; + cell-spacing:0; +} +#admin-lang table.lang_except th { + padding:5px 4px 2px 0; + font-size:0.75em; +} +#admin-lang table.lang_except td { + padding:0 4px 0 0; +} +#admin-lang .lang_previousvalue { + font-size:0.75em; +} +#admin-lang .lang_except_add { + margin-left:1em; + font-size:0.75em; + vertical-align:bottom; +} + + + #admin-langimport .generalbox table { text-align:center; margin:auto; Index: lang/en_utf8/admin.php =================================================================== RCS file: /cvsroot/moodle/moodle/lang/en_utf8/admin.php,v retrieving revision 1.171 diff -u -r1.171 admin.php --- lang/en_utf8/admin.php 19 Dec 2007 17:35:24 -0000 1.171 +++ lang/en_utf8/admin.php 19 Dec 2007 18:38:44 -0000 @@ -384,6 +384,9 @@ $string['iplookup'] = 'IP address lookup'; $string['keeptagnamecase'] = 'Keep tag name casing'; $string['lang'] = 'Default language'; +$string['lang_exceptadd'] = 'Add except'; +$string['lang_exceptcondition'] = 'Except when'; +$string['lang_exceptvalue'] = 'Value'; $string['lang16notify'] = 'Moodle 1.6 and above allows you to install and update language packs directly from download.moodle.org by following the link below'; $string['langcache'] = 'Cache language menu'; $string['langedit'] = 'Language editing'; Index: lib/moodlelib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/moodlelib.php,v retrieving revision 1.978 diff -u -r1.978 moodlelib.php --- lib/moodlelib.php 19 Dec 2007 17:35:27 -0000 1.978 +++ lib/moodlelib.php 19 Dec 2007 18:38:45 -0000 @@ -4963,7 +4963,7 @@ $filetocheck = 'langconfig.php'; $defaultlang = 'en_utf8'; if (in_array($identifier, $langconfigstrs)) { - $module = 'langconfig'; //This strings are under langconfig.php for 1.6 lang packs + $module = 'langconfig'; //This strings are under langconfig.php for 1.6 lang packs } $lang = current_language(); @@ -5028,7 +5028,7 @@ foreach ($locations as $location) { $locallangfile = $location.$lang.'_local'.'/'.$module.'.php'; //first, see if there's a local file if (file_exists($locallangfile)) { - if ($result = get_string_from_file($identifier, $locallangfile, "\$resultstring")) { + if ($result = get_string_from_file($identifier, $locallangfile, "\$resultstring", $a)) { eval($result); return $resultstring; } @@ -5036,7 +5036,7 @@ //if local directory not found, or particular string does not exist in local direcotry $langfile = $location.$lang.'/'.$module.'.php'; if (file_exists($langfile)) { - if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) { + if ($result = get_string_from_file($identifier, $langfile, "\$resultstring", $a)) { eval($result); return $resultstring; } @@ -5054,14 +5054,14 @@ foreach ($locations as $location) { $langfile = $location.$lang.'/'.$filetocheck; if (file_exists($langfile)) { - if ($result = get_string_from_file('parentlanguage', $langfile, "\$parentlang")) { + if ($result = get_string_from_file('parentlanguage', $langfile, "\$parentlang", $a)) { eval($result); if (!empty($parentlang)) { // found it! //first, see if there's a local file for parent $locallangfile = $location.$parentlang.'_local'.'/'.$module.'.php'; if (file_exists($locallangfile)) { - if ($result = get_string_from_file($identifier, $locallangfile, "\$resultstring")) { + if ($result = get_string_from_file($identifier, $locallangfile, "\$resultstring", $a)) { eval($result); return $resultstring; } @@ -5070,7 +5070,7 @@ //if local directory not found, or particular string does not exist in local direcotry $langfile = $location.$parentlang.'/'.$module.'.php'; if (file_exists($langfile)) { - if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) { + if ($result = get_string_from_file($identifier, $langfile, "\$resultstring", $a)) { eval($result); return $resultstring; } @@ -5085,7 +5085,7 @@ foreach ($locations as $location) { $locallangfile = $location.$defaultlang.'_local/'.$module.'.php'; //first, see if there's a local file if (file_exists($locallangfile)) { - if ($result = get_string_from_file($identifier, $locallangfile, "\$resultstring")) { + if ($result = get_string_from_file($identifier, $locallangfile, "\$resultstring", $a)) { eval($result); return $resultstring; } @@ -5095,7 +5095,7 @@ $langfile = $location.$defaultlang.'/'.$module.'.php'; if (file_exists($langfile)) { - if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) { + if ($result = get_string_from_file($identifier, $langfile, "\$resultstring", $a)) { eval($result); return $resultstring; } @@ -5109,7 +5109,7 @@ foreach ($locations as $location) { $locallangfile = $location.$defaultlang.'_local/'.$module.'.php'; //first, see if there's a local file if (file_exists($locallangfile)) { - if ($result = get_string_from_file($identifier, $locallangfile, "\$resultstring")) { + if ($result = get_string_from_file($identifier, $locallangfile, "\$resultstring", $a)) { eval($result); return $resultstring; } @@ -5119,7 +5119,7 @@ $langfile = $location.$defaultlang.'/'.$module.'.php'; if (file_exists($langfile)) { - if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) { + if ($result = get_string_from_file($identifier, $langfile, "\$resultstring", $a)) { eval($result); return $resultstring; } @@ -5137,18 +5137,21 @@ * @param string $identifier ? * @param string $langfile ? * @param string $destination ? + * @param mixed $a Arbitrary parameter to get_string, used only for expressions * @return string|false ? * @staticvar array $strings Localized strings * @access private * @todo Finish documenting this function. */ -function get_string_from_file($identifier, $langfile, $destination) { +function get_string_from_file($identifier, $langfile, $destination, $a) { static $strings; // Keep the strings cached in memory. if (empty($strings[$langfile])) { $string = array(); + $except = array(); include ($langfile); + $string['__except']=$except; $strings[$langfile] = $string; } else { $string = &$strings[$langfile]; @@ -5157,8 +5160,26 @@ if (!isset ($string[$identifier])) { return false; } + + $selectedstring=null; + + // When there is a conditional string entry for this identifier, it is + // used in preference. The first matching condition is used. If no + // conditions match, the normal $string will be used. + if(array_key_exists($identifier,$string['__except'])) { + foreach($string['__except'][$identifier] as $expression=>$value) { + if(eval("return $expression;")) { + $selectedstring=$value; + break; + } + } + } + + if(is_null($selectedstring)) { + $selectedstring=$string[$identifier]; + } - return $destination .'= sprintf("'. $string[$identifier] .'");'; + return $destination .'= sprintf("'. $selectedstring .'");'; } /** Index: admin/lang.php =================================================================== RCS file: /cvsroot/moodle/moodle/admin/lang.php,v retrieving revision 1.111 diff -u -r1.111 lang.php --- admin/lang.php 19 Dec 2007 17:35:21 -0000 1.111 +++ admin/lang.php 19 Dec 2007 18:38:44 -0000 @@ -439,15 +439,27 @@ } $newstrings = array(); + $newexcepts = array(); foreach ($_POST as $postkey => $postval) { $stringkey = lang_file_string_key($postkey); - $newstrings[$stringkey] = $postval; + @list($id, $stringname) = explode('XXX',$stringkey); + $matches=array(); + if($id=='string') { + $newstrings[$stringname] = $postval; + } else if(preg_match('/^exceptcondition([0-9]+)$/',$id,$matches)) { + if(!array_key_exists($stringname, $newexcepts)) { + $newexcepts[$stringname] = array(); + } + $value = $_POST['exceptvalue'.$matches[1].'XXX'.$stringname]; + if( trim($value) !== '' ) { + $newexcepts[$stringname][$postval] = $value; + } + } } - - unset($newstrings['currentfile']); - + $packstring = array(); + $packexcept = array(); $saveinto = $langdir; if ($uselocal) { if(file_exists($trfilepath)) { @@ -455,12 +467,17 @@ if (isset($string)) { $packstring = $string; } + if (isset($except)) { + $packexcept = $except; + } unset($string); + unset($except); } $saveinto = $locallangdir; } - if (lang_save_file($saveinto, $currentfile, $newstrings, $uselocal, $packstring)) { + if (lang_save_file($saveinto, $currentfile, $newstrings, $newexcepts, + $uselocal, $packstring, $packexcept)) { notify(get_string("changessaved")." ($saveinto/$currentfile)", "notifysuccess"); } else { error("Could not save the file '$saveinto/$currentfile'!", "lang.php?mode=compare¤tfile=$currentfile"); @@ -518,8 +535,10 @@ $o = ''; // stores the HTML output to be echo-ed unset($string); + unset($except); include($enfilepath); $enstring = isset($string) ? $string : array(); + $enexcept = isset($except) ? $except : array(); // // Following strings have moved into langconfig.php, but keep the here for backward compatibility // @@ -530,17 +549,21 @@ $enstring['parentlanguage'] = "<< TRANSLATORS: If your language has a Parent Language that Moodle should use when strings are missing from your language pack, then specify the code for it here. If you leave this blank then English will be used. Example: nl >>"; } unset($string); + unset($except); ksort($enstring); @include($lcfilepath); $localstring = isset($string) ? $string : array(); + $localexcept = isset($except) ? $except : array(); unset($string); + unset($except); ksort($localstring); @include($trfilepath); $string = isset($string) ? $string : array(); + $except = isset($except) ? $except : array(); ksort($string); - + if ($editable) { $o .= "