Skip to content

Commit

Permalink
fix(i18n): system cache now supports regional designators in language…
Browse files Browse the repository at this point in the history
… codes

Name of a cached language file can now have the following structure:
 - language code (2-3 lowercase alphabets)
 - underscore followed by regional designator (2 lowercase alphabets)

Fixes #7187
  • Loading branch information
Juho Jaakkola committed Sep 3, 2014
1 parent e1ea9d0 commit 735ceb4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion engine/lib/languages.php
Expand Up @@ -249,7 +249,10 @@ function reload_all_translations() {
$cache_dir = $cache->getVariable("cache_path");
$filenames = elgg_get_file_list($cache_dir, array(), array(), array(".lang"));
foreach ($filenames as $filename) {
if (preg_match('/([a-z]+)\.[^.]+$/', $filename, $matches)) {
// Look for files matching for example 'en.lang', 'cmn.lang' or 'pt_br.lang'.
// Note that this regex is just for the system cache. The original language
// files are allowed to have uppercase letters (e.g. pt_BR.php).
if (preg_match('/(([a-z]{2,3})(_[a-z]{2})?)\.lang$/', $filename, $matches)) {
$language = $matches[1];
$data = elgg_load_system_cache("$language.lang");
if ($data) {
Expand Down
4 changes: 3 additions & 1 deletion languages/en.php
Expand Up @@ -1234,7 +1234,7 @@
'js:security:token_refreshed' => 'Connection to %s restored!',

/**
* Languages according to ISO 639-1
* Languages according to ISO 639-1 (with a couple of exceptions)
*/
"aa" => "Afar",
"ab" => "Abkhazian",
Expand All @@ -1253,6 +1253,7 @@
"bo" => "Tibetan",
"br" => "Breton",
"ca" => "Catalan",
"cmn" => "Mandarin Chinese", // ISO 639-3
"co" => "Corsican",
"cs" => "Czech",
"cy" => "Welsh",
Expand Down Expand Up @@ -1329,6 +1330,7 @@
"pl" => "Polish",
"ps" => "Pashto / Pushto",
"pt" => "Portuguese",
"pt_br" => 'Brazilian Portuguese',
"qu" => "Quechua",
"rm" => "Rhaeto-Romance",
"rn" => "Kirundi",
Expand Down

0 comments on commit 735ceb4

Please sign in to comment.