Skip to content

Commit

Permalink
fix stupid safari which defaults to en-US ... look for the base langu…
Browse files Browse the repository at this point in the history
…age and glob on that if we cannot find an exact match

git-svn-id: https://xerteonlinetoolkits.googlecode.com/svn/trunk@319 912cdd6b-5c7d-d5a7-a2ba-d0f0cdb91641
  • Loading branch information
Dave Goodwin committed Apr 29, 2012
1 parent 0668b6b commit 336f758
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions functions.php
Expand Up @@ -47,17 +47,20 @@ function _load_language_file($file_path)
// this does some magic interrogation of $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$language = new Zend_Locale();
// xerte seems to use en-GB instead of the more standard en_GB. Assume this convention will persist....
$language = str_replace('_', '-', $language);
$language_name = str_replace('_', '-', $language);
// Check that Xerte supports the required language.
if (!is_dir(dirname(__FILE__) . '/languages/' . $language)) {
if (!is_dir($languages . $language_name)) {

// try and catch e.g. getting back 'en' as our locale - so choose any english language pack
foreach (glob($languages . $language . '*') as $dir) {
foreach (glob($languages . $language->getLanguage() . '*') as $dir) {
$language = basename($dir);
break;
}
$language_name = "en-GB";
}
}
$language = $language_name;

}


$real_file_path = dirname(__FILE__) . '/languages/' . $language . $file_path;
Expand Down

0 comments on commit 336f758

Please sign in to comment.