From e0516e3f5c7229062720b348da5063bde994861f Mon Sep 17 00:00:00 2001 From: Peter Cottle Date: Wed, 7 May 2014 17:45:17 -0700 Subject: [PATCH] [INTL] Fallback locale map for PR #169 --- src/js/intl/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/js/intl/index.js b/src/js/intl/index.js index 49bec6ec..42ae86b0 100644 --- a/src/js/intl/index.js +++ b/src/js/intl/index.js @@ -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');