@tginternal/language-util
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -44,3 +44,5 @@ "use strict"; | ||
var _a; | ||
return (__assign(__assign({}, acc), (_a = {}, _a[curr] = languages_1.getLanguageRegions(curr).map(function (r) { return flags_1.getCountryFlagEmoji(r); }), _a))); | ||
return (__assign(__assign({}, acc), (_a = {}, _a[curr] = languages_1.getLanguageRegions(curr).map(function (r) { | ||
return flags_1.getCountryFlagEmoji(r); | ||
}), _a))); | ||
}, {}); | ||
@@ -47,0 +49,0 @@ expect(result['en'][0]).toEqual('🇬🇧'); |
@@ -46,3 +46,45 @@ "use strict"; | ||
}); | ||
describe('languages', function () { | ||
test('returns correct language population', function () { | ||
var population = languageInfo_1.languageInfo['en'].population; | ||
expect(population).toBeGreaterThan(1000000000); | ||
}); | ||
test('returns correct language cs', function () { | ||
var population = languageInfo_1.languageInfo['cs'].population; | ||
expect(population).toBeGreaterThan(9000000); | ||
}); | ||
test('returns correct language cs-CZ', function () { | ||
var population = languageInfo_1.languageInfo['cs-CZ'].population; | ||
expect(population).toBeGreaterThan(9000000); | ||
}); | ||
test('returns correct language zh-Hans', function () { | ||
var population = languageInfo_1.languageInfo['zh-Hans'].population; | ||
expect(population).toBeGreaterThan(9000000); | ||
}); | ||
test('returns territory by language', function () { | ||
var territories = languageInfo_1.languageInfo['cs'].regions; | ||
expect(territories).toEqual(['CZ']); | ||
}); | ||
test('returns territory from parsed region', function () { | ||
var territories = languageInfo_1.languageInfo['en-US'].regions; | ||
expect(territories).toEqual(['US']); | ||
}); | ||
test('returns correct territories for english', function () { | ||
var territories = languageInfo_1.languageInfo['en'].regions; | ||
expect(territories.length).toEqual(89); | ||
expect(territories[0]).toEqual('GB'); | ||
expect(territories[1]).toEqual('US'); | ||
}); | ||
test('returns territories for spanish', function () { | ||
var territories = languageInfo_1.languageInfo['es'].regions; | ||
expect(territories.length).toEqual(23); | ||
expect(territories[0]).toEqual('ES'); | ||
}); | ||
test('returns territories for french', function () { | ||
var territories = languageInfo_1.languageInfo['fr'].regions; | ||
expect(territories.length).toEqual(45); | ||
expect(territories[0]).toEqual('FR'); | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=languageInfo.test.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.supportedFlags = void 0; | ||
exports.supportedFlags = ["🇳🇦", "🇪🇹", "🇪🇬", "🇩🇿", "🇸🇩", "🇮🇶", "🇾🇪", "🇲🇦", "🇸🇾", "🇯🇴", "🇹🇳", "🇦🇪", "🇱🇾", "🇵🇸", "🇸🇦", "🇱🇧", "🇸🇴", "🇴🇲", "🇲🇷", "🇰🇼", "🇹🇩", "🇶🇦", "🇮🇱", "🇧🇭", "🇪🇭", "🇰🇲", "🇪🇷", "🇩🇯", "🇸🇸", "🇦🇿", "🇧🇾", "🇧🇬", "🇧🇩", "🇮🇳", "🇧🇦", "🇦🇩", "🇪🇸", "🇫🇷", "🇮🇹", "🇨🇿", "🇩🇰", "🇬🇱", "🇩🇪", "🇦🇹", "🇨🇭", "🇧🇪", "🇱🇺", "🇱🇮", "🇬🇷", "🇨🇾", "🇬🇧", "🇺🇸", "🇵🇰", "🇳🇬", "🇵🇭", "🇹🇿", "🇦🇺", "🇰🇪", "🇬🇭", "🇮🇪", "🇲🇬", "🇱🇷", "🇭🇰", "🇯🇲", "🇧🇼", "🇬🇲", "🇧🇧", "🇧🇸", "🇧🇿", "🇦🇬", "🇨🇦", "🇿🇦", "🇲🇼", "🇨🇲", "🇿🇼", "🇸🇬", "🇳🇿", "🇵🇬", "🇿🇲", "🇸🇱", "🇷🇼", "🇺🇬", "🇵🇷", "🇲🇺", "🇸🇿", "🇸🇧", "🇲🇹", "🇹🇹", "🇩🇲", "🇫🇯", "🇬🇾", "🇱🇸", "🇻🇺", "🇬🇺", "🇱🇨", "🇬🇩", "🇬🇬", "🇮🇲", "🇰🇮", "🇻🇨", "🇲🇭", "🇧🇲", "🇫🇲", "🇰🇳", "🇰🇾", "🇦🇸", "🇬🇮", "🇦🇮", "🇯🇪", "🇻🇮", "🇹🇨", "🇲🇵", "🇻🇬", "🇸🇨", "🇸🇽", "🇹🇴", "🇳🇷", "🇨🇰", "🇧🇮", "🇸🇭", "🇼🇸", "🇮🇴", "🇲🇸", "🇫🇰", "🇵🇼", "🇳🇫", "🇨🇽", "🇹🇰", "🇳🇺", "🇹🇻", "🇩🇬", "🇺🇲", "🇨🇨", "🇵🇳", "🇫🇮", "🇲🇴", "🇲🇾", "🇳🇱", "🇸🇪", "🇸🇮", "🇲🇽", "🇨🇴", "🇦🇷", "🇻🇪", "🇵🇪", "🇨🇱", "🇪🇨", "🇬🇹", "🇨🇺", "🇩🇴", "🇭🇳", "🇧🇴", "🇸🇻", "🇨🇷", "🇳🇮", "🇺🇾", "🇵🇦", "🇬🇶", "🇵🇾", "🇪🇦", "🇮🇨", "🇧🇷", "🇪🇪", "🇮🇷", "🇦🇫", "🇨🇮", "🇲🇱", "🇧🇫", "🇳🇪", "🇸🇳", "🇹🇬", "🇧🇯", "🇨🇬", "🇨🇩", "🇬🇳", "🇨🇫", "🇬🇦", "🇷🇪", "🇭🇹", "🇲🇶", "🇬🇵", "🇳🇨", "🇵🇫", "🇬🇫", "🇾🇹", "🇲🇨", "🇲🇫", "🇼🇫", "🇧🇱", "🇵🇲", "🇭🇷", "🇭🇺", "🇦🇲", "🇮🇩", "🇮🇸", "🇸🇲", "🇻🇦", "🇯🇵", "🇬🇪", "🇰🇿", "🇰🇭", "🇰🇷", "🇰🇵", "🇰🇬", "🇱🇦", "🇱🇹", "🇱🇻", "🇲🇰", "🇲🇳", "🇧🇳", "🇲🇲", "🇳🇴", "🇸🇯", "🇳🇵", "🇸🇷", "🇦🇼", "🇧🇶", "🇨🇼", "🇵🇱", "🇦🇴", "🇵🇹", "🇲🇿", "🇬🇼", "🇹🇱", "🇨🇻", "🇸🇹", "🇷🇴", "🇲🇩", "🇷🇺", "🇺🇦", "🇱🇰", "🇸🇰", "🇦🇱", "🇽🇰", "🇷🇸", "🇲🇪", "🇦🇽", "🇹🇭", "🇹🇲", "🇹🇷", "🇺🇿", "🇻🇳", "🇹🇼", "🇨🇳", "🇧🇹", "🇫🇴", "🇹🇯", "🏁"]; | ||
exports.supportedFlags = [ | ||
'🇳🇦', | ||
'🇪🇹', | ||
'🇪🇬', | ||
'🇩🇿', | ||
'🇸🇩', | ||
'🇮🇶', | ||
'🇾🇪', | ||
'🇲🇦', | ||
'🇸🇾', | ||
'🇯🇴', | ||
'🇹🇳', | ||
'🇦🇪', | ||
'🇱🇾', | ||
'🇵🇸', | ||
'🇸🇦', | ||
'🇱🇧', | ||
'🇸🇴', | ||
'🇴🇲', | ||
'🇲🇷', | ||
'🇰🇼', | ||
'🇹🇩', | ||
'🇶🇦', | ||
'🇮🇱', | ||
'🇧🇭', | ||
'🇪🇭', | ||
'🇰🇲', | ||
'🇪🇷', | ||
'🇩🇯', | ||
'🇸🇸', | ||
'🇦🇿', | ||
'🇧🇾', | ||
'🇧🇬', | ||
'🇧🇩', | ||
'🇮🇳', | ||
'🇧🇦', | ||
'🇦🇩', | ||
'🇪🇸', | ||
'🇫🇷', | ||
'🇮🇹', | ||
'🇨🇿', | ||
'🇩🇰', | ||
'🇬🇱', | ||
'🇩🇪', | ||
'🇦🇹', | ||
'🇨🇭', | ||
'🇧🇪', | ||
'🇱🇺', | ||
'🇱🇮', | ||
'🇬🇷', | ||
'🇨🇾', | ||
'🇬🇧', | ||
'🇺🇸', | ||
'🇵🇰', | ||
'🇳🇬', | ||
'🇵🇭', | ||
'🇹🇿', | ||
'🇦🇺', | ||
'🇰🇪', | ||
'🇬🇭', | ||
'🇮🇪', | ||
'🇲🇬', | ||
'🇱🇷', | ||
'🇭🇰', | ||
'🇯🇲', | ||
'🇧🇼', | ||
'🇬🇲', | ||
'🇧🇧', | ||
'🇧🇸', | ||
'🇧🇿', | ||
'🇦🇬', | ||
'🇨🇦', | ||
'🇿🇦', | ||
'🇲🇼', | ||
'🇨🇲', | ||
'🇿🇼', | ||
'🇸🇬', | ||
'🇳🇿', | ||
'🇵🇬', | ||
'🇿🇲', | ||
'🇸🇱', | ||
'🇷🇼', | ||
'🇺🇬', | ||
'🇵🇷', | ||
'🇲🇺', | ||
'🇸🇿', | ||
'🇸🇧', | ||
'🇲🇹', | ||
'🇹🇹', | ||
'🇩🇲', | ||
'🇫🇯', | ||
'🇬🇾', | ||
'🇱🇸', | ||
'🇻🇺', | ||
'🇬🇺', | ||
'🇱🇨', | ||
'🇬🇩', | ||
'🇬🇬', | ||
'🇮🇲', | ||
'🇰🇮', | ||
'🇻🇨', | ||
'🇲🇭', | ||
'🇧🇲', | ||
'🇫🇲', | ||
'🇰🇳', | ||
'🇰🇾', | ||
'🇦🇸', | ||
'🇬🇮', | ||
'🇦🇮', | ||
'🇯🇪', | ||
'🇻🇮', | ||
'🇹🇨', | ||
'🇲🇵', | ||
'🇻🇬', | ||
'🇸🇨', | ||
'🇸🇽', | ||
'🇹🇴', | ||
'🇳🇷', | ||
'🇨🇰', | ||
'🇧🇮', | ||
'🇸🇭', | ||
'🇼🇸', | ||
'🇮🇴', | ||
'🇲🇸', | ||
'🇫🇰', | ||
'🇵🇼', | ||
'🇳🇫', | ||
'🇨🇽', | ||
'🇹🇰', | ||
'🇳🇺', | ||
'🇹🇻', | ||
'🇩🇬', | ||
'🇺🇲', | ||
'🇨🇨', | ||
'🇵🇳', | ||
'🇫🇮', | ||
'🇲🇴', | ||
'🇲🇾', | ||
'🇳🇱', | ||
'🇸🇪', | ||
'🇸🇮', | ||
'🇲🇽', | ||
'🇨🇴', | ||
'🇦🇷', | ||
'🇻🇪', | ||
'🇵🇪', | ||
'🇨🇱', | ||
'🇪🇨', | ||
'🇬🇹', | ||
'🇨🇺', | ||
'🇩🇴', | ||
'🇭🇳', | ||
'🇧🇴', | ||
'🇸🇻', | ||
'🇨🇷', | ||
'🇳🇮', | ||
'🇺🇾', | ||
'🇵🇦', | ||
'🇬🇶', | ||
'🇵🇾', | ||
'🇪🇦', | ||
'🇮🇨', | ||
'🇧🇷', | ||
'🇪🇪', | ||
'🇮🇷', | ||
'🇦🇫', | ||
'🇨🇮', | ||
'🇲🇱', | ||
'🇧🇫', | ||
'🇳🇪', | ||
'🇸🇳', | ||
'🇹🇬', | ||
'🇧🇯', | ||
'🇨🇬', | ||
'🇨🇩', | ||
'🇬🇳', | ||
'🇨🇫', | ||
'🇬🇦', | ||
'🇷🇪', | ||
'🇭🇹', | ||
'🇲🇶', | ||
'🇬🇵', | ||
'🇳🇨', | ||
'🇵🇫', | ||
'🇬🇫', | ||
'🇾🇹', | ||
'🇲🇨', | ||
'🇲🇫', | ||
'🇼🇫', | ||
'🇧🇱', | ||
'🇵🇲', | ||
'🇭🇷', | ||
'🇭🇺', | ||
'🇦🇲', | ||
'🇮🇩', | ||
'🇮🇸', | ||
'🇸🇲', | ||
'🇻🇦', | ||
'🇯🇵', | ||
'🇬🇪', | ||
'🇰🇿', | ||
'🇰🇭', | ||
'🇰🇷', | ||
'🇰🇵', | ||
'🇰🇬', | ||
'🇱🇦', | ||
'🇱🇹', | ||
'🇱🇻', | ||
'🇲🇰', | ||
'🇲🇳', | ||
'🇧🇳', | ||
'🇲🇲', | ||
'🇳🇴', | ||
'🇸🇯', | ||
'🇳🇵', | ||
'🇸🇷', | ||
'🇦🇼', | ||
'🇧🇶', | ||
'🇨🇼', | ||
'🇵🇱', | ||
'🇦🇴', | ||
'🇵🇹', | ||
'🇲🇿', | ||
'🇬🇼', | ||
'🇹🇱', | ||
'🇨🇻', | ||
'🇸🇹', | ||
'🇷🇴', | ||
'🇲🇩', | ||
'🇷🇺', | ||
'🇺🇦', | ||
'🇱🇰', | ||
'🇸🇰', | ||
'🇦🇱', | ||
'🇽🇰', | ||
'🇷🇸', | ||
'🇲🇪', | ||
'🇦🇽', | ||
'🇹🇭', | ||
'🇹🇲', | ||
'🇹🇷', | ||
'🇺🇿', | ||
'🇻🇳', | ||
'🇹🇼', | ||
'🇨🇳', | ||
'🇧🇹', | ||
'🇫🇴', | ||
'🇹🇯', | ||
'🏁', | ||
]; | ||
//# sourceMappingURL=supportedFlags.js.map |
@@ -1,4 +0,3 @@ | ||
export declare const getLanguagePopulation: (language: string) => number; | ||
export declare const getLanguageRegions: (locale: string) => string[]; | ||
export declare const isValidLanguageTag: (tag: string) => boolean; | ||
export declare const getLanguageRegions: (language: string) => string[]; | ||
export interface TerritoryInfo { | ||
@@ -5,0 +4,0 @@ languagePopulation?: { |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isValidLanguageTag = exports.getLanguageRegions = exports.getLanguagePopulation = void 0; | ||
var territoryInfoData = __importStar(require("cldr-core/supplemental/territoryInfo.json")); | ||
exports.getLanguageRegions = exports.isValidLanguageTag = void 0; | ||
var intl_getcanonicallocales_1 = require("@formatjs/intl-getcanonicallocales"); | ||
var languageTerritoryOrder_1 = require("./languageTerritoryOrder"); | ||
var languageData = __importStar(require("cldr-core/supplemental/languageData.json")); | ||
var getLanguagePopulation = function (language) { | ||
var _a, _b; | ||
var parsed = intl_getcanonicallocales_1.parseUnicodeLanguageId(language); | ||
var info = territoryInfoData.supplemental.territoryInfo; | ||
if (parsed.region) { | ||
var regionInfo = info[parsed.region]; | ||
var populationPercent = (_b = (_a = regionInfo === null || regionInfo === void 0 ? void 0 : regionInfo.languagePopulation) === null || _a === void 0 ? void 0 : _a[parsed.lang]) === null || _b === void 0 ? void 0 : _b._populationPercent; | ||
var population = regionInfo === null || regionInfo === void 0 ? void 0 : regionInfo._population; | ||
if (population && populationPercent) { | ||
return (parseInt(populationPercent) / 100) * parseInt(population); | ||
} | ||
return 0; | ||
} | ||
return Object.values(info).reduce(function (acc, data) { | ||
var _a; | ||
var typedData = data; | ||
var languagePopulation = (_a = typedData.languagePopulation) === null || _a === void 0 ? void 0 : _a[parsed.lang]; | ||
if (languagePopulation && | ||
languagePopulation._populationPercent && | ||
typedData._population) { | ||
return (acc + | ||
Math.ceil((parseFloat(languagePopulation._populationPercent) / 100) * | ||
parseInt(typedData._population))); | ||
} | ||
return acc; | ||
}, 0); | ||
}; | ||
exports.getLanguagePopulation = getLanguagePopulation; | ||
var getLanguageRegions = function (locale) { | ||
var parsed = intl_getcanonicallocales_1.parseUnicodeLanguageId(locale); | ||
if (parsed.region) { | ||
return [parsed.region]; | ||
} | ||
if (parsed.lang) { | ||
var info = languageData.supplemental.languageData; | ||
var langInfo = info[parsed.lang]; | ||
var territories = langInfo === null || langInfo === void 0 ? void 0 : langInfo._territories; | ||
if (!territories) { | ||
return []; | ||
} | ||
return sortTerritoriesByLanguage(territories, parsed.lang) || []; | ||
} | ||
return []; | ||
}; | ||
exports.getLanguageRegions = getLanguageRegions; | ||
var languageInfo_1 = require("./generated/languageInfo"); | ||
var isValidLanguageTag = function (tag) { | ||
@@ -97,66 +10,4 @@ return intl_getcanonicallocales_1.isStructurallyValidLanguageTag(tag); | ||
exports.isValidLanguageTag = isValidLanguageTag; | ||
var getTerritoriesLanguagePopulations = function (territories, language) { | ||
var info = territoryInfoData.supplemental.territoryInfo; | ||
var territoriesLanguagePopulation = {}; | ||
territories.forEach(function (t) { | ||
var _a; | ||
var territoryData = info[t]; | ||
var languagePopulation = (_a = territoryData === null || territoryData === void 0 ? void 0 : territoryData.languagePopulation) === null || _a === void 0 ? void 0 : _a[language]; | ||
if (languagePopulation) { | ||
territoriesLanguagePopulation[t] = languagePopulation; | ||
territoriesLanguagePopulation[t].territoryTotalPopulation = | ||
territoryData === null || territoryData === void 0 ? void 0 : territoryData._population; | ||
} | ||
}); | ||
return territoriesLanguagePopulation; | ||
}; | ||
var sortTerritoriesByLanguage = function (territories, language) { | ||
var customOrder = languageTerritoryOrder_1.languageTerritoryOrder[language] || []; | ||
territories = territories.filter(function (t) { return customOrder.indexOf(t) === -1; }); | ||
var territoriesLanguagePopulation = getTerritoriesLanguagePopulations(territories, language); | ||
territories.sort(function (a, b) { | ||
var _a, _b, _c, _d, _e, _f; | ||
var aOfficialStatus = (_a = territoriesLanguagePopulation[a]) === null || _a === void 0 ? void 0 : _a._officialStatus; | ||
var bOfficialStatus = (_b = territoriesLanguagePopulation[b]) === null || _b === void 0 ? void 0 : _b._officialStatus; | ||
if ((aOfficialStatus == 'official' || | ||
aOfficialStatus == 'de_facto_official') && | ||
bOfficialStatus != 'official' && | ||
bOfficialStatus !== 'de_facto_official') { | ||
return -1; | ||
} | ||
if ((bOfficialStatus == 'official' || | ||
bOfficialStatus == 'de_facto_official') && | ||
aOfficialStatus != 'official' && | ||
aOfficialStatus !== 'de_facto_official') { | ||
return -1; | ||
} | ||
if (aOfficialStatus == 'official_regional' && | ||
bOfficialStatus != 'official_regional') { | ||
return -1; | ||
} | ||
if (bOfficialStatus == 'official_regional' && | ||
aOfficialStatus != 'official_regional') { | ||
return 1; | ||
} | ||
var aPercent = (_c = territoriesLanguagePopulation[a]) === null || _c === void 0 ? void 0 : _c._populationPercent; | ||
var bPercent = (_d = territoriesLanguagePopulation[b]) === null || _d === void 0 ? void 0 : _d._populationPercent; | ||
var aTotalPopulation = (_e = territoriesLanguagePopulation[a]) === null || _e === void 0 ? void 0 : _e.territoryTotalPopulation; | ||
var bTotalPopulation = (_f = territoriesLanguagePopulation[b]) === null || _f === void 0 ? void 0 : _f.territoryTotalPopulation; | ||
if (aPercent === bPercent) { | ||
return 0; | ||
} | ||
if (aPercent && !bPercent) { | ||
return -1; | ||
} | ||
if (bPercent && !aPercent) { | ||
return 1; | ||
} | ||
if (!aTotalPopulation || !bTotalPopulation) { | ||
return 0; | ||
} | ||
return (parseFloat(bPercent) * parseInt(bTotalPopulation) - | ||
parseFloat(aPercent) * parseInt(aTotalPopulation)); | ||
}); | ||
return __spreadArray(__spreadArray([], __read(customOrder)), __read(territories)); | ||
}; | ||
var getLanguageRegions = function (language) { var _a; return ((_a = languageInfo_1.languageInfo[language]) === null || _a === void 0 ? void 0 : _a.regions) || []; }; | ||
exports.getLanguageRegions = getLanguageRegions; | ||
//# sourceMappingURL=languages.js.map |
@@ -5,22 +5,2 @@ "use strict"; | ||
describe('languages', function () { | ||
test('returns correct language population', function () { | ||
var population = languages_1.getLanguagePopulation('en'); | ||
expect(population).toBeGreaterThan(1000000000); | ||
}); | ||
test('returns correct language cs', function () { | ||
var population = languages_1.getLanguagePopulation('cs'); | ||
expect(population).toBeGreaterThan(9000000); | ||
}); | ||
test('returns correct language cs-CZ', function () { | ||
var population = languages_1.getLanguagePopulation('cs-CZ'); | ||
expect(population).toBeGreaterThan(9000000); | ||
}); | ||
test('returns correct language zh-Hans', function () { | ||
var population = languages_1.getLanguagePopulation('zh-Hans'); | ||
expect(population).toBeGreaterThan(9000000); | ||
}); | ||
test('returns territory by language', function () { | ||
var territories = languages_1.getLanguageRegions('cs'); | ||
expect(territories).toEqual(['CZ']); | ||
}); | ||
test('returns territory from parsed region', function () { | ||
@@ -30,19 +10,7 @@ var territories = languages_1.getLanguageRegions('en-US'); | ||
}); | ||
test('returns correct territories for english', function () { | ||
var territories = languages_1.getLanguageRegions('en'); | ||
expect(territories.length).toEqual(89); | ||
expect(territories[0]).toEqual('GB'); | ||
expect(territories[1]).toEqual('US'); | ||
test('validates language tag', function () { | ||
expect(languages_1.isValidLanguageTag('en')).toBeTruthy(); | ||
expect(languages_1.isValidLanguageTag('en_de')).toBeFalsy(); | ||
}); | ||
test('returns territories for spanish', function () { | ||
var territories = languages_1.getLanguageRegions('es'); | ||
expect(territories.length).toEqual(23); | ||
expect(territories[0]).toEqual('ES'); | ||
}); | ||
test('returns territories for french', function () { | ||
var territories = languages_1.getLanguageRegions('fr'); | ||
expect(territories.length).toEqual(45); | ||
expect(territories[0]).toEqual('FR'); | ||
}); | ||
}); | ||
//# sourceMappingURL=languages.test.js.map |
{ | ||
"name": "@tginternal/language-util", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Language data utility for Tolgee localization tool", | ||
@@ -45,8 +45,9 @@ "main": "lib/index.js", | ||
"ts-node": "^10.0.0", | ||
"typescript": "^4.3.2" | ||
"typescript": "^4.3.2", | ||
"prettier": "^2.3.1", | ||
"eslint": "^7.28.0" | ||
}, | ||
"dependencies": { | ||
"eslint": "^7.28.0", | ||
"latinize": "^0.5.0", | ||
"prettier": "^2.3.1" | ||
"@formatjs/intl-getcanonicallocales": "^1.7.0" | ||
}, | ||
@@ -53,0 +54,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
2
0
1012939
21
6635
+ Added@formatjs/intl-getcanonicallocales@1.9.2(transitive)
+ Addedtslib@2.7.0(transitive)
- Removedeslint@^7.28.0
- Removedprettier@^2.3.1
- Removed@babel/code-frame@7.12.11(transitive)
- Removed@babel/helper-validator-identifier@7.24.7(transitive)
- Removed@babel/highlight@7.24.7(transitive)
- Removed@eslint/eslintrc@0.4.3(transitive)
- Removed@humanwhocodes/config-array@0.5.0(transitive)
- Removed@humanwhocodes/object-schema@1.2.1(transitive)
- Removedacorn@7.4.1(transitive)
- Removedacorn-jsx@5.3.2(transitive)
- Removedajv@6.12.68.17.1(transitive)
- Removedansi-colors@4.1.3(transitive)
- Removedansi-regex@5.0.1(transitive)
- Removedansi-styles@3.2.14.3.0(transitive)
- Removedargparse@1.0.10(transitive)
- Removedastral-regex@2.0.0(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedcallsites@3.1.0(transitive)
- Removedchalk@2.4.24.1.2(transitive)
- Removedcolor-convert@1.9.32.0.1(transitive)
- Removedcolor-name@1.1.31.1.4(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedcross-spawn@7.0.3(transitive)
- Removeddebug@4.3.7(transitive)
- Removeddeep-is@0.1.4(transitive)
- Removeddoctrine@3.0.0(transitive)
- Removedemoji-regex@8.0.0(transitive)
- Removedenquirer@2.4.1(transitive)
- Removedescape-string-regexp@1.0.54.0.0(transitive)
- Removedeslint@7.32.0(transitive)
- Removedeslint-scope@5.1.1(transitive)
- Removedeslint-utils@2.1.0(transitive)
- Removedeslint-visitor-keys@1.3.02.1.0(transitive)
- Removedespree@7.3.1(transitive)
- Removedesprima@4.0.1(transitive)
- Removedesquery@1.6.0(transitive)
- Removedesrecurse@4.3.0(transitive)
- Removedestraverse@4.3.05.3.0(transitive)
- Removedesutils@2.0.3(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedfast-levenshtein@2.0.6(transitive)
- Removedfast-uri@3.0.1(transitive)
- Removedfile-entry-cache@6.0.1(transitive)
- Removedflat-cache@3.2.0(transitive)
- Removedflatted@3.3.1(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedfunctional-red-black-tree@1.0.1(transitive)
- Removedglob@7.2.3(transitive)
- Removedglob-parent@5.1.2(transitive)
- Removedglobals@13.24.0(transitive)
- Removedhas-flag@3.0.04.0.0(transitive)
- Removedignore@4.0.6(transitive)
- Removedimport-fresh@3.3.0(transitive)
- Removedimurmurhash@0.1.4(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-fullwidth-code-point@3.0.0(transitive)
- Removedis-glob@4.0.3(transitive)
- Removedisexe@2.0.0(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjs-yaml@3.14.1(transitive)
- Removedjson-buffer@3.0.1(transitive)
- Removedjson-schema-traverse@0.4.11.0.0(transitive)
- Removedjson-stable-stringify-without-jsonify@1.0.1(transitive)
- Removedkeyv@4.5.4(transitive)
- Removedlevn@0.4.1(transitive)
- Removedlodash.merge@4.6.2(transitive)
- Removedlodash.truncate@4.4.2(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedms@2.1.3(transitive)
- Removednatural-compare@1.4.0(transitive)
- Removedonce@1.4.0(transitive)
- Removedoptionator@0.9.4(transitive)
- Removedparent-module@1.0.1(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpath-key@3.1.1(transitive)
- Removedpicocolors@1.1.0(transitive)
- Removedprelude-ls@1.2.1(transitive)
- Removedprettier@2.8.8(transitive)
- Removedprogress@2.0.3(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedregexpp@3.2.0(transitive)
- Removedrequire-from-string@2.0.2(transitive)
- Removedresolve-from@4.0.0(transitive)
- Removedrimraf@3.0.2(transitive)
- Removedsemver@7.6.3(transitive)
- Removedshebang-command@2.0.0(transitive)
- Removedshebang-regex@3.0.0(transitive)
- Removedslice-ansi@4.0.0(transitive)
- Removedsprintf-js@1.0.3(transitive)
- Removedstring-width@4.2.3(transitive)
- Removedstrip-ansi@6.0.1(transitive)
- Removedstrip-json-comments@3.1.1(transitive)
- Removedsupports-color@5.5.07.2.0(transitive)
- Removedtable@6.8.2(transitive)
- Removedtext-table@0.2.0(transitive)
- Removedtype-check@0.4.0(transitive)
- Removedtype-fest@0.20.2(transitive)
- Removeduri-js@4.4.1(transitive)
- Removedv8-compile-cache@2.4.0(transitive)
- Removedwhich@2.0.2(transitive)
- Removedword-wrap@1.2.5(transitive)
- Removedwrappy@1.0.2(transitive)