Skip to content
Snippets Groups Projects
Commit 699408f2 authored by Jared Hancock's avatar Jared Hancock
Browse files

i18n: Fix locale corruption searching for packs

Also add a slight performance optimization for untranslated (en_US) help
desks
parent f7d2ca18
No related branches found
No related tags found
No related merge requests found
...@@ -676,8 +676,16 @@ class TextDomain { ...@@ -676,8 +676,16 @@ class TextDomain {
} }
function getTranslation($category=LC_MESSAGES, $locale=false) { function getTranslation($category=LC_MESSAGES, $locale=false) {
$locale = $locale ?: self::setLocale(LC_MESSAGES, 0); $locale = $locale ?: self::$current_locale
if (!isset($this->l10n[$locale])) { ?: self::setLocale(LC_MESSAGES, 0);
if (isset($this->l10n[$locale]))
return $this->l10n[$locale];
if ($locale == 'en_US') {
$this->l10n[$locale] = new Translation(null);
}
else {
// get the current locale // get the current locale
$bound_path = @$this->path ?: './'; $bound_path = @$this->path ?: './';
$subpath = self::$LC_CATEGORIES[$category] . $subpath = self::$LC_CATEGORIES[$category] .
...@@ -685,13 +693,13 @@ class TextDomain { ...@@ -685,13 +693,13 @@ class TextDomain {
$locale_names = self::get_list_of_locales($locale); $locale_names = self::get_list_of_locales($locale);
$input = null; $input = null;
foreach ($locale_names as $locale) { foreach ($locale_names as $T) {
$phar_path = 'phar://' . $bound_path . $locale . ".phar/" . $subpath; $phar_path = 'phar://' . $bound_path . $T . ".phar/" . $subpath;
if (file_exists($phar_path)) { if (file_exists($phar_path)) {
$input = $phar_path; $input = $phar_path;
break; break;
} }
$full_path = $bound_path . $locale . "/" . $subpath; $full_path = $bound_path . $T . "/" . $subpath;
if (file_exists($full_path)) { if (file_exists($full_path)) {
$input = $full_path; $input = $full_path;
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment