-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(phone-number): add missing locales & validation script
- Loading branch information
Showing
15 changed files
with
1,620 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
packages/ods/src/components/phone-number/scripts/validate-i18n-keys.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#! /usr/bin/env node | ||
|
||
const fs = require('fs'); | ||
const { glob } = require('glob'); | ||
|
||
const expectedIsoCodes = [ | ||
'ad','ae','af','ag','ai','al','am','ao','aq','ar','as','at','au','aw','ax', | ||
'az','ba','bb','bd','be','bf','bg','bh','bi','bj','bl','bm','bn','bo','br', | ||
'bs','bt','bw','by','bz','ca','cc','cd','cf','cg','ch','ci','ck','cl','cm', | ||
'cn','co','cr','cu','cv','cw','cx','cy','cz','de','dj','dk','dm','do','dz', | ||
'ec','ee','eg','eh','er','es','et','fi','fj','fk','fm','fo','fr','ga','gb', | ||
'gd','ge','gg','gh','gi','gl','gm','gn','gq','gr','gs','gt','gu','gw','gy', | ||
'hk','hn','hr','ht','hu','id','ie','il','im','in','iq','ir','is','it','je', | ||
'jm','jo','jp','ke','kg','kh','ki','km','kn','kp','kr','kw','ky','kz','la', | ||
'lb','lc','li','lk','lr','ls','lt','lu','lv','ly','ma','mc','md','me','mf', | ||
'mg','mh','mk','ml','mm','mn','mo','mp','mq','mr','ms','mt','mu','mv','mw', | ||
'mx','my','mz','na','nc','ne','nf','ng','ni','nl','no','np','nr','nu','nz', | ||
'om','pa','pe','pf','pg','ph','pk','pl','pn','pr','ps','pt','pw','py','qa', | ||
'ro','rs','ru','rw','sa','sb','sc','sd','se','sg','sh','si','sk','sl','sm', | ||
'sn','so','sr','ss','st','sv','sy','sz','tc','td','tf','tg','th','tj','tk', | ||
'tl','tm','tn','to','tr','tt','tv','tw','tz','ua','ug','us','uy','uz','va', | ||
'vc','ve','vg','vi','vn','vu','wf','ws','ye','yt','za','zm','zw', | ||
]; | ||
|
||
const dirPath = process.argv[2]; | ||
|
||
(async function main() { | ||
const errors = []; | ||
|
||
try { | ||
const filePaths = await glob(dirPath); | ||
|
||
for (const filePath of filePaths) { | ||
const fileRows = JSON.parse(fs.readFileSync(filePath, 'utf8')) | ||
const fileIsoCodes = fileRows.map((row) => row.isoCode); | ||
|
||
const emptyValues = fileRows.filter((row) => { | ||
return !row.name; | ||
}).map((row) => row.isoCode); | ||
|
||
const extraCodes = fileIsoCodes.filter((isoCode) => { | ||
return expectedIsoCodes.indexOf(isoCode) < 0; | ||
}); | ||
|
||
const missingCodes = expectedIsoCodes.filter((isoCode) => { | ||
return fileIsoCodes.indexOf(isoCode) < 0; | ||
}); | ||
|
||
if (emptyValues.length || extraCodes.length || missingCodes.length) { | ||
errors.push({ emptyValues, extraCodes, filePath, missingCodes }); | ||
} | ||
} | ||
} catch (error) { | ||
console.error('Something went wrong during the i18n keys validation', error); | ||
} | ||
|
||
if (errors.length) { | ||
console.log('Following errors have been found during i18n keys validation:') | ||
|
||
errors.forEach((error) => { | ||
console.log(`--- File ${error.filePath} ---`); | ||
|
||
(error.emptyValues || []).forEach((emptyValue) => { | ||
console.log(`Empty isoCode value to fill: ${emptyValue}`); | ||
}); | ||
|
||
(error.extraCodes || []).forEach((extraCode) => { | ||
console.log(`Extra isoCode to remove: ${extraCode}`); | ||
}); | ||
|
||
(error.missingCodes || []).forEach((missingCode) => { | ||
console.log(`Missing isoCode to add: ${missingCode}`); | ||
}); | ||
}); | ||
|
||
process.exitCode = 1; | ||
} | ||
})(); |
15 changes: 2 additions & 13 deletions
15
packages/ods/src/components/phone-number/src/constants/phone-number-locale.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,3 @@ | ||
enum ODS_PHONE_NUMBER_LOCALE { | ||
en = 'en', | ||
fr = 'fr', | ||
} | ||
import { ODS_LOCALE, ODS_LOCALES, type OdsLocale } from '../../../../utils/locale'; | ||
|
||
type OdsPhoneNumberLocale = `${ODS_PHONE_NUMBER_LOCALE}`; | ||
|
||
const ODS_PHONE_NUMBER_LOCALES = Object.freeze(Object.values(ODS_PHONE_NUMBER_LOCALE)); | ||
|
||
export { | ||
ODS_PHONE_NUMBER_LOCALE, | ||
ODS_PHONE_NUMBER_LOCALES, | ||
type OdsPhoneNumberLocale, | ||
}; | ||
export { ODS_LOCALE as ODS_PHONE_NUMBER_LOCALE, ODS_LOCALES as ODS_PHONE_NUMBER_LOCALES, type OdsLocale as OdsPhoneNumberLocale }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
240 changes: 240 additions & 0 deletions
240
packages/ods/src/components/phone-number/src/i18n/countries-de.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,240 @@ | ||
[ | ||
{"isoCode": "ad", "name": "Andorra"}, | ||
{"isoCode": "ae", "name": "Vereinigte Arabische Emirate"}, | ||
{"isoCode": "af", "name": "Afghanistan"}, | ||
{"isoCode": "ag", "name": "Antigua und Barbuda"}, | ||
{"isoCode": "ai", "name": "Anguilla"}, | ||
{"isoCode": "al", "name": "Albanien"}, | ||
{"isoCode": "am", "name": "Armenien"}, | ||
{"isoCode": "ao", "name": "Angola"}, | ||
{"isoCode": "aq", "name": "Antarktis (Sonderstatus durch Antarktisvertrag)"}, | ||
{"isoCode": "ar", "name": "Argentinien"}, | ||
{"isoCode": "as", "name": "Amerikanisch-Samoa"}, | ||
{"isoCode": "at", "name": "Österreich"}, | ||
{"isoCode": "au", "name": "Australien"}, | ||
{"isoCode": "aw", "name": "Aruba"}, | ||
{"isoCode": "ax", "name": "Åland"}, | ||
{"isoCode": "az", "name": "Aserbaidschan"}, | ||
{"isoCode": "ba", "name": "Bosnien und Herzegowina"}, | ||
{"isoCode": "bb", "name": "Barbados"}, | ||
{"isoCode": "bd", "name": "Bangladesch"}, | ||
{"isoCode": "be", "name": "Belgien"}, | ||
{"isoCode": "bf", "name": "Burkina Faso"}, | ||
{"isoCode": "bg", "name": "Bulgarien"}, | ||
{"isoCode": "bh", "name": "Bahrain"}, | ||
{"isoCode": "bi", "name": "Burundi"}, | ||
{"isoCode": "bj", "name": "Benin"}, | ||
{"isoCode": "bl", "name": "Saint-Barthélemy"}, | ||
{"isoCode": "bm", "name": "Bermuda"}, | ||
{"isoCode": "bn", "name": "Brunei"}, | ||
{"isoCode": "bo", "name": "Bolivien"}, | ||
{"isoCode": "br", "name": "Brasilien"}, | ||
{"isoCode": "bs", "name": "Bahamas"}, | ||
{"isoCode": "bt", "name": "Bhutan"}, | ||
{"isoCode": "bw", "name": "Botswana"}, | ||
{"isoCode": "by", "name": "Belarus"}, | ||
{"isoCode": "bz", "name": "Belize"}, | ||
{"isoCode": "ca", "name": "Kanada"}, | ||
{"isoCode": "cc", "name": "Kokosinseln"}, | ||
{"isoCode": "cd", "name": "Kongo, Demokratische Republik"}, | ||
{"isoCode": "cf", "name": "Zentralafrikanische Republik"}, | ||
{"isoCode": "cg", "name": "Kongo, Republik"}, | ||
{"isoCode": "ch", "name": "Schweiz"}, | ||
{"isoCode": "ci", "name": "Elfenbeinküste"}, | ||
{"isoCode": "ck", "name": "Cookinseln"}, | ||
{"isoCode": "cl", "name": "Chile"}, | ||
{"isoCode": "cm", "name": "Kamerun"}, | ||
{"isoCode": "cn", "name": "China, Volksrepublik"}, | ||
{"isoCode": "co", "name": "Kolumbien"}, | ||
{"isoCode": "cr", "name": "Costa Rica"}, | ||
{"isoCode": "cu", "name": "Kuba"}, | ||
{"isoCode": "cv", "name": "Kap Verde"}, | ||
{"isoCode": "cw", "name": "Curaçao"}, | ||
{"isoCode": "cx", "name": "Weihnachtsinsel"}, | ||
{"isoCode": "cy", "name": "Zypern"}, | ||
{"isoCode": "cz", "name": "Tschechien"}, | ||
{"isoCode": "de", "name": "Deutschland"}, | ||
{"isoCode": "dj", "name": "Dschibuti"}, | ||
{"isoCode": "dk", "name": "Dänemark"}, | ||
{"isoCode": "dm", "name": "Dominica"}, | ||
{"isoCode": "do", "name": "Dominikanische Republik"}, | ||
{"isoCode": "dz", "name": "Algerien"}, | ||
{"isoCode": "ec", "name": "Ecuador"}, | ||
{"isoCode": "ee", "name": "Estland"}, | ||
{"isoCode": "eg", "name": "Ägypten"}, | ||
{"isoCode": "eh", "name": "Westsahara"}, | ||
{"isoCode": "er", "name": "Eritrea"}, | ||
{"isoCode": "es", "name": "Spanien"}, | ||
{"isoCode": "et", "name": "Äthiopien"}, | ||
{"isoCode": "fi", "name": "Finnland"}, | ||
{"isoCode": "fj", "name": "Fidschi"}, | ||
{"isoCode": "fk", "name": "Falklandinseln"}, | ||
{"isoCode": "fm", "name": "Mikronesien"}, | ||
{"isoCode": "fo", "name": "Färöer"}, | ||
{"isoCode": "fr", "name": "Frankreich"}, | ||
{"isoCode": "ga", "name": "Gabun"}, | ||
{"isoCode": "gb", "name": "Vereinigtes Königreich"}, | ||
{"isoCode": "gd", "name": "Grenada"}, | ||
{"isoCode": "ge", "name": "Georgien"}, | ||
{"isoCode": "gg", "name": "Guernsey (Kanalinsel)"}, | ||
{"isoCode": "gh", "name": "Ghana"}, | ||
{"isoCode": "gi", "name": "Gibraltar"}, | ||
{"isoCode": "gl", "name": "Grönland"}, | ||
{"isoCode": "gm", "name": "Gambia"}, | ||
{"isoCode": "gn", "name": "Guinea"}, | ||
{"isoCode": "gq", "name": "Äquatorialguinea"}, | ||
{"isoCode": "gr", "name": "Griechenland"}, | ||
{"isoCode": "gs", "name": "Südgeorgien und die Südlichen Sandwichinseln"}, | ||
{"isoCode": "gt", "name": "Guatemala"}, | ||
{"isoCode": "gu", "name": "Guam"}, | ||
{"isoCode": "gw", "name": "Guinea-Bissau"}, | ||
{"isoCode": "gy", "name": "Guyana"}, | ||
{"isoCode": "hk", "name": "Hongkong"}, | ||
{"isoCode": "hn", "name": "Honduras"}, | ||
{"isoCode": "hr", "name": "Kroatien"}, | ||
{"isoCode": "ht", "name": "Haiti"}, | ||
{"isoCode": "hu", "name": "Ungarn"}, | ||
{"isoCode": "id", "name": "Indonesien"}, | ||
{"isoCode": "ie", "name": "Irland"}, | ||
{"isoCode": "il", "name": "Israel"}, | ||
{"isoCode": "im", "name": "Insel Man"}, | ||
{"isoCode": "in", "name": "Indien"}, | ||
{"isoCode": "iq", "name": "Irak"}, | ||
{"isoCode": "ir", "name": "Iran"}, | ||
{"isoCode": "is", "name": "Island"}, | ||
{"isoCode": "it", "name": "Italien"}, | ||
{"isoCode": "je", "name": "Jersey (Kanalinsel)"}, | ||
{"isoCode": "jm", "name": "Jamaika"}, | ||
{"isoCode": "jo", "name": "Jordanien"}, | ||
{"isoCode": "jp", "name": "Japan"}, | ||
{"isoCode": "ke", "name": "Kenia"}, | ||
{"isoCode": "kg", "name": "Kirgisistan"}, | ||
{"isoCode": "kh", "name": "Kambodscha"}, | ||
{"isoCode": "ki", "name": "Kiribati"}, | ||
{"isoCode": "km", "name": "Komoren"}, | ||
{"isoCode": "kn", "name": "St. Kitts und Nevis"}, | ||
{"isoCode": "kp", "name": "Korea, Nord (Nordkorea)"}, | ||
{"isoCode": "kr", "name": "Korea, Süd (Südkorea)"}, | ||
{"isoCode": "kw", "name": "Kuwait"}, | ||
{"isoCode": "ky", "name": "Kaimaninseln"}, | ||
{"isoCode": "kz", "name": "Kasachstan"}, | ||
{"isoCode": "la", "name": "Laos"}, | ||
{"isoCode": "lb", "name": "Libanon"}, | ||
{"isoCode": "lc", "name": "St. Lucia"}, | ||
{"isoCode": "li", "name": "Liechtenstein"}, | ||
{"isoCode": "lk", "name": "Sri Lanka"}, | ||
{"isoCode": "lr", "name": "Liberia"}, | ||
{"isoCode": "ls", "name": "Lesotho"}, | ||
{"isoCode": "lt", "name": "Litauen"}, | ||
{"isoCode": "lu", "name": "Luxemburg"}, | ||
{"isoCode": "lv", "name": "Lettland"}, | ||
{"isoCode": "ly", "name": "Libyen"}, | ||
{"isoCode": "ma", "name": "Marokko"}, | ||
{"isoCode": "mc", "name": "Monaco"}, | ||
{"isoCode": "md", "name": "Moldau"}, | ||
{"isoCode": "me", "name": "Montenegro"}, | ||
{"isoCode": "mf", "name": "Saint-Martin (französischer Teil)"}, | ||
{"isoCode": "mg", "name": "Madagaskar"}, | ||
{"isoCode": "mh", "name": "Marshallinseln"}, | ||
{"isoCode": "mk", "name": "Nordmazedonien"}, | ||
{"isoCode": "ml", "name": "Mali"}, | ||
{"isoCode": "mm", "name": "Myanmar"}, | ||
{"isoCode": "mn", "name": "Mongolei"}, | ||
{"isoCode": "mo", "name": "Macau"}, | ||
{"isoCode": "mp", "name": "Nördliche Marianen"}, | ||
{"isoCode": "mq", "name": "Martinique"}, | ||
{"isoCode": "mr", "name": "Mauretanien"}, | ||
{"isoCode": "ms", "name": "Montserrat"}, | ||
{"isoCode": "mt", "name": "Malta"}, | ||
{"isoCode": "mu", "name": "Mauritius"}, | ||
{"isoCode": "mv", "name": "Malediven"}, | ||
{"isoCode": "mw", "name": "Malawi"}, | ||
{"isoCode": "mx", "name": "Mexiko"}, | ||
{"isoCode": "my", "name": "Malaysia"}, | ||
{"isoCode": "mz", "name": "Mosambik"}, | ||
{"isoCode": "na", "name": "Namibia"}, | ||
{"isoCode": "nc", "name": "Neukaledonien"}, | ||
{"isoCode": "ne", "name": "Niger"}, | ||
{"isoCode": "nf", "name": "Norfolkinsel"}, | ||
{"isoCode": "ng", "name": "Nigeria"}, | ||
{"isoCode": "ni", "name": "Nicaragua"}, | ||
{"isoCode": "nl", "name": "Niederlande"}, | ||
{"isoCode": "no", "name": "Norwegen"}, | ||
{"isoCode": "np", "name": "Nepal"}, | ||
{"isoCode": "nr", "name": "Nauru"}, | ||
{"isoCode": "nu", "name": "Niue"}, | ||
{"isoCode": "nz", "name": "Neuseeland"}, | ||
{"isoCode": "om", "name": "Oman"}, | ||
{"isoCode": "pa", "name": "Panama"}, | ||
{"isoCode": "pe", "name": "Peru"}, | ||
{"isoCode": "pf", "name": "Französisch-Polynesien"}, | ||
{"isoCode": "pg", "name": "Papua-Neuguinea"}, | ||
{"isoCode": "ph", "name": "Philippinen"}, | ||
{"isoCode": "pk", "name": "Pakistan"}, | ||
{"isoCode": "pl", "name": "Polen"}, | ||
{"isoCode": "pn", "name": "Pitcairninseln"}, | ||
{"isoCode": "pr", "name": "Puerto Rico"}, | ||
{"isoCode": "ps", "name": "Palästina"}, | ||
{"isoCode": "pt", "name": "Portugal"}, | ||
{"isoCode": "pw", "name": "Palau"}, | ||
{"isoCode": "py", "name": "Paraguay"}, | ||
{"isoCode": "qa", "name": "Katar"}, | ||
{"isoCode": "ro", "name": "Rumänien"}, | ||
{"isoCode": "rs", "name": "Serbien"}, | ||
{"isoCode": "ru", "name": "Russland"}, | ||
{"isoCode": "rw", "name": "Ruanda"}, | ||
{"isoCode": "sa", "name": "Saudi-Arabien"}, | ||
{"isoCode": "sb", "name": "Salomonen"}, | ||
{"isoCode": "sc", "name": "Seychellen"}, | ||
{"isoCode": "sd", "name": "Sudan"}, | ||
{"isoCode": "se", "name": "Schweden"}, | ||
{"isoCode": "sg", "name": "Singapur"}, | ||
{"isoCode": "sh", "name": "St. Helena, Ascension und Tristan da Cunha"}, | ||
{"isoCode": "si", "name": "Slowenien"}, | ||
{"isoCode": "sk", "name": "Slowakei"}, | ||
{"isoCode": "sl", "name": "Sierra Leone"}, | ||
{"isoCode": "sm", "name": "San Marino"}, | ||
{"isoCode": "sn", "name": "Senegal"}, | ||
{"isoCode": "so", "name": "Somalia"}, | ||
{"isoCode": "sr", "name": "Suriname"}, | ||
{"isoCode": "ss", "name": "Südsudan"}, | ||
{"isoCode": "st", "name": "São Tomé und Príncipe"}, | ||
{"isoCode": "sv", "name": "El Salvador"}, | ||
{"isoCode": "sy", "name": "Syrien"}, | ||
{"isoCode": "sz", "name": "Eswatini"}, | ||
{"isoCode": "tc", "name": "Turks- und Caicosinseln"}, | ||
{"isoCode": "td", "name": "Tschad"}, | ||
{"isoCode": "tf", "name": "Französische Süd- und Antarktisgebiete"}, | ||
{"isoCode": "tg", "name": "Togo"}, | ||
{"isoCode": "th", "name": "Thailand"}, | ||
{"isoCode": "tj", "name": "Tadschikistan"}, | ||
{"isoCode": "tk", "name": "Tokelau"}, | ||
{"isoCode": "tl", "name": "Osttimor"}, | ||
{"isoCode": "tm", "name": "Turkmenistan"}, | ||
{"isoCode": "tn", "name": "Tunesien"}, | ||
{"isoCode": "to", "name": "Tonga"}, | ||
{"isoCode": "tr", "name": "Türkei"}, | ||
{"isoCode": "tt", "name": "Trinidad und Tobago"}, | ||
{"isoCode": "tv", "name": "Tuvalu"}, | ||
{"isoCode": "tw", "name": "China, Republik"}, | ||
{"isoCode": "tz", "name": "Tansania"}, | ||
{"isoCode": "ua", "name": "Ukraine"}, | ||
{"isoCode": "ug", "name": "Uganda"}, | ||
{"isoCode": "us", "name": "Vereinigte Staaten"}, | ||
{"isoCode": "uy", "name": "Uruguay"}, | ||
{"isoCode": "uz", "name": "Usbekistan"}, | ||
{"isoCode": "va", "name": "Vatikanstadt"}, | ||
{"isoCode": "vc", "name": "St. Vincent und die Grenadinen"}, | ||
{"isoCode": "ve", "name": "Venezuela"}, | ||
{"isoCode": "vg", "name": "Britische Jungferninseln"}, | ||
{"isoCode": "vi", "name": "Amerikanische Jungferninseln"}, | ||
{"isoCode": "vn", "name": "Vietnam"}, | ||
{"isoCode": "vu", "name": "Vanuatu"}, | ||
{"isoCode": "wf", "name": "Wallis und Futuna"}, | ||
{"isoCode": "ws", "name": "Samoa"}, | ||
{"isoCode": "ye", "name": "Jemen"}, | ||
{"isoCode": "yt", "name": "Mayotte"}, | ||
{"isoCode": "za", "name": "Südafrika"}, | ||
{"isoCode": "zm", "name": "Sambia"}, | ||
{"isoCode": "zw", "name": "Simbabwe"} | ||
] |
Oops, something went wrong.