Commit 1d7a1fa4 authored by Robert Lyon's avatar Robert Lyon Committed by Aaron Wells

Allowing for non english theme / plugin lang files to be used

Bug 1417120

The language location check now goes in this order:

1. /local string in selected language
2. theme/plugin directory, in selected language
3. langpack, in selected language
4. /local string in parent language (if any)
5. theme/plugin directory, in parent language
6. langpack, in parent language
7. /local string in English
8. theme/plugin directory, in English

Change-Id: I24f61e24fadbca3a62fefa3855f4f444165d750a
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent dc6b8b0f
......@@ -462,6 +462,8 @@ function get_string_location($identifier, $section, $variables, $replacefunc='fo
// Define the locations of language strings for this section
$langstringroot = get_language_root($lang);
$docroot = get_config('docroot');
$langdirectory = ''; // The directory in which the language file for this string should ideally reside, if the language has implemented it
if (false === strpos($section, '.')) {
......@@ -486,7 +488,13 @@ function get_string_location($identifier, $section, $variables, $replacefunc='fo
}
}
// First check all the normal locations for the string in the current language
// First check the theme/plugin locations
$result = get_string_local($docroot . $langdirectory, $lang . '/' . $section . '.php', $identifier);
if ($result !== false) {
return $replacefunc($result, $variables, $lang);
}
// Then check the default location for the string in the current language
$result = get_string_local($langstringroot . $langdirectory, $lang . '/' . $section . '.php', $identifier);
if ($result !== false) {
return $replacefunc($result, $variables, $lang);
......@@ -502,7 +510,15 @@ function get_string_location($identifier, $section, $variables, $replacefunc='fo
$langfile = $langstringroot . 'lang/' . $lang . '/langconfig.php';
if (is_readable($langfile)) {
if ($parentlang = get_string_from_file('parentlanguage', $langfile)) {
$result = get_string_local(get_language_root($parentlang) . 'lang/', $parentlang . '/' . $section . '.php', $identifier);
// First check the theme/plugin locations
$result = get_string_local($docroot . $langdirectory, $parentlang . '/' . $section . '.php', $identifier);
if ($result !== false) {
return $replacefunc($result, $variables, $parentlang);
}
// Then check the default location for the string in the current language
$result = get_string_local(get_language_root($parentlang) . $langdirectory, $parentlang . '/' . $section . '.php', $identifier);
if ($result !== false) {
return $replacefunc($result, $variables, $parentlang);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment