How to use the cldr.localeIds function in cldr

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

github angular / angular / scripts / cldr / gen_plural_rules.js View on Github external
/**
 * @license
 * Copyright Google Inc. All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */

const cldr = require('cldr');
// locale list
const locales = cldr.localeIds;
const langToRule = {};
const ruleToLang = {};
const variants = [];
const localeToVariant = {};
const DEFAULT_RULE = `function anonymous(n\n/**/) {\nreturn"other"\n}`;
const EMPTY_RULE = `function anonymous(n\n/**/) {\n\n}`;

locales.forEach(locale => {
  const rule = normalizeRule(cldr.extractPluralRuleFunction(locale).toString());
  const lang = getVariantLang(locale, rule);

  if (!lang || !rule) {
    return;
  }

  if (!ruleToLang[rule]) {
github bobisjan / ember-format / lib / commands / format-locales.js View on Github external
findLocales: function() {
    var re = new RegExp('_', 'g');

    return cldr.localeIds.map(function(locale) {
      return locale.replace(re, '-');
    }).filter(function(locale) {
      if (locale === 'root') {
        return false;
      }

      var parts = locale.split('-');

      return parts.length === 1;
    });
  }
github ArminTamzarian / node-calendar / node-calendar.js View on Github external
function setlocale(locale) {
      locale = typeof(locale) === "undefined" ? "en_US" : locale;

      if((cldr && (cldr.localeIds.indexOf(locale.replace(/-/g, '_').toLowerCase()) === -1)) || (!cldr && ((locale.replace(/-/g, '_').toLowerCase() !== "en_us")))) {
         throw new IllegalLocaleError();
      }

      this.day_name   = _extractLocaleDays(false, locale);
      this.day_abbr   = _extractLocaleDays(true, locale);
      this.month_name = _extractLocaleMonths(false, locale);
      this.month_abbr = _extractLocaleMonths(true, locale);
    };
github ember-intl / ember-intl / lib / extract.js View on Github external
function isValidLocale(locale) {
    return cldr.localeIds.indexOf(normalize(locale)) >= 0;
}
github bobisjan / ember-format / blueprints / locale / index.js View on Github external
isKnownLocaleCode: function(code) {
    if (code === 'root') {
      return false;
    }

    code = code.replace(/-/g, '_');
    code = code.toLowerCase();

    return cldr.localeIds.indexOf(code) >= 0;
  },