Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const fs = require('fs');
const path = require('path');
const glob = require('glob');
const i18n = require('../lib/i18n/i18n.js');
const lookupClosestLocale = require('lookup-closest-locale');
const cldrAliasData = require('cldr-core/supplemental/aliases.json');
const cldrAliases = cldrAliasData.supplemental.metadata.alias.languageAlias;
const cldrParentsData = require('cldr-core/supplemental/parentLocales.json');
const cldrParentLocales = cldrParentsData.supplemental.parentLocales.parentLocale;
// const
// Object.entries(cldrAliases).forEach(([alias, entry]) => { if (locales[entry._replacement]) console.log(alias, entry) })
const lhLocales = glob
.sync('./lighthouse-core/lib/i18n/locales/*.json')
.filter(f => !f.includes('.ctc.json'))
.map(filename => path.parse(filename).name);
//
// 1. Validate the locales we store are canonical and not an alias
//
const aliasExceptions = ['zh-HK', 'zh-TW']; // TC pipeline still uses these codes rather than the CLDR's preferred `zh-Hant-HK`, `zh-Hant-TW`
for (const localeCode of lhLocales) {
import * as glob from "glob"
import * as path from "path"
let CLDR_DATES_DIR = path.dirname(require.resolve("cldr-dates-full/package.json"))
let CLDR_NUMBERS_DIR = path.dirname(require.resolve("cldr-numbers-full/package.json"))
// These are the exceptions to the default algorithm for determining a locale's
// parent locale.
let PARENT_LOCALES_HASH = require("cldr-core/supplemental/parentLocales.json")
.supplemental.parentLocales.parentLocale
let CALENDARS_LOCALES_HASH = glob.sync("*/ca-*.json", {
cwd: path.resolve(CLDR_DATES_DIR, "main")
}).reduce((hash, filename) => {
hash[path.dirname(filename)] = true
return hash
}, {})
let NUMBERS_LOCALES_HASH = glob.sync("*/numbers.json", {
cwd: path.resolve(CLDR_NUMBERS_DIR, "main")
}).reduce((hash, filename) => {
hash[path.dirname(filename)] = true
return hash
}, {})