Skip to content

Commit

Permalink
Added a generic fallback for language codes not explicitly supported …
Browse files Browse the repository at this point in the history
…by WET (en-US, fr-BEm, etc...)
  • Loading branch information
LaurentGoderre committed Nov 5, 2012
1 parent c6709be commit 21ced91
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build/js/pe-ap-min.js

Large diffs are not rendered by default.

19 changes: 16 additions & 3 deletions src/js/pe-ap.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
}
pe.dance();
});
pe.add.language(pe.language);
pe.add.language(pe.language, pe.languages);
});
},
/**
Expand Down Expand Up @@ -1407,10 +1407,23 @@
* @memberof pe.add
* @function
* @param {string} lang The two (iso 639-1) or three (iso 639-2) letter language code of the page.
* @param {array} available of two (iso 639-1) or three (iso 639-2) letter language code supported by WET.
* @return {void}
*/
language: function (lang) {
var url = pe.add.liblocation + 'i18n/' + lang + pe.suffix + '.js';
language: function (lang, available) {
var d, url;
if (available.indexOf(lang) === -1) {
d = lang.indexOf('-');
if (d !== -1) {
lang = lang.substr(0, d);
if (available.indexOf(lang) === -1) {
lang = 'en';
}
} else {
lang = 'en';
}
}
url = pe.add.liblocation + 'i18n/' + lang + pe.suffix + '.js';
pe.add._load(url);
},
/**
Expand Down

0 comments on commit 21ced91

Please sign in to comment.