summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/src/nfvo-utils/i18n/i18n.js
diff options
context:
space:
mode:
authorAvi Ziv <avi.ziv@amdocs.com>2017-07-18 19:45:38 +0300
committerAvi Ziv <avi.ziv@amdocs.com>2017-07-18 19:45:38 +0300
commitb8e2faf476202b6ffe61bc3a9a37df1304881d40 (patch)
treef78b8c0517d8e16c5ae610bf8b49f68ea8a312a1 /openecomp-ui/src/nfvo-utils/i18n/i18n.js
parent75aacbbe1acf78fa53378f07f0a8c7769449a17e (diff)
[SDC] Onboarding 1710 rebase.
Change-Id: If3b6b81d221fde13908f1e8160db6f7d9433c535 Signed-off-by: Avi Ziv <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-ui/src/nfvo-utils/i18n/i18n.js')
-rw-r--r--openecomp-ui/src/nfvo-utils/i18n/i18n.js26
1 files changed, 6 insertions, 20 deletions
diff --git a/openecomp-ui/src/nfvo-utils/i18n/i18n.js b/openecomp-ui/src/nfvo-utils/i18n/i18n.js
index 4d03ddb8dd..2f63dfe605 100644
--- a/openecomp-ui/src/nfvo-utils/i18n/i18n.js
+++ b/openecomp-ui/src/nfvo-utils/i18n/i18n.js
@@ -14,27 +14,17 @@
* permissions and limitations under the License.
*/
import IntlObj from 'intl';
-import IntlMessageFormatObj from 'intl-messageformat';
import IntlRelativeFormatObj from 'intl-relativeformat';
import createFormatCacheObj from 'intl-format-cache';
import i18nJson from 'i18nJson';
-
/*
Intl libs are using out dated transpailer from ecmascript6.
* TODO: As soon as they fix it, remove this assignments!!!
* */
var Intl = window.Intl || IntlObj.default,
- IntlMessageFormat = IntlMessageFormatObj.default,
IntlRelativeFormat = IntlRelativeFormatObj.default,
createFormatCache = createFormatCacheObj.default;
-var i18nData;
-
-if(i18nJson) {
- i18nData = i18nJson.dataWrapperArr[i18nJson.i18nDataIdx];
-}
-
-
/*extract locale*/
var _locale = window.localStorage && localStorage.getItem('user_locale');
if(!_locale) {
@@ -53,12 +43,11 @@ if(!_locale) {
}
var _localeUpper = _locale.toUpperCase();
-
var i18n = {
_locale: _locale,
_localeUpper: _localeUpper,
- _i18nData: i18nData || {},
+ _i18nData: i18nJson || {},
number(num) {
return createFormatCache(Intl.NumberFormat)(this._locale).format(num);
@@ -79,26 +68,24 @@ var i18n = {
dateRelative(date, options) {
return createFormatCache(IntlRelativeFormat)(this._locale, options).format(date);
},
-
- message(messageId, options) {
- return createFormatCache(IntlMessageFormat)(this._i18nData[messageId] || String(messageId), this._locale).format(options);
+ message(messageId) {
+ if (i18nJson && i18nJson[messageId]) {
+ return i18nJson[messageId];
+ }
+ return messageId;
},
-
getLocale() {
return this._locale;
},
-
getLocaleUpper() {
return this._localeUpper;
},
-
setLocale(locale) {
localStorage.setItem('user_locale', locale);
window.location.reload();
}
};
-
function i18nWrapper() {
return i18nWrapper.message.apply(i18nWrapper, arguments);
}
@@ -113,5 +100,4 @@ for (propKey in i18n) {
i18nWrapper[propKey] = prop;
}
-
export default i18nWrapper;