How to use the globalize 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 joshswan / react-native-globalize / lib / globalize.js View on Github external
// Throw error if no locale
    if (!this.locale) {
      throw new Error('Globalize: CLDR data for the selected language/locale has not been loaded! Check the locale you\'re using and remember that only certain data is included by default!');
    }

    // Set options
    this.options = Object.assign({
      warnOnMissingMessage: true,
    }, options);

    // Set currency code
    this.currencyCode = currencyCode || 'USD';

    // Create new Globalize instance
    this.globalize = new Globalize(this.locale);

    // Set up caches for generated formatters
    this._currencyFormatters = {};
    this._dateFormatters = {};
    this._dateParsers = {};
    this._messageFormatters = {};
    this._numberFormatters = {};
    this._numberParsers = {};
    this._pluralGenerators = {};
    this._relativeTimeFormatters = {};
    this._unitFormatters = {};
  }
github globalizejs / react-globalize / src / generator.js View on Github external
setup(props) {
            this.globalize = props.locale ? Globalize(props.locale) : Globalize;
            this.domProps = Object.keys(props).filter(omit(globalizePropNames)).reduce(function(memo, propKey) {
                memo[propKey] = props[propKey];
                return memo;
            }, {});

            this.globalizePropValues = localPropNames.map(function(element) {
                return props[element];
            });
            this.globalizePropValues[0] = props.children;

            beforeFormat.call(this, props);
            var formattedValue = this.globalize[fn](...this.globalizePropValues);
            this.value = alwaysArray(afterFormat.call(this, props, formattedValue));
        }
github Kloudless / file-picker / src / explorer / js / localization.js View on Github external
updateCurrentLocaleOfKo(effectiveLocale, isDefalutLocale = false) {
    const cldrLocale = supportedLocales[effectiveLocale].cldr;
    const globalizeLocaleObject = globalize(cldrLocale);
    const localeSettings = {
      globalize: globalizeLocaleObject,
      locale: effectiveLocale,
    };
    if (!isDefalutLocale) {
      loadedLocales[effectiveLocale] = localeSettings;
    }
    currentLocale(localeSettings);
  },
github kerrishotts / Mastering-PhoneGap-Code-Package / logology-v05 / src / www / js / lib / Localization.js View on Github external
async loadLocale(...addtlCultureData) {
		let locale = await this.getDeviceLocale();
		Globalize.load(
			require("cldr-data/main/en/ca-gregorian"),
			require("cldr-data/main/en/currencies"),
			require("cldr-data/main/en/dateFields"),
			require("cldr-data/main/en/numbers"),
			require("cldr-data/supplemental/currencyData"),
			require("cldr-data/supplemental/likelySubtags"),
			require("cldr-data/supplemental/plurals"),
			require("cldr-data/supplemental/timeData"),
			require("cldr-data/supplemental/weekData"),
			...addtlCultureData
		);
		Globalize.locale(locale);
		this[_globalize] = new Globalize(locale);
		return locale;
	}