Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if the original translationSuite is
{ "zh-TW": { ...translations-for-zh-TW } }
after the process below, it'll become
{ "zh-Hant": { ...translations-for-zh-TW } }
*/
Object.keys(translation).forEach((key) => {
// if the user set `locale=fr-CA`, it'll fallback to use `locale=fr`
const el = this.getEffectiveLocale(key);
const keyCldr = supportedLocales[el].cldr;
translation[keyCldr] = getLowercaseKeyedObj(translation[key]);
// we need to delete the unused key, otherwise, it will cause
// some issues when calling globalize.loadMessages()
if (keyCldr !== key) delete translation[key];
});
globalize.loadMessages({
// https://github.com/globalizejs/globalize/blob/master/doc/api/message/load-messages.md#messages-inheritance
root: getLowercaseKeyedObj(messages.en),
...translation,
});
this.updateCurrentLocaleOfKo(effectiveLocale);
// eslint-disable-next-line no-console
}).fail(() => console.warn(warningCLDRNotFound));
}
timeZoneData = attributes.timeZoneData || function() {
return require( "iana-tz-data" );
};
if ( typeof timeZoneData === "object" ) {
timeZoneDataObject = timeZoneData;
timeZoneData = function() {
return timeZoneDataObject;
};
}
// TODO
//assert( defaultLocale )
//assert( extracts )
Globalize.load( cldr( defaultLocale ) );
Globalize.loadMessages( messages( defaultLocale ) );
Globalize.loadTimeZone( timeZoneData() );
Globalize.locale( defaultLocale );
formattersAndParsers = alwaysArray( extracts ).reduce(function( sum, extract ) {
[].push.apply( sum, extract( Globalize ) );
return sum;
}, [] );
return compile( formattersAndParsers, compilerOptions );
}
// DevExtreme messages (en messages already included)
import deMessages from 'devextreme/localization/messages/de.json!json'
// CLDR data
import deCldrData from 'devextreme-cldr-data/de.json!json'
import supplementalCldrData from 'devextreme-cldr-data/supplemental.json!json'
import Globalize from 'globalize'
Globalize.load(
deCldrData,
supplementalCldrData
);
Globalize.loadMessages(deMessages);
Globalize.locale('de');
arguments[0] = sanitizedPath;
aux = globalizeMessageFormatter.apply(this, arguments);
arguments[0] = pathOrMessage;
return aux || globalizeMessageFormatter.apply(this, arguments);
}
var sanitizedPathExists = this.cldr.get(["globalize-messages/{bundle}", sanitizedPath]) !== undefined;
var pathExists = this.cldr.get(["globalize-messages/{bundle}", pathOrMessage]) !== undefined;
// Want to distinguish between default message and path value - just checking
// for sanitizedPath won't be enough, because sanitizedPath !== pathOrMessage
// for paths like "salutations/hi".
if (!sanitizedPathExists && !pathExists) {
aux[this.cldr.attributes.bundle] = {};
aux[this.cldr.attributes.bundle][sanitizedPath] = pathOrMessage;
Globalize.loadMessages(aux);
sanitizedPathExists = true;
}
arguments[0] = sanitizedPathExists ? sanitizedPath : pathOrMessage;
return globalizeMessageFormatter.apply(this, arguments);
};
loadDefaultLocaleData() {
globalize.load(likelySubtags, numberingSystems, timeData, weekData,
caGregorian, numbers, timeZoneNames, plurals);
globalize.loadMessages(getLowercaseKeyedObj(messages));
this.updateCurrentLocaleOfKo(DEFAULT_LOCALE, true);
},
static loadMessages(messageData) {
return Globalize.loadMessages(messageData);
}
static loadMessages(messageData) {
return Globalize.loadMessages(messageData);
}
var data = {};
function set(data, path, value) {
var i;
var node = data;
var length = path.length;
for (i = 0; i < length - 1; i++) {
if (!node[path[i]]) {
node[path[i]] = {};
}
node = node[path[i]];
}
node[path[i]] = value;
}
set(data, [globalize.cldr.attributes.bundle].concat(path), message);
Globalize.loadMessages(data);
};
Globalize.load(
require( 'cldr-data/main/en/ca-gregorian' ),
require( 'cldr-data/main/en/timeZoneNames' ),
require( 'cldr-data/main/en/numbers' ),
require( 'cldr-data/main/en/currencies' ),
require( 'cldr-data/main/pt/ca-gregorian' ),
require( 'cldr-data/main/pt/timeZoneNames' ),
require( 'cldr-data/main/pt/numbers' ),
require( 'cldr-data/main/pt/currencies' ),
require( 'cldr-data/supplemental/currencyData' ),
require( 'cldr-data/supplemental/plurals' ),
require( 'cldr-data/supplemental/likelySubtags' ),
require( 'cldr-data/supplemental/timeData' ),
require( 'cldr-data/supplemental/weekData' )
);
Globalize.loadMessages(messages);
React.render(
, document.getElementById('currency')
);
React.render(
, document.getElementById('dates')
);
React.render(
, document.getElementById('messages')
);
React.render(
, document.getElementById('numbers')
);
loadTranslations(...translations) {
if (!this[_globalize]) {
throw new GlobalizationNotLoadedError();
}
Globalize.loadMessages(...translations);
}