diff options
| author | Andy Staudacher <andy.st@gmail.com> | 2009-09-05 18:55:44 -0700 |
|---|---|---|
| committer | Andy Staudacher <andy.st@gmail.com> | 2009-09-05 18:55:44 -0700 |
| commit | b3d0cb5a4c88c42e29e67f3b3eb4e91151802164 (patch) | |
| tree | 38069e0075a300ec0c912015cefab55591391380 /modules/gallery/helpers | |
| parent | b01596c0f08f00e5fc2d1019b3905fe5fd76a223 (diff) | |
Bugfixes for locales::locale_from_http_request(), and adding tests.
(And the tests should illustrate that kohana 2.4's API doesn't quite fit our purpose of simply getting the best match between the accepted (client) and the installed (g3) locales.)
Diffstat (limited to 'modules/gallery/helpers')
| -rw-r--r-- | modules/gallery/helpers/locales.php | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php index 04fa8954..16dda2d7 100644 --- a/modules/gallery/helpers/locales.php +++ b/modules/gallery/helpers/locales.php @@ -56,6 +56,9 @@ class locales_Core { : array_merge($locales, array($default)); module::set_var("gallery", "installed_locales", join("|", $locales)); + + // Clear the cache + self::$locales = null; } // @todo Might want to add a localizable language name as well. @@ -167,7 +170,7 @@ class locales_Core { } // Compare and score requested locales with installed ones - $matched_locales = array(); + $scored_locales = array(); foreach ($locale_preferences as $requested_value) { $scored_locale_match = self::_locale_match_score($requested_value); if ($scored_locale_match) { @@ -175,7 +178,7 @@ class locales_Core { } } - usort($matched_locales, array("locales", "_compare_locale_by_qvalue")); + usort($scored_locales, array("locales", "_compare_locale_by_qvalue")); $best_match = array_shift($scored_locales); if ($best_match) { @@ -202,7 +205,8 @@ class locales_Core { return $requested_locale_and_qvalue; } list ($language) = explode("_", $requested_locale . "_"); - if (isset(self::$language_subtag_to_locale[$language])) { + if (isset(self::$language_subtag_to_locale[$language]) && + isset($installed[self::$language_subtag_to_locale[$language]])) { return array(self::$language_subtag_to_locale[$language], $qvalue * 0.66); } return null; |
