Update country display names
This commit is contained in:
parent
9b98e20a8c
commit
46b620228e
3 changed files with 1163 additions and 1159 deletions
|
@ -6,23 +6,6 @@ import fs from 'fs/promises';
|
|||
import { z } from 'zod';
|
||||
import { _getAvailableLocales } from '../../app/locale';
|
||||
|
||||
const availableLocales = _getAvailableLocales();
|
||||
|
||||
const LocaleString = z.string().refine(arg => {
|
||||
try {
|
||||
return new Intl.Locale(arg) && true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
const LocaleDisplayNames = z
|
||||
.tuple([z.tuple([z.literal('locale')]).rest(LocaleString)])
|
||||
.rest(z.tuple([LocaleString]).rest(z.string()));
|
||||
|
||||
type Row = ReadonlyArray<string>;
|
||||
type Records = ReadonlyArray<Row>;
|
||||
|
||||
const type = process.argv[2];
|
||||
if (type !== 'countries' && type !== 'locales') {
|
||||
throw new Error('Invalid first argument, expceted "countries" or "locales"');
|
||||
|
@ -37,6 +20,27 @@ if (!localeDisplayNamesBuildPath) {
|
|||
throw new Error('Missing third argument: output json file');
|
||||
}
|
||||
|
||||
const availableLocales = _getAvailableLocales();
|
||||
|
||||
const LocaleString = z.string().refine(arg => {
|
||||
try {
|
||||
return new Intl.Locale(arg) && true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
const LocaleDisplayNames = z
|
||||
.tuple([
|
||||
z
|
||||
.tuple([z.literal(type === 'locales' ? 'locale' : 'Country Code')])
|
||||
.rest(LocaleString),
|
||||
])
|
||||
.rest(z.tuple([LocaleString]).rest(z.string()));
|
||||
|
||||
type Row = ReadonlyArray<string>;
|
||||
type Records = ReadonlyArray<Row>;
|
||||
|
||||
function parseCsv(input: string) {
|
||||
return new Promise<Records>((resolve, reject) => {
|
||||
parse(input, { trim: true }, (error, records: Records) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue