How to use the globalize.loadMessages function in globalize

To help you get started, we’ve selected a few globalize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kloudless / file-picker / src / explorer / js / localization.js View on Github external
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));
    }
github globalizejs / globalize-compiler / lib / compile-extracts.js View on Github external
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 );
}
github DevExpress / devextreme-examples / systemjs-angular-globalize / src / localization.ts View on Github external
// 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');
github globalizejs / react-globalize / src / message.js View on Github external
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);
};
github Kloudless / file-picker / src / explorer / js / localization.js View on Github external
loadDefaultLocaleData() {
    globalize.load(likelySubtags, numberingSystems, timeData, weekData,
      caGregorian, numbers, timeZoneNames, plurals);
    globalize.loadMessages(getLowercaseKeyedObj(messages));

    this.updateCurrentLocaleOfKo(DEFAULT_LOCALE, true);
  },
github joshswan / react-native-globalize / lib / globalize.js View on Github external
static loadMessages(messageData) {
    return Globalize.loadMessages(messageData);
  }
github joshswan / react-native-globalize / src / globalize.js View on Github external
static loadMessages(messageData) {
    return Globalize.loadMessages(messageData);
  }
github globalizejs / react-globalize / src / message.js View on Github external
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);
        };
github globalizejs / react-globalize / examples / index.js View on Github external
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')
);
github kerrishotts / Mastering-PhoneGap-Code-Package / logology-v05 / src / www / js / lib / Localization.js View on Github external
loadTranslations(...translations) {
		if (!this[_globalize]) {
			throw new GlobalizationNotLoadedError();
		}
		Globalize.loadMessages(...translations);
	}