mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 08:50:06 +02:00
[INTL] Fallback locale map for PR #169
This commit is contained in:
parent
45e1d935ca
commit
e0516e3f5c
1 changed files with 9 additions and 0 deletions
|
@ -9,6 +9,10 @@ var getDefaultLocale = exports.getDefaultLocale = function() {
|
|||
return 'en_US';
|
||||
};
|
||||
|
||||
var fallbackMap = {
|
||||
'zh_TW': 'zh_CN'
|
||||
};
|
||||
|
||||
var getLocale = exports.getLocale = function() {
|
||||
if (GlobalState.locale) {
|
||||
return GlobalState.locale;
|
||||
|
@ -44,6 +48,11 @@ var str = exports.str = function(key, params) {
|
|||
return 'NO INTL support for key ' + key;
|
||||
}
|
||||
|
||||
if (!strings[key][locale]) {
|
||||
// try falling back to another locale if in the map
|
||||
locale = fallbackMap[locale] || locale;
|
||||
}
|
||||
|
||||
if (!strings[key][locale]) {
|
||||
if (key !== 'error-untranslated') {
|
||||
return str('error-untranslated');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue