react-intl-universal
Advanced tools
Comparing version 1.14.3 to 1.15.0
@@ -101,3 +101,4 @@ /* | ||
escapeHtml: true, // disable escape html in variable mode | ||
commonLocaleDataUrls: COMMON_LOCALE_DATA_URLS | ||
commonLocaleDataUrls: COMMON_LOCALE_DATA_URLS, | ||
fallbackLocale: null // Locale to use if a key is not found in the current locale | ||
}; | ||
@@ -130,4 +131,12 @@ } | ||
if (msg == null) { | ||
this.options.warningHandler("react-intl-universal key \"" + key + "\" not defined in " + currentLocale); | ||
return ""; | ||
if (this.options.fallbackLocale) { | ||
msg = this.getDescendantProp(locales[this.options.fallbackLocale], key); | ||
if (msg == null) { | ||
this.options.warningHandler("react-intl-universal key \"" + key + "\" not defined in " + currentLocale + " or the fallback locale, " + this.options.fallbackLocale); | ||
return ""; | ||
} | ||
} else { | ||
this.options.warningHandler("react-intl-universal key \"" + key + "\" not defined in " + currentLocale); | ||
return ""; | ||
} | ||
} | ||
@@ -134,0 +143,0 @@ if (variables) { |
{ | ||
"name": "react-intl-universal", | ||
"version": "1.14.3", | ||
"version": "1.15.0", | ||
"description": "Internationalize React apps. Not only for React.Component but also for Vanilla JS.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -281,2 +281,3 @@ ## Work at Alibaba 加入我们 | ||
* @param {Object} options.warningHandler Ability to accumulate missing messages using third party services. See https://github.com/alibaba/react-intl-universal/releases/tag/1.11.1 | ||
* @param {string} options.fallbackLocale Fallback locale such as 'zh-CN' to use if a key is not found in the current locale | ||
* @returns {Promise} | ||
@@ -283,0 +284,0 @@ */ |
@@ -73,2 +73,3 @@ declare module "react-intl-universal" { | ||
* @param {Object} options.warningHandler Ability to accumulate missing messages using third party services like Sentry | ||
* @param {string} options.fallbackLocale Fallback locale such as 'zh-CN' to use if a key is not found in the current locale | ||
* @param {boolean} options.escapeHtml To escape html. Default value is true. | ||
@@ -75,0 +76,0 @@ * @returns {Promise} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36457
395
416