From f2cdf137baba52df8ba0991c4fda96ec3e1f033c Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Fri, 21 Jan 2022 21:07:14 +0100 Subject: [PATCH 01/10] feat: auto generate locale files --- package.json | 1 + pnpm-lock.yaml | 6 +++++ scripts/generateLocales.ts | 53 ++++++++++++++++++++++++++++++++++++++ src/locale/af_ZA.ts | 2 +- src/locale/ar.ts | 2 +- src/locale/az.ts | 2 +- src/locale/cz.ts | 2 +- src/locale/de.ts | 2 +- src/locale/de_AT.ts | 2 +- src/locale/de_CH.ts | 2 +- src/locale/el.ts | 2 +- src/locale/en.ts | 2 +- src/locale/en_AU.ts | 2 +- src/locale/en_AU_ocker.ts | 2 +- src/locale/en_BORK.ts | 2 +- src/locale/en_CA.ts | 2 +- src/locale/en_GB.ts | 2 +- src/locale/en_GH.ts | 2 +- src/locale/en_IE.ts | 2 +- src/locale/en_IND.ts | 2 +- src/locale/en_NG.ts | 2 +- src/locale/en_US.ts | 2 +- src/locale/en_ZA.ts | 2 +- src/locale/es.ts | 2 +- src/locale/es_MX.ts | 2 +- src/locale/fa.ts | 2 +- src/locale/fi.ts | 2 +- src/locale/fr.ts | 2 +- src/locale/fr_BE.ts | 6 ++--- src/locale/fr_CA.ts | 2 +- src/locale/fr_CH.ts | 2 +- src/locale/ge.ts | 2 +- src/locale/he.ts | 2 +- src/locale/hr.ts | 2 +- src/locale/hy.ts | 2 +- src/locale/id_ID.ts | 2 +- src/locale/it.ts | 2 +- src/locale/ja.ts | 2 +- src/locale/ko.ts | 2 +- src/locale/lv.ts | 6 ++--- src/locale/mk.ts | 2 +- src/locale/nb_NO.ts | 2 +- src/locale/ne.ts | 2 +- src/locale/nl.ts | 2 +- src/locale/nl_BE.ts | 2 +- src/locale/pl.ts | 2 +- src/locale/pt_BR.ts | 2 +- src/locale/pt_PT.ts | 2 +- src/locale/ro.ts | 2 +- src/locale/ru.ts | 2 +- src/locale/sk.ts | 2 +- src/locale/sv.ts | 2 +- src/locale/tr.ts | 2 +- src/locale/uk.ts | 2 +- src/locale/ur.ts | 2 +- src/locale/vi.ts | 2 +- src/locale/zh_CN.ts | 2 +- src/locale/zh_TW.ts | 2 +- src/locale/zu_ZA.ts | 2 +- 59 files changed, 120 insertions(+), 60 deletions(-) create mode 100644 scripts/generateLocales.ts diff --git a/package.json b/package.json index 3146b70473d..78126779176 100644 --- a/package.json +++ b/package.json @@ -89,6 +89,7 @@ "@types/node": "~16.11.21", "@typescript-eslint/eslint-plugin": "~5.10.1", "@typescript-eslint/parser": "~5.10.1", + "@types/prettier": "~2.4.3", "@types/validator": "~13.7.1", "@vitest/ui": "~0.2.5", "c8": "~7.11.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 70ac0bfa318..caad896defe 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2,6 +2,7 @@ lockfileVersion: 5.3 specifiers: '@types/node': ~16.11.21 + '@types/prettier': ~2.4.3 '@types/validator': ~13.7.1 '@typescript-eslint/eslint-plugin': ~5.10.1 '@typescript-eslint/parser': ~5.10.1 @@ -32,6 +33,7 @@ specifiers: devDependencies: '@types/node': 16.11.21 + '@types/prettier': 2.4.3 '@types/validator': 13.7.1 '@typescript-eslint/eslint-plugin': 5.10.1_5bb2413551d07429e4087fb9ca3ae3ea '@typescript-eslint/parser': 5.10.1_eslint@8.8.0+typescript@4.5.5 @@ -366,6 +368,10 @@ packages: resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} dev: true + /@types/prettier/2.4.3: + resolution: {integrity: sha512-QzSuZMBuG5u8HqYz01qtMdg/Jfctlnvj1z/lYnIDXs/golxw0fxtRAHd9KrzjR7Yxz1qVeI00o0kiO3PmVdJ9w==} + dev: true + /@types/sinonjs__fake-timers/8.1.1: resolution: {integrity: sha512-0kSuKjAS0TrGLJ0M/+8MaFkGsQhZpB6pxOmvS3K8FYI72K//YmdfoW9X2qPsAKh1mkwxGD5zib9s1FIFed6E8g==} dev: true diff --git a/scripts/generateLocales.ts b/scripts/generateLocales.ts new file mode 100644 index 00000000000..90f9adfa42f --- /dev/null +++ b/scripts/generateLocales.ts @@ -0,0 +1,53 @@ +import fs from 'fs'; +import { format } from 'prettier'; +import options from '../.prettierrc.cjs'; + +const pathLocale = 'src/locale/'; +const pathLocales = 'src/locales/'; + +const locales = fs.readdirSync(pathLocales); +locales.splice(locales.indexOf('index.ts'), 1); + +let localeIndexImports = "import type { LocaleDefinition } from '..';\n"; +let localeIndexType = 'export type KnownLocale =\n'; +let localeIndexLocales = 'const locales: KnownLocales = {\n'; + +for (let locale of locales) { + localeIndexImports += `import ${locale} from './${locale}';`; + localeIndexType += ` | '${locale}'`; + localeIndexLocales += ` ${locale},`; + + if (locale !== 'en') { + let content: string = `import { Faker } from '..'; + import ${locale} from '../locales/${locale}'; + import en from '../locales/en'; + + const faker = new Faker({ + locale: '${locale}', + localeFallback: 'en', + locales: { + ${locale}, + en, + }, + }); + + export default faker;`; + content = format(content, { ...options, parser: 'typescript' }); + fs.writeFileSync(pathLocale + locale + '.ts', content); + } +} + +let indexContent = `${localeIndexImports} + +${localeIndexType}; + +export type KnownLocales = Record; + +${localeIndexLocales}}; + +export default locales; +`; + +indexContent = format(indexContent, { ...options, parser: 'typescript' }); + +fs.writeFileSync(pathLocales + 'index.ts', indexContent); diff --git a/src/locale/af_ZA.ts b/src/locale/af_ZA.ts index 0cda3c6e95f..041f6d3b9d2 100644 --- a/src/locale/af_ZA.ts +++ b/src/locale/af_ZA.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/ar.ts b/src/locale/ar.ts index 9407ec15fe4..417189c12ec 100644 --- a/src/locale/ar.ts +++ b/src/locale/ar.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/az.ts b/src/locale/az.ts index e0f0d1253ec..d3494a167e4 100644 --- a/src/locale/az.ts +++ b/src/locale/az.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/cz.ts b/src/locale/cz.ts index ddef6ee56a4..1157ea71077 100644 --- a/src/locale/cz.ts +++ b/src/locale/cz.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/de.ts b/src/locale/de.ts index 414313a7604..5f2e222a387 100644 --- a/src/locale/de.ts +++ b/src/locale/de.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/de_AT.ts b/src/locale/de_AT.ts index 4c2d4bd6266..b864f6af189 100644 --- a/src/locale/de_AT.ts +++ b/src/locale/de_AT.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/de_CH.ts b/src/locale/de_CH.ts index 44fc440b5b4..d82614d401e 100644 --- a/src/locale/de_CH.ts +++ b/src/locale/de_CH.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/el.ts b/src/locale/el.ts index c1a33a5ccb6..a954bba1bef 100644 --- a/src/locale/el.ts +++ b/src/locale/el.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/en.ts b/src/locale/en.ts index 88445510dc9..333a143752a 100644 --- a/src/locale/en.ts +++ b/src/locale/en.ts @@ -9,4 +9,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/en_AU.ts b/src/locale/en_AU.ts index 613560aafc3..e67ec3a545d 100644 --- a/src/locale/en_AU.ts +++ b/src/locale/en_AU.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/en_AU_ocker.ts b/src/locale/en_AU_ocker.ts index 41620392a0c..85014b1f7c9 100644 --- a/src/locale/en_AU_ocker.ts +++ b/src/locale/en_AU_ocker.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/en_BORK.ts b/src/locale/en_BORK.ts index f58b2df94db..51754502778 100644 --- a/src/locale/en_BORK.ts +++ b/src/locale/en_BORK.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/en_CA.ts b/src/locale/en_CA.ts index 089f003c352..aa0902a5851 100644 --- a/src/locale/en_CA.ts +++ b/src/locale/en_CA.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/en_GB.ts b/src/locale/en_GB.ts index c1fe3a40aba..d39b3026ad2 100644 --- a/src/locale/en_GB.ts +++ b/src/locale/en_GB.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/en_GH.ts b/src/locale/en_GH.ts index ab9f22864c3..bdf78539275 100644 --- a/src/locale/en_GH.ts +++ b/src/locale/en_GH.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/en_IE.ts b/src/locale/en_IE.ts index 8ed57e76d0e..b3b3c12d158 100644 --- a/src/locale/en_IE.ts +++ b/src/locale/en_IE.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/en_IND.ts b/src/locale/en_IND.ts index c2d580835b6..d2642a60c0b 100644 --- a/src/locale/en_IND.ts +++ b/src/locale/en_IND.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/en_NG.ts b/src/locale/en_NG.ts index b5315df7e2f..2b8451de0a8 100644 --- a/src/locale/en_NG.ts +++ b/src/locale/en_NG.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/en_US.ts b/src/locale/en_US.ts index 73f5e50b743..1f2ac2fcc56 100644 --- a/src/locale/en_US.ts +++ b/src/locale/en_US.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/en_ZA.ts b/src/locale/en_ZA.ts index 0c7f4c668ea..598e78e54ce 100644 --- a/src/locale/en_ZA.ts +++ b/src/locale/en_ZA.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/es.ts b/src/locale/es.ts index b812dc25435..a6ffc624b7a 100644 --- a/src/locale/es.ts +++ b/src/locale/es.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/es_MX.ts b/src/locale/es_MX.ts index 6b6972c6beb..f7e31228703 100644 --- a/src/locale/es_MX.ts +++ b/src/locale/es_MX.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/fa.ts b/src/locale/fa.ts index 3611e3a1e48..c0572f37829 100644 --- a/src/locale/fa.ts +++ b/src/locale/fa.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/fi.ts b/src/locale/fi.ts index 18e754d371e..140a708a8fb 100644 --- a/src/locale/fi.ts +++ b/src/locale/fi.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/fr.ts b/src/locale/fr.ts index e7d2e69dc5c..8d75d785188 100644 --- a/src/locale/fr.ts +++ b/src/locale/fr.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/fr_BE.ts b/src/locale/fr_BE.ts index 9b41d9ed5f6..2f4b7946f8c 100644 --- a/src/locale/fr_BE.ts +++ b/src/locale/fr_BE.ts @@ -1,14 +1,14 @@ import { Faker } from '..'; -import en from '../locales/en'; import fr_BE from '../locales/fr_BE'; +import en from '../locales/en'; const faker = new Faker({ locale: 'fr_BE', localeFallback: 'en', locales: { - en, fr_BE, + en, }, }); -export = faker; +export default faker; diff --git a/src/locale/fr_CA.ts b/src/locale/fr_CA.ts index 8fd3ad97736..e9c8fb83359 100644 --- a/src/locale/fr_CA.ts +++ b/src/locale/fr_CA.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/fr_CH.ts b/src/locale/fr_CH.ts index a6e293075e1..22fc5592239 100644 --- a/src/locale/fr_CH.ts +++ b/src/locale/fr_CH.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/ge.ts b/src/locale/ge.ts index 1e859809fb8..8830377fd62 100644 --- a/src/locale/ge.ts +++ b/src/locale/ge.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/he.ts b/src/locale/he.ts index d1905656721..32e7e1fef1a 100644 --- a/src/locale/he.ts +++ b/src/locale/he.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/hr.ts b/src/locale/hr.ts index a95d50526cd..c15831ea072 100644 --- a/src/locale/hr.ts +++ b/src/locale/hr.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/hy.ts b/src/locale/hy.ts index fc1f710aa27..fea88758ea7 100644 --- a/src/locale/hy.ts +++ b/src/locale/hy.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/id_ID.ts b/src/locale/id_ID.ts index c435d8d78f0..57a4dacef20 100644 --- a/src/locale/id_ID.ts +++ b/src/locale/id_ID.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/it.ts b/src/locale/it.ts index 8cd45d62363..14ac5bccf98 100644 --- a/src/locale/it.ts +++ b/src/locale/it.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/ja.ts b/src/locale/ja.ts index cb20528fe4c..6191dd2a75d 100644 --- a/src/locale/ja.ts +++ b/src/locale/ja.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/ko.ts b/src/locale/ko.ts index 1a55af6827b..bb6f82993b1 100644 --- a/src/locale/ko.ts +++ b/src/locale/ko.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/lv.ts b/src/locale/lv.ts index 082e9cd529c..3e9585e8d2e 100644 --- a/src/locale/lv.ts +++ b/src/locale/lv.ts @@ -1,14 +1,14 @@ import { Faker } from '..'; -import en from '../locales/en'; import lv from '../locales/lv'; +import en from '../locales/en'; const faker = new Faker({ locale: 'lv', localeFallback: 'en', locales: { - en, lv, + en, }, }); -export = faker; +export default faker; diff --git a/src/locale/mk.ts b/src/locale/mk.ts index c416ac4c379..6545a8de3ba 100644 --- a/src/locale/mk.ts +++ b/src/locale/mk.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/nb_NO.ts b/src/locale/nb_NO.ts index 51e66c8c40e..08c4d8fc381 100644 --- a/src/locale/nb_NO.ts +++ b/src/locale/nb_NO.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/ne.ts b/src/locale/ne.ts index 1b64771bc9d..7dd878a2724 100644 --- a/src/locale/ne.ts +++ b/src/locale/ne.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/nl.ts b/src/locale/nl.ts index 18b32cfe41d..062d36d445e 100644 --- a/src/locale/nl.ts +++ b/src/locale/nl.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/nl_BE.ts b/src/locale/nl_BE.ts index de1dde66054..4d159ddc8aa 100644 --- a/src/locale/nl_BE.ts +++ b/src/locale/nl_BE.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/pl.ts b/src/locale/pl.ts index af88fef8393..7627be92299 100644 --- a/src/locale/pl.ts +++ b/src/locale/pl.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/pt_BR.ts b/src/locale/pt_BR.ts index 1d82ef4aa38..043e05879a0 100644 --- a/src/locale/pt_BR.ts +++ b/src/locale/pt_BR.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/pt_PT.ts b/src/locale/pt_PT.ts index 35daac9ef03..8512fa404d3 100644 --- a/src/locale/pt_PT.ts +++ b/src/locale/pt_PT.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/ro.ts b/src/locale/ro.ts index 50a31f96008..e4b4c76c039 100644 --- a/src/locale/ro.ts +++ b/src/locale/ro.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/ru.ts b/src/locale/ru.ts index 76afbc645a4..344935b0ea4 100644 --- a/src/locale/ru.ts +++ b/src/locale/ru.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/sk.ts b/src/locale/sk.ts index ce9baca2fa2..e4f55552376 100644 --- a/src/locale/sk.ts +++ b/src/locale/sk.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/sv.ts b/src/locale/sv.ts index 3ece5709bf5..3a41b158223 100644 --- a/src/locale/sv.ts +++ b/src/locale/sv.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/tr.ts b/src/locale/tr.ts index d915f4ac8b6..0d628cbc785 100644 --- a/src/locale/tr.ts +++ b/src/locale/tr.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/uk.ts b/src/locale/uk.ts index 465a3887705..ec8ec631d5d 100644 --- a/src/locale/uk.ts +++ b/src/locale/uk.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/ur.ts b/src/locale/ur.ts index 7ccb498deae..a25a3662a40 100644 --- a/src/locale/ur.ts +++ b/src/locale/ur.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/vi.ts b/src/locale/vi.ts index 21ea52cbfea..8c2f45a4f27 100644 --- a/src/locale/vi.ts +++ b/src/locale/vi.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/zh_CN.ts b/src/locale/zh_CN.ts index 45f64495406..f47d6bcb2e1 100644 --- a/src/locale/zh_CN.ts +++ b/src/locale/zh_CN.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/zh_TW.ts b/src/locale/zh_TW.ts index 51c3cc1daf7..569b8e1c343 100644 --- a/src/locale/zh_TW.ts +++ b/src/locale/zh_TW.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; diff --git a/src/locale/zu_ZA.ts b/src/locale/zu_ZA.ts index bf3b018a967..e63efbf7c60 100644 --- a/src/locale/zu_ZA.ts +++ b/src/locale/zu_ZA.ts @@ -11,4 +11,4 @@ const faker = new Faker({ }, }); -export = faker; +export default faker; From a1b9dffb1a3740e71ff3ee81486fdabb067e24a6 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Fri, 21 Jan 2022 21:54:36 +0100 Subject: [PATCH 02/10] feat: auto generate locales in docs --- docs/api/localization.md | 4 ++++ scripts/generateLocales.ts | 42 ++++++++++++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/docs/api/localization.md b/docs/api/localization.md index 6152d32f876..2478383e4ce 100644 --- a/docs/api/localization.md +++ b/docs/api/localization.md @@ -13,6 +13,8 @@ faker.setLocale('de'); faker.locale = 'de'; ``` + + | Locale | Name | | :---------- | :------------------------ | | af_ZA | Afrikaans | @@ -72,6 +74,8 @@ faker.locale = 'de'; | zh_TW | Chinese (Taiwan) | | zu_ZA | Zulu (South Africa) | + + ## Individual Localization Packages As of version `v3.0.0` Faker supports incremental loading of locales. diff --git a/scripts/generateLocales.ts b/scripts/generateLocales.ts index 90f9adfa42f..db9398299d8 100644 --- a/scripts/generateLocales.ts +++ b/scripts/generateLocales.ts @@ -1,22 +1,35 @@ -import fs from 'fs'; +import { readdirSync, readFileSync, writeFileSync } from 'node:fs'; +import { resolve } from 'node:path'; import { format } from 'prettier'; import options from '../.prettierrc.cjs'; -const pathLocale = 'src/locale/'; -const pathLocales = 'src/locales/'; +const pathRoot = resolve(__dirname, '..'); +const pathLocale = resolve(pathRoot, 'src', 'locale'); +const pathLocales = resolve(pathRoot, 'src', 'locales'); +const pathLocalesIndex = resolve(pathLocales, 'index.ts'); +const pathDocsApiLocalization = resolve( + pathRoot, + 'docs', + 'api', + 'localization.md' +); -const locales = fs.readdirSync(pathLocales); +const locales = readdirSync(pathLocales); locales.splice(locales.indexOf('index.ts'), 1); let localeIndexImports = "import type { LocaleDefinition } from '..';\n"; let localeIndexType = 'export type KnownLocale =\n'; let localeIndexLocales = 'const locales: KnownLocales = {\n'; +let localizationLocales = ''; + for (let locale of locales) { - localeIndexImports += `import ${locale} from './${locale}';`; - localeIndexType += ` | '${locale}'`; - localeIndexLocales += ` ${locale},`; + localeIndexImports += `import ${locale} from './${locale}';\n`; + localeIndexType += ` | '${locale}'\n`; + localeIndexLocales += ` ${locale},\n`; + localizationLocales += `- ${locale}\n`; + // src/locale/.ts if (locale !== 'en') { let content: string = `import { Faker } from '..'; import ${locale} from '../locales/${locale}'; @@ -33,10 +46,12 @@ for (let locale of locales) { export default faker;`; content = format(content, { ...options, parser: 'typescript' }); - fs.writeFileSync(pathLocale + locale + '.ts', content); + writeFileSync(resolve(pathLocale, locale + '.ts'), content); } } +// src/locales/index.ts + let indexContent = `${localeIndexImports} ${localeIndexType}; @@ -50,4 +65,13 @@ export default locales; indexContent = format(indexContent, { ...options, parser: 'typescript' }); -fs.writeFileSync(pathLocales + 'index.ts', indexContent); +writeFileSync(pathLocalesIndex, indexContent); + +// docs/api/localization.md + +let localizationContent = readFileSync(pathDocsApiLocalization, 'utf-8'); +localizationContent = localizationContent.replace( + /(^$).*(^$)/gms, + `$1\n\n${localizationLocales}\n$2` +); +writeFileSync(pathDocsApiLocalization, localizationContent); From 7142012e91e3594fc454c792315225bdae47b611 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Fri, 21 Jan 2022 22:48:11 +0100 Subject: [PATCH 03/10] chore(docs): use locale table instead of list --- scripts/generateLocales.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/generateLocales.ts b/scripts/generateLocales.ts index db9398299d8..55cb6e849ef 100644 --- a/scripts/generateLocales.ts +++ b/scripts/generateLocales.ts @@ -2,6 +2,7 @@ import { readdirSync, readFileSync, writeFileSync } from 'node:fs'; import { resolve } from 'node:path'; import { format } from 'prettier'; import options from '../.prettierrc.cjs'; +import type { LocaleDefinition } from '../src'; const pathRoot = resolve(__dirname, '..'); const pathLocale = resolve(pathRoot, 'src', 'locale'); @@ -21,13 +22,17 @@ let localeIndexImports = "import type { LocaleDefinition } from '..';\n"; let localeIndexType = 'export type KnownLocale =\n'; let localeIndexLocales = 'const locales: KnownLocales = {\n'; -let localizationLocales = ''; +let localizationLocales = '| Locale | Name |\n| :--- | :--- |\n'; for (let locale of locales) { + const localeDef: LocaleDefinition = require('../src/locales/' + + locale).default; + const localeTitle = localeDef.title; + localeIndexImports += `import ${locale} from './${locale}';\n`; localeIndexType += ` | '${locale}'\n`; localeIndexLocales += ` ${locale},\n`; - localizationLocales += `- ${locale}\n`; + localizationLocales += `| ${locale} | ${localeTitle} |\n`; // src/locale/.ts if (locale !== 'en') { @@ -69,6 +74,11 @@ writeFileSync(pathLocalesIndex, indexContent); // docs/api/localization.md +localizationLocales = format(localizationLocales, { + ...options, + parser: 'markdown', +}); + let localizationContent = readFileSync(pathDocsApiLocalization, 'utf-8'); localizationContent = localizationContent.replace( /(^$).*(^$)/gms, From e18a4a61d2c0a04f434078a9fef6a1db8aa1d9cc Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Sun, 23 Jan 2022 13:59:28 +0100 Subject: [PATCH 04/10] feat: add autogenerated header --- docs/api/localization.md | 2 ++ scripts/generateLocales.ts | 53 +++++++++++++++++++++++--------------- src/locale/af_ZA.ts | 5 ++++ src/locale/ar.ts | 5 ++++ src/locale/az.ts | 5 ++++ src/locale/cz.ts | 5 ++++ src/locale/de.ts | 5 ++++ src/locale/de_AT.ts | 5 ++++ src/locale/de_CH.ts | 5 ++++ src/locale/el.ts | 5 ++++ src/locale/en_AU.ts | 5 ++++ src/locale/en_AU_ocker.ts | 5 ++++ src/locale/en_BORK.ts | 5 ++++ src/locale/en_CA.ts | 5 ++++ src/locale/en_GB.ts | 5 ++++ src/locale/en_GH.ts | 5 ++++ src/locale/en_IE.ts | 5 ++++ src/locale/en_IND.ts | 5 ++++ src/locale/en_NG.ts | 5 ++++ src/locale/en_US.ts | 5 ++++ src/locale/en_ZA.ts | 5 ++++ src/locale/es.ts | 5 ++++ src/locale/es_MX.ts | 5 ++++ src/locale/fa.ts | 5 ++++ src/locale/fi.ts | 5 ++++ src/locale/fr.ts | 5 ++++ src/locale/fr_BE.ts | 5 ++++ src/locale/fr_CA.ts | 5 ++++ src/locale/fr_CH.ts | 5 ++++ src/locale/ge.ts | 5 ++++ src/locale/he.ts | 5 ++++ src/locale/hr.ts | 5 ++++ src/locale/hy.ts | 5 ++++ src/locale/id_ID.ts | 5 ++++ src/locale/it.ts | 5 ++++ src/locale/ja.ts | 5 ++++ src/locale/ko.ts | 5 ++++ src/locale/lv.ts | 5 ++++ src/locale/mk.ts | 5 ++++ src/locale/nb_NO.ts | 5 ++++ src/locale/ne.ts | 5 ++++ src/locale/nl.ts | 5 ++++ src/locale/nl_BE.ts | 5 ++++ src/locale/pl.ts | 5 ++++ src/locale/pt_BR.ts | 5 ++++ src/locale/pt_PT.ts | 5 ++++ src/locale/ro.ts | 5 ++++ src/locale/ru.ts | 5 ++++ src/locale/sk.ts | 5 ++++ src/locale/sv.ts | 5 ++++ src/locale/tr.ts | 5 ++++ src/locale/uk.ts | 5 ++++ src/locale/ur.ts | 5 ++++ src/locale/vi.ts | 5 ++++ src/locale/zh_CN.ts | 5 ++++ src/locale/zh_TW.ts | 5 ++++ src/locale/zu_ZA.ts | 5 ++++ src/locales/index.ts | 5 ++++ 58 files changed, 314 insertions(+), 21 deletions(-) diff --git a/docs/api/localization.md b/docs/api/localization.md index 2478383e4ce..48a31c08961 100644 --- a/docs/api/localization.md +++ b/docs/api/localization.md @@ -15,6 +15,8 @@ faker.locale = 'de'; + + | Locale | Name | | :---------- | :------------------------ | | af_ZA | Afrikaans | diff --git a/scripts/generateLocales.ts b/scripts/generateLocales.ts index 55cb6e849ef..2fb96e38387 100644 --- a/scripts/generateLocales.ts +++ b/scripts/generateLocales.ts @@ -24,6 +24,11 @@ let localeIndexLocales = 'const locales: KnownLocales = {\n'; let localizationLocales = '| Locale | Name |\n| :--- | :--- |\n'; +const autoGeneratedCommentHeader = `/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */`; + for (let locale of locales) { const localeDef: LocaleDefinition = require('../src/locales/' + locale).default; @@ -36,20 +41,23 @@ for (let locale of locales) { // src/locale/.ts if (locale !== 'en') { - let content: string = `import { Faker } from '..'; - import ${locale} from '../locales/${locale}'; - import en from '../locales/en'; - - const faker = new Faker({ - locale: '${locale}', - localeFallback: 'en', - locales: { - ${locale}, - en, - }, - }); - - export default faker;`; + let content: string = ` + ${autoGeneratedCommentHeader} + + import { Faker } from '..'; + import ${locale} from '../locales/${locale}'; + import en from '../locales/en'; + + const faker = new Faker({ + locale: '${locale}', + localeFallback: 'en', + locales: { + ${locale}, + en, + }, + }); + + export default faker;`; content = format(content, { ...options, parser: 'typescript' }); writeFileSync(resolve(pathLocale, locale + '.ts'), content); } @@ -57,16 +65,19 @@ for (let locale of locales) { // src/locales/index.ts -let indexContent = `${localeIndexImports} +let indexContent = ` + ${autoGeneratedCommentHeader} + + ${localeIndexImports} -${localeIndexType}; + ${localeIndexType}; -export type KnownLocales = Record; + export type KnownLocales = Record; -${localeIndexLocales}}; + ${localeIndexLocales}}; -export default locales; -`; + export default locales; + `; indexContent = format(indexContent, { ...options, parser: 'typescript' }); @@ -82,6 +93,6 @@ localizationLocales = format(localizationLocales, { let localizationContent = readFileSync(pathDocsApiLocalization, 'utf-8'); localizationContent = localizationContent.replace( /(^$).*(^$)/gms, - `$1\n\n${localizationLocales}\n$2` + `$1\n\n\n\n${localizationLocales}\n$2` ); writeFileSync(pathDocsApiLocalization, localizationContent); diff --git a/src/locale/af_ZA.ts b/src/locale/af_ZA.ts index 041f6d3b9d2..d7a1c7f6f18 100644 --- a/src/locale/af_ZA.ts +++ b/src/locale/af_ZA.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import af_ZA from '../locales/af_ZA'; import en from '../locales/en'; diff --git a/src/locale/ar.ts b/src/locale/ar.ts index 417189c12ec..cba058f3575 100644 --- a/src/locale/ar.ts +++ b/src/locale/ar.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import ar from '../locales/ar'; import en from '../locales/en'; diff --git a/src/locale/az.ts b/src/locale/az.ts index d3494a167e4..eb50cec1bab 100644 --- a/src/locale/az.ts +++ b/src/locale/az.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import az from '../locales/az'; import en from '../locales/en'; diff --git a/src/locale/cz.ts b/src/locale/cz.ts index 1157ea71077..60d805e71d6 100644 --- a/src/locale/cz.ts +++ b/src/locale/cz.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import cz from '../locales/cz'; import en from '../locales/en'; diff --git a/src/locale/de.ts b/src/locale/de.ts index 5f2e222a387..ace52e2e180 100644 --- a/src/locale/de.ts +++ b/src/locale/de.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import de from '../locales/de'; import en from '../locales/en'; diff --git a/src/locale/de_AT.ts b/src/locale/de_AT.ts index b864f6af189..cf20f2706ca 100644 --- a/src/locale/de_AT.ts +++ b/src/locale/de_AT.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import de_AT from '../locales/de_AT'; import en from '../locales/en'; diff --git a/src/locale/de_CH.ts b/src/locale/de_CH.ts index d82614d401e..1d341c3a38b 100644 --- a/src/locale/de_CH.ts +++ b/src/locale/de_CH.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import de_CH from '../locales/de_CH'; import en from '../locales/en'; diff --git a/src/locale/el.ts b/src/locale/el.ts index a954bba1bef..bcefb788504 100644 --- a/src/locale/el.ts +++ b/src/locale/el.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import el from '../locales/el'; import en from '../locales/en'; diff --git a/src/locale/en_AU.ts b/src/locale/en_AU.ts index e67ec3a545d..8ccf4dc2c15 100644 --- a/src/locale/en_AU.ts +++ b/src/locale/en_AU.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import en_AU from '../locales/en_AU'; import en from '../locales/en'; diff --git a/src/locale/en_AU_ocker.ts b/src/locale/en_AU_ocker.ts index 85014b1f7c9..e09df344d28 100644 --- a/src/locale/en_AU_ocker.ts +++ b/src/locale/en_AU_ocker.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import en_AU_ocker from '../locales/en_AU_ocker'; import en from '../locales/en'; diff --git a/src/locale/en_BORK.ts b/src/locale/en_BORK.ts index 51754502778..99215fc9da5 100644 --- a/src/locale/en_BORK.ts +++ b/src/locale/en_BORK.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import en_BORK from '../locales/en_BORK'; import en from '../locales/en'; diff --git a/src/locale/en_CA.ts b/src/locale/en_CA.ts index aa0902a5851..a9a948c50b1 100644 --- a/src/locale/en_CA.ts +++ b/src/locale/en_CA.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import en_CA from '../locales/en_CA'; import en from '../locales/en'; diff --git a/src/locale/en_GB.ts b/src/locale/en_GB.ts index d39b3026ad2..d8460578cf7 100644 --- a/src/locale/en_GB.ts +++ b/src/locale/en_GB.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import en_GB from '../locales/en_GB'; import en from '../locales/en'; diff --git a/src/locale/en_GH.ts b/src/locale/en_GH.ts index bdf78539275..e4d9816ea2e 100644 --- a/src/locale/en_GH.ts +++ b/src/locale/en_GH.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import en_GH from '../locales/en_GH'; import en from '../locales/en'; diff --git a/src/locale/en_IE.ts b/src/locale/en_IE.ts index b3b3c12d158..7a0aca53020 100644 --- a/src/locale/en_IE.ts +++ b/src/locale/en_IE.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import en_IE from '../locales/en_IE'; import en from '../locales/en'; diff --git a/src/locale/en_IND.ts b/src/locale/en_IND.ts index d2642a60c0b..16a1b2a6de2 100644 --- a/src/locale/en_IND.ts +++ b/src/locale/en_IND.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import en_IND from '../locales/en_IND'; import en from '../locales/en'; diff --git a/src/locale/en_NG.ts b/src/locale/en_NG.ts index 2b8451de0a8..81f593313de 100644 --- a/src/locale/en_NG.ts +++ b/src/locale/en_NG.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import en_NG from '../locales/en_NG'; import en from '../locales/en'; diff --git a/src/locale/en_US.ts b/src/locale/en_US.ts index 1f2ac2fcc56..934c9892263 100644 --- a/src/locale/en_US.ts +++ b/src/locale/en_US.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import en_US from '../locales/en_US'; import en from '../locales/en'; diff --git a/src/locale/en_ZA.ts b/src/locale/en_ZA.ts index 598e78e54ce..f8c7c717ac0 100644 --- a/src/locale/en_ZA.ts +++ b/src/locale/en_ZA.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import en_ZA from '../locales/en_ZA'; import en from '../locales/en'; diff --git a/src/locale/es.ts b/src/locale/es.ts index a6ffc624b7a..326a2696ef8 100644 --- a/src/locale/es.ts +++ b/src/locale/es.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import es from '../locales/es'; import en from '../locales/en'; diff --git a/src/locale/es_MX.ts b/src/locale/es_MX.ts index f7e31228703..21f177facab 100644 --- a/src/locale/es_MX.ts +++ b/src/locale/es_MX.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import es_MX from '../locales/es_MX'; import en from '../locales/en'; diff --git a/src/locale/fa.ts b/src/locale/fa.ts index c0572f37829..1cdd22dbb2c 100644 --- a/src/locale/fa.ts +++ b/src/locale/fa.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import fa from '../locales/fa'; import en from '../locales/en'; diff --git a/src/locale/fi.ts b/src/locale/fi.ts index 140a708a8fb..0355ba466b9 100644 --- a/src/locale/fi.ts +++ b/src/locale/fi.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import fi from '../locales/fi'; import en from '../locales/en'; diff --git a/src/locale/fr.ts b/src/locale/fr.ts index 8d75d785188..f5e17c32ccd 100644 --- a/src/locale/fr.ts +++ b/src/locale/fr.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import fr from '../locales/fr'; import en from '../locales/en'; diff --git a/src/locale/fr_BE.ts b/src/locale/fr_BE.ts index 2f4b7946f8c..d10113b7dbc 100644 --- a/src/locale/fr_BE.ts +++ b/src/locale/fr_BE.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import fr_BE from '../locales/fr_BE'; import en from '../locales/en'; diff --git a/src/locale/fr_CA.ts b/src/locale/fr_CA.ts index e9c8fb83359..4667f04eec6 100644 --- a/src/locale/fr_CA.ts +++ b/src/locale/fr_CA.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import fr_CA from '../locales/fr_CA'; import en from '../locales/en'; diff --git a/src/locale/fr_CH.ts b/src/locale/fr_CH.ts index 22fc5592239..09e0973bbb9 100644 --- a/src/locale/fr_CH.ts +++ b/src/locale/fr_CH.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import fr_CH from '../locales/fr_CH'; import en from '../locales/en'; diff --git a/src/locale/ge.ts b/src/locale/ge.ts index 8830377fd62..7a483d41d22 100644 --- a/src/locale/ge.ts +++ b/src/locale/ge.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import ge from '../locales/ge'; import en from '../locales/en'; diff --git a/src/locale/he.ts b/src/locale/he.ts index 32e7e1fef1a..0832ea121da 100644 --- a/src/locale/he.ts +++ b/src/locale/he.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import he from '../locales/he'; import en from '../locales/en'; diff --git a/src/locale/hr.ts b/src/locale/hr.ts index c15831ea072..1e031c2e76f 100644 --- a/src/locale/hr.ts +++ b/src/locale/hr.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import hr from '../locales/hr'; import en from '../locales/en'; diff --git a/src/locale/hy.ts b/src/locale/hy.ts index fea88758ea7..21ecc4b3fdd 100644 --- a/src/locale/hy.ts +++ b/src/locale/hy.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import hy from '../locales/hy'; import en from '../locales/en'; diff --git a/src/locale/id_ID.ts b/src/locale/id_ID.ts index 57a4dacef20..460ef07ba6c 100644 --- a/src/locale/id_ID.ts +++ b/src/locale/id_ID.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import id_ID from '../locales/id_ID'; import en from '../locales/en'; diff --git a/src/locale/it.ts b/src/locale/it.ts index 14ac5bccf98..e2519ec4961 100644 --- a/src/locale/it.ts +++ b/src/locale/it.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import it from '../locales/it'; import en from '../locales/en'; diff --git a/src/locale/ja.ts b/src/locale/ja.ts index 6191dd2a75d..b8bdde7019f 100644 --- a/src/locale/ja.ts +++ b/src/locale/ja.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import ja from '../locales/ja'; import en from '../locales/en'; diff --git a/src/locale/ko.ts b/src/locale/ko.ts index bb6f82993b1..e63f825aa13 100644 --- a/src/locale/ko.ts +++ b/src/locale/ko.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import ko from '../locales/ko'; import en from '../locales/en'; diff --git a/src/locale/lv.ts b/src/locale/lv.ts index 3e9585e8d2e..4cf73fb4a89 100644 --- a/src/locale/lv.ts +++ b/src/locale/lv.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import lv from '../locales/lv'; import en from '../locales/en'; diff --git a/src/locale/mk.ts b/src/locale/mk.ts index 6545a8de3ba..a59029f0418 100644 --- a/src/locale/mk.ts +++ b/src/locale/mk.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import mk from '../locales/mk'; import en from '../locales/en'; diff --git a/src/locale/nb_NO.ts b/src/locale/nb_NO.ts index 08c4d8fc381..aab8e5d5bd0 100644 --- a/src/locale/nb_NO.ts +++ b/src/locale/nb_NO.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import nb_NO from '../locales/nb_NO'; import en from '../locales/en'; diff --git a/src/locale/ne.ts b/src/locale/ne.ts index 7dd878a2724..e76a1a65109 100644 --- a/src/locale/ne.ts +++ b/src/locale/ne.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import ne from '../locales/ne'; import en from '../locales/en'; diff --git a/src/locale/nl.ts b/src/locale/nl.ts index 062d36d445e..b0209ba4b48 100644 --- a/src/locale/nl.ts +++ b/src/locale/nl.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import nl from '../locales/nl'; import en from '../locales/en'; diff --git a/src/locale/nl_BE.ts b/src/locale/nl_BE.ts index 4d159ddc8aa..46723a3bd95 100644 --- a/src/locale/nl_BE.ts +++ b/src/locale/nl_BE.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import nl_BE from '../locales/nl_BE'; import en from '../locales/en'; diff --git a/src/locale/pl.ts b/src/locale/pl.ts index 7627be92299..6d8d127100a 100644 --- a/src/locale/pl.ts +++ b/src/locale/pl.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import pl from '../locales/pl'; import en from '../locales/en'; diff --git a/src/locale/pt_BR.ts b/src/locale/pt_BR.ts index 043e05879a0..516ab5780f9 100644 --- a/src/locale/pt_BR.ts +++ b/src/locale/pt_BR.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import pt_BR from '../locales/pt_BR'; import en from '../locales/en'; diff --git a/src/locale/pt_PT.ts b/src/locale/pt_PT.ts index 8512fa404d3..8868a015bae 100644 --- a/src/locale/pt_PT.ts +++ b/src/locale/pt_PT.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import pt_PT from '../locales/pt_PT'; import en from '../locales/en'; diff --git a/src/locale/ro.ts b/src/locale/ro.ts index e4b4c76c039..b2494b397e9 100644 --- a/src/locale/ro.ts +++ b/src/locale/ro.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import ro from '../locales/ro'; import en from '../locales/en'; diff --git a/src/locale/ru.ts b/src/locale/ru.ts index 344935b0ea4..58074fd5a1b 100644 --- a/src/locale/ru.ts +++ b/src/locale/ru.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import ru from '../locales/ru'; import en from '../locales/en'; diff --git a/src/locale/sk.ts b/src/locale/sk.ts index e4f55552376..272620a4a64 100644 --- a/src/locale/sk.ts +++ b/src/locale/sk.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import sk from '../locales/sk'; import en from '../locales/en'; diff --git a/src/locale/sv.ts b/src/locale/sv.ts index 3a41b158223..7312efb3174 100644 --- a/src/locale/sv.ts +++ b/src/locale/sv.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import sv from '../locales/sv'; import en from '../locales/en'; diff --git a/src/locale/tr.ts b/src/locale/tr.ts index 0d628cbc785..d32dbfba680 100644 --- a/src/locale/tr.ts +++ b/src/locale/tr.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import tr from '../locales/tr'; import en from '../locales/en'; diff --git a/src/locale/uk.ts b/src/locale/uk.ts index ec8ec631d5d..d628d57bdc6 100644 --- a/src/locale/uk.ts +++ b/src/locale/uk.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import uk from '../locales/uk'; import en from '../locales/en'; diff --git a/src/locale/ur.ts b/src/locale/ur.ts index a25a3662a40..46674d09b10 100644 --- a/src/locale/ur.ts +++ b/src/locale/ur.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import ur from '../locales/ur'; import en from '../locales/en'; diff --git a/src/locale/vi.ts b/src/locale/vi.ts index 8c2f45a4f27..2ac5fb5338a 100644 --- a/src/locale/vi.ts +++ b/src/locale/vi.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import vi from '../locales/vi'; import en from '../locales/en'; diff --git a/src/locale/zh_CN.ts b/src/locale/zh_CN.ts index f47d6bcb2e1..5ad48f04491 100644 --- a/src/locale/zh_CN.ts +++ b/src/locale/zh_CN.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import zh_CN from '../locales/zh_CN'; import en from '../locales/en'; diff --git a/src/locale/zh_TW.ts b/src/locale/zh_TW.ts index 569b8e1c343..bd16c370820 100644 --- a/src/locale/zh_TW.ts +++ b/src/locale/zh_TW.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import zh_TW from '../locales/zh_TW'; import en from '../locales/en'; diff --git a/src/locale/zu_ZA.ts b/src/locale/zu_ZA.ts index e63efbf7c60..3f8da3ce6cf 100644 --- a/src/locale/zu_ZA.ts +++ b/src/locale/zu_ZA.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import { Faker } from '..'; import zu_ZA from '../locales/zu_ZA'; import en from '../locales/en'; diff --git a/src/locales/index.ts b/src/locales/index.ts index 83c012f7118..7340380ea5b 100644 --- a/src/locales/index.ts +++ b/src/locales/index.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm esno scripts/generateLocales.ts' to update. + */ + import type { LocaleDefinition } from '..'; import af_ZA from './af_ZA'; import ar from './ar'; From f347a56625a2f15c682af1cad416a0cc912db4b4 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Thu, 27 Jan 2022 14:31:54 +0100 Subject: [PATCH 05/10] chore: add command to generate locale related files --- CONTRIBUTING.md | 1 + docs/api/localization.md | 2 +- package.json | 3 ++- scripts/generateLocales.ts | 4 ++-- src/locale/af_ZA.ts | 2 +- src/locale/ar.ts | 2 +- src/locale/az.ts | 2 +- src/locale/cz.ts | 2 +- src/locale/de.ts | 2 +- src/locale/de_AT.ts | 2 +- src/locale/de_CH.ts | 2 +- src/locale/el.ts | 2 +- src/locale/en_AU.ts | 2 +- src/locale/en_AU_ocker.ts | 2 +- src/locale/en_BORK.ts | 2 +- src/locale/en_CA.ts | 2 +- src/locale/en_GB.ts | 2 +- src/locale/en_GH.ts | 2 +- src/locale/en_IE.ts | 2 +- src/locale/en_IND.ts | 2 +- src/locale/en_NG.ts | 2 +- src/locale/en_US.ts | 2 +- src/locale/en_ZA.ts | 2 +- src/locale/es.ts | 2 +- src/locale/es_MX.ts | 2 +- src/locale/fa.ts | 2 +- src/locale/fi.ts | 2 +- src/locale/fr.ts | 2 +- src/locale/fr_BE.ts | 2 +- src/locale/fr_CA.ts | 2 +- src/locale/fr_CH.ts | 2 +- src/locale/ge.ts | 2 +- src/locale/he.ts | 2 +- src/locale/hr.ts | 2 +- src/locale/hy.ts | 2 +- src/locale/id_ID.ts | 2 +- src/locale/it.ts | 2 +- src/locale/ja.ts | 2 +- src/locale/ko.ts | 2 +- src/locale/lv.ts | 2 +- src/locale/mk.ts | 2 +- src/locale/nb_NO.ts | 2 +- src/locale/ne.ts | 2 +- src/locale/nl.ts | 2 +- src/locale/nl_BE.ts | 2 +- src/locale/pl.ts | 2 +- src/locale/pt_BR.ts | 2 +- src/locale/pt_PT.ts | 2 +- src/locale/ro.ts | 2 +- src/locale/ru.ts | 2 +- src/locale/sk.ts | 2 +- src/locale/sv.ts | 2 +- src/locale/tr.ts | 2 +- src/locale/uk.ts | 2 +- src/locale/ur.ts | 2 +- src/locale/vi.ts | 2 +- src/locale/zh_CN.ts | 2 +- src/locale/zh_TW.ts | 2 +- src/locale/zu_ZA.ts | 2 +- src/locales/index.ts | 2 +- 60 files changed, 62 insertions(+), 60 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2bc75f6d517..fec845a44cb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,6 +13,7 @@ If you want to make `Faker` a better, please read the following contribution gui Make sure you **build** the project before running the docs, cause some files depend on `dist`. Use `pnpm run docs:dev` to edit them in live mode. - The tests are executing `vitest` against `test/**/*.spec.ts` +- If you update the locales, make sure to run `pnpm run generate` to generate/update the related files. ## Architecture diff --git a/docs/api/localization.md b/docs/api/localization.md index 48a31c08961..2c9997b1661 100644 --- a/docs/api/localization.md +++ b/docs/api/localization.md @@ -15,7 +15,7 @@ faker.locale = 'de'; - + | Locale | Name | | :---------- | :------------------------ | diff --git a/package.json b/package.json index 78126779176..008dd74d079 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,8 @@ "build:code": "esno ./scripts/bundle.ts", "build:types": "tsc --emitDeclarationOnly --outDir dist/types", "build": "run-s build:clean build:code build:types", - "generate:api-docs": "esno scripts/apidoc.ts", + "generate:api-docs": "esno ./scripts/apidoc.ts", + "generate:locales": "esno ./scripts/generateLocales.ts", "docs:build": "run-s docs:prepare docs:build:run", "docs:build:run": "vitepress build docs", "docs:build:ci": "run-s build docs:build", diff --git a/scripts/generateLocales.ts b/scripts/generateLocales.ts index 2fb96e38387..630a6de7057 100644 --- a/scripts/generateLocales.ts +++ b/scripts/generateLocales.ts @@ -26,7 +26,7 @@ let localizationLocales = '| Locale | Name |\n| :--- | :--- |\n'; const autoGeneratedCommentHeader = `/* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */`; for (let locale of locales) { @@ -93,6 +93,6 @@ localizationLocales = format(localizationLocales, { let localizationContent = readFileSync(pathDocsApiLocalization, 'utf-8'); localizationContent = localizationContent.replace( /(^$).*(^$)/gms, - `$1\n\n\n\n${localizationLocales}\n$2` + `$1\n\n\n\n${localizationLocales}\n$2` ); writeFileSync(pathDocsApiLocalization, localizationContent); diff --git a/src/locale/af_ZA.ts b/src/locale/af_ZA.ts index d7a1c7f6f18..c6f514ad667 100644 --- a/src/locale/af_ZA.ts +++ b/src/locale/af_ZA.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/ar.ts b/src/locale/ar.ts index cba058f3575..2c02f9b8a2f 100644 --- a/src/locale/ar.ts +++ b/src/locale/ar.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/az.ts b/src/locale/az.ts index eb50cec1bab..72ab856bdb2 100644 --- a/src/locale/az.ts +++ b/src/locale/az.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/cz.ts b/src/locale/cz.ts index 60d805e71d6..caadbb2d1f5 100644 --- a/src/locale/cz.ts +++ b/src/locale/cz.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/de.ts b/src/locale/de.ts index ace52e2e180..b94f7686dca 100644 --- a/src/locale/de.ts +++ b/src/locale/de.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/de_AT.ts b/src/locale/de_AT.ts index cf20f2706ca..b176199f95d 100644 --- a/src/locale/de_AT.ts +++ b/src/locale/de_AT.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/de_CH.ts b/src/locale/de_CH.ts index 1d341c3a38b..aee63b5aa7f 100644 --- a/src/locale/de_CH.ts +++ b/src/locale/de_CH.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/el.ts b/src/locale/el.ts index bcefb788504..ee83b22ed1b 100644 --- a/src/locale/el.ts +++ b/src/locale/el.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_AU.ts b/src/locale/en_AU.ts index 8ccf4dc2c15..c76c7b62325 100644 --- a/src/locale/en_AU.ts +++ b/src/locale/en_AU.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_AU_ocker.ts b/src/locale/en_AU_ocker.ts index e09df344d28..aa5386556ab 100644 --- a/src/locale/en_AU_ocker.ts +++ b/src/locale/en_AU_ocker.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_BORK.ts b/src/locale/en_BORK.ts index 99215fc9da5..a8d4d510324 100644 --- a/src/locale/en_BORK.ts +++ b/src/locale/en_BORK.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_CA.ts b/src/locale/en_CA.ts index a9a948c50b1..ef948d81d4b 100644 --- a/src/locale/en_CA.ts +++ b/src/locale/en_CA.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_GB.ts b/src/locale/en_GB.ts index d8460578cf7..efd256dfb7a 100644 --- a/src/locale/en_GB.ts +++ b/src/locale/en_GB.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_GH.ts b/src/locale/en_GH.ts index e4d9816ea2e..f80ce7dd878 100644 --- a/src/locale/en_GH.ts +++ b/src/locale/en_GH.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_IE.ts b/src/locale/en_IE.ts index 7a0aca53020..fdc69fd1c2b 100644 --- a/src/locale/en_IE.ts +++ b/src/locale/en_IE.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_IND.ts b/src/locale/en_IND.ts index 16a1b2a6de2..528ced210fd 100644 --- a/src/locale/en_IND.ts +++ b/src/locale/en_IND.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_NG.ts b/src/locale/en_NG.ts index 81f593313de..4fc30331083 100644 --- a/src/locale/en_NG.ts +++ b/src/locale/en_NG.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_US.ts b/src/locale/en_US.ts index 934c9892263..ab30817fc09 100644 --- a/src/locale/en_US.ts +++ b/src/locale/en_US.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_ZA.ts b/src/locale/en_ZA.ts index f8c7c717ac0..b5ef5cdec59 100644 --- a/src/locale/en_ZA.ts +++ b/src/locale/en_ZA.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/es.ts b/src/locale/es.ts index 326a2696ef8..df7a6200155 100644 --- a/src/locale/es.ts +++ b/src/locale/es.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/es_MX.ts b/src/locale/es_MX.ts index 21f177facab..16579a08c92 100644 --- a/src/locale/es_MX.ts +++ b/src/locale/es_MX.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/fa.ts b/src/locale/fa.ts index 1cdd22dbb2c..d28789d9e55 100644 --- a/src/locale/fa.ts +++ b/src/locale/fa.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/fi.ts b/src/locale/fi.ts index 0355ba466b9..04eb86332e6 100644 --- a/src/locale/fi.ts +++ b/src/locale/fi.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/fr.ts b/src/locale/fr.ts index f5e17c32ccd..f8fa00be396 100644 --- a/src/locale/fr.ts +++ b/src/locale/fr.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/fr_BE.ts b/src/locale/fr_BE.ts index d10113b7dbc..2ba70dd2ef0 100644 --- a/src/locale/fr_BE.ts +++ b/src/locale/fr_BE.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/fr_CA.ts b/src/locale/fr_CA.ts index 4667f04eec6..0aedecdb614 100644 --- a/src/locale/fr_CA.ts +++ b/src/locale/fr_CA.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/fr_CH.ts b/src/locale/fr_CH.ts index 09e0973bbb9..7dda209b071 100644 --- a/src/locale/fr_CH.ts +++ b/src/locale/fr_CH.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/ge.ts b/src/locale/ge.ts index 7a483d41d22..ca3268a47d0 100644 --- a/src/locale/ge.ts +++ b/src/locale/ge.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/he.ts b/src/locale/he.ts index 0832ea121da..198eab6de2e 100644 --- a/src/locale/he.ts +++ b/src/locale/he.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/hr.ts b/src/locale/hr.ts index 1e031c2e76f..98e39f76002 100644 --- a/src/locale/hr.ts +++ b/src/locale/hr.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/hy.ts b/src/locale/hy.ts index 21ecc4b3fdd..f50574563f9 100644 --- a/src/locale/hy.ts +++ b/src/locale/hy.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/id_ID.ts b/src/locale/id_ID.ts index 460ef07ba6c..6b35ff47ce5 100644 --- a/src/locale/id_ID.ts +++ b/src/locale/id_ID.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/it.ts b/src/locale/it.ts index e2519ec4961..45005f744ca 100644 --- a/src/locale/it.ts +++ b/src/locale/it.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/ja.ts b/src/locale/ja.ts index b8bdde7019f..627b178efcd 100644 --- a/src/locale/ja.ts +++ b/src/locale/ja.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/ko.ts b/src/locale/ko.ts index e63f825aa13..8f0f498e576 100644 --- a/src/locale/ko.ts +++ b/src/locale/ko.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/lv.ts b/src/locale/lv.ts index 4cf73fb4a89..e8cb7129935 100644 --- a/src/locale/lv.ts +++ b/src/locale/lv.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/mk.ts b/src/locale/mk.ts index a59029f0418..5c188a0d476 100644 --- a/src/locale/mk.ts +++ b/src/locale/mk.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/nb_NO.ts b/src/locale/nb_NO.ts index aab8e5d5bd0..dcab3a19159 100644 --- a/src/locale/nb_NO.ts +++ b/src/locale/nb_NO.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/ne.ts b/src/locale/ne.ts index e76a1a65109..78d7d8f140d 100644 --- a/src/locale/ne.ts +++ b/src/locale/ne.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/nl.ts b/src/locale/nl.ts index b0209ba4b48..82216f62a7d 100644 --- a/src/locale/nl.ts +++ b/src/locale/nl.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/nl_BE.ts b/src/locale/nl_BE.ts index 46723a3bd95..0bcc18a1cc4 100644 --- a/src/locale/nl_BE.ts +++ b/src/locale/nl_BE.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/pl.ts b/src/locale/pl.ts index 6d8d127100a..3b632a12a00 100644 --- a/src/locale/pl.ts +++ b/src/locale/pl.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/pt_BR.ts b/src/locale/pt_BR.ts index 516ab5780f9..b4eede8e0d8 100644 --- a/src/locale/pt_BR.ts +++ b/src/locale/pt_BR.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/pt_PT.ts b/src/locale/pt_PT.ts index 8868a015bae..8583d30f663 100644 --- a/src/locale/pt_PT.ts +++ b/src/locale/pt_PT.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/ro.ts b/src/locale/ro.ts index b2494b397e9..22c777c291e 100644 --- a/src/locale/ro.ts +++ b/src/locale/ro.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/ru.ts b/src/locale/ru.ts index 58074fd5a1b..8167a0794de 100644 --- a/src/locale/ru.ts +++ b/src/locale/ru.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/sk.ts b/src/locale/sk.ts index 272620a4a64..00e6e3abdca 100644 --- a/src/locale/sk.ts +++ b/src/locale/sk.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/sv.ts b/src/locale/sv.ts index 7312efb3174..c440286e848 100644 --- a/src/locale/sv.ts +++ b/src/locale/sv.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/tr.ts b/src/locale/tr.ts index d32dbfba680..c7783e1423d 100644 --- a/src/locale/tr.ts +++ b/src/locale/tr.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/uk.ts b/src/locale/uk.ts index d628d57bdc6..32ba438a783 100644 --- a/src/locale/uk.ts +++ b/src/locale/uk.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/ur.ts b/src/locale/ur.ts index 46674d09b10..623530c66a0 100644 --- a/src/locale/ur.ts +++ b/src/locale/ur.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/vi.ts b/src/locale/vi.ts index 2ac5fb5338a..796d1843359 100644 --- a/src/locale/vi.ts +++ b/src/locale/vi.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/zh_CN.ts b/src/locale/zh_CN.ts index 5ad48f04491..e81a3022ca2 100644 --- a/src/locale/zh_CN.ts +++ b/src/locale/zh_CN.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/zh_TW.ts b/src/locale/zh_TW.ts index bd16c370820..02defd4f8b6 100644 --- a/src/locale/zh_TW.ts +++ b/src/locale/zh_TW.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locale/zu_ZA.ts b/src/locale/zu_ZA.ts index 3f8da3ce6cf..60c3ae6e48f 100644 --- a/src/locale/zu_ZA.ts +++ b/src/locale/zu_ZA.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import { Faker } from '..'; diff --git a/src/locales/index.ts b/src/locales/index.ts index 7340380ea5b..2823960165e 100644 --- a/src/locales/index.ts +++ b/src/locales/index.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm esno scripts/generateLocales.ts' to update. + * Run 'pnpm run generate' to update. */ import type { LocaleDefinition } from '..'; From db6d1366b2a1ecbcc748bdcca19b100a320a978d Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Thu, 27 Jan 2022 14:38:04 +0100 Subject: [PATCH 06/10] chore: restore original export behavior --- scripts/generateLocales.ts | 2 +- src/locale/af_ZA.ts | 2 +- src/locale/ar.ts | 2 +- src/locale/az.ts | 2 +- src/locale/cz.ts | 2 +- src/locale/de.ts | 2 +- src/locale/de_AT.ts | 2 +- src/locale/de_CH.ts | 2 +- src/locale/el.ts | 2 +- src/locale/en_AU.ts | 2 +- src/locale/en_AU_ocker.ts | 2 +- src/locale/en_BORK.ts | 2 +- src/locale/en_CA.ts | 2 +- src/locale/en_GB.ts | 2 +- src/locale/en_GH.ts | 2 +- src/locale/en_IE.ts | 2 +- src/locale/en_IND.ts | 2 +- src/locale/en_NG.ts | 2 +- src/locale/en_US.ts | 2 +- src/locale/en_ZA.ts | 2 +- src/locale/es.ts | 2 +- src/locale/es_MX.ts | 2 +- src/locale/fa.ts | 2 +- src/locale/fi.ts | 2 +- src/locale/fr.ts | 2 +- src/locale/fr_BE.ts | 2 +- src/locale/fr_CA.ts | 2 +- src/locale/fr_CH.ts | 2 +- src/locale/ge.ts | 2 +- src/locale/he.ts | 2 +- src/locale/hr.ts | 2 +- src/locale/hy.ts | 2 +- src/locale/id_ID.ts | 2 +- src/locale/it.ts | 2 +- src/locale/ja.ts | 2 +- src/locale/ko.ts | 2 +- src/locale/lv.ts | 2 +- src/locale/mk.ts | 2 +- src/locale/nb_NO.ts | 2 +- src/locale/ne.ts | 2 +- src/locale/nl.ts | 2 +- src/locale/nl_BE.ts | 2 +- src/locale/pl.ts | 2 +- src/locale/pt_BR.ts | 2 +- src/locale/pt_PT.ts | 2 +- src/locale/ro.ts | 2 +- src/locale/ru.ts | 2 +- src/locale/sk.ts | 2 +- src/locale/sv.ts | 2 +- src/locale/tr.ts | 2 +- src/locale/uk.ts | 2 +- src/locale/ur.ts | 2 +- src/locale/vi.ts | 2 +- src/locale/zh_CN.ts | 2 +- src/locale/zh_TW.ts | 2 +- src/locale/zu_ZA.ts | 2 +- 56 files changed, 56 insertions(+), 56 deletions(-) diff --git a/scripts/generateLocales.ts b/scripts/generateLocales.ts index 630a6de7057..ba93635c503 100644 --- a/scripts/generateLocales.ts +++ b/scripts/generateLocales.ts @@ -57,7 +57,7 @@ for (let locale of locales) { }, }); - export default faker;`; + export = faker;`; content = format(content, { ...options, parser: 'typescript' }); writeFileSync(resolve(pathLocale, locale + '.ts'), content); } diff --git a/src/locale/af_ZA.ts b/src/locale/af_ZA.ts index c6f514ad667..b09e07bd390 100644 --- a/src/locale/af_ZA.ts +++ b/src/locale/af_ZA.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/ar.ts b/src/locale/ar.ts index 2c02f9b8a2f..f17c5479c68 100644 --- a/src/locale/ar.ts +++ b/src/locale/ar.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/az.ts b/src/locale/az.ts index 72ab856bdb2..cea73c5c308 100644 --- a/src/locale/az.ts +++ b/src/locale/az.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/cz.ts b/src/locale/cz.ts index caadbb2d1f5..01caa14f8a6 100644 --- a/src/locale/cz.ts +++ b/src/locale/cz.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/de.ts b/src/locale/de.ts index b94f7686dca..db476abdd46 100644 --- a/src/locale/de.ts +++ b/src/locale/de.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/de_AT.ts b/src/locale/de_AT.ts index b176199f95d..579e3ba03a7 100644 --- a/src/locale/de_AT.ts +++ b/src/locale/de_AT.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/de_CH.ts b/src/locale/de_CH.ts index aee63b5aa7f..2c4066be72a 100644 --- a/src/locale/de_CH.ts +++ b/src/locale/de_CH.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/el.ts b/src/locale/el.ts index ee83b22ed1b..479cc358cf5 100644 --- a/src/locale/el.ts +++ b/src/locale/el.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/en_AU.ts b/src/locale/en_AU.ts index c76c7b62325..6018d5942eb 100644 --- a/src/locale/en_AU.ts +++ b/src/locale/en_AU.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/en_AU_ocker.ts b/src/locale/en_AU_ocker.ts index aa5386556ab..09a7a9687d1 100644 --- a/src/locale/en_AU_ocker.ts +++ b/src/locale/en_AU_ocker.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/en_BORK.ts b/src/locale/en_BORK.ts index a8d4d510324..fad7c1e399c 100644 --- a/src/locale/en_BORK.ts +++ b/src/locale/en_BORK.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/en_CA.ts b/src/locale/en_CA.ts index ef948d81d4b..20689f69ae2 100644 --- a/src/locale/en_CA.ts +++ b/src/locale/en_CA.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/en_GB.ts b/src/locale/en_GB.ts index efd256dfb7a..f349a9b7f77 100644 --- a/src/locale/en_GB.ts +++ b/src/locale/en_GB.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/en_GH.ts b/src/locale/en_GH.ts index f80ce7dd878..40c2fd7a205 100644 --- a/src/locale/en_GH.ts +++ b/src/locale/en_GH.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/en_IE.ts b/src/locale/en_IE.ts index fdc69fd1c2b..4e518f2240e 100644 --- a/src/locale/en_IE.ts +++ b/src/locale/en_IE.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/en_IND.ts b/src/locale/en_IND.ts index 528ced210fd..30187de2086 100644 --- a/src/locale/en_IND.ts +++ b/src/locale/en_IND.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/en_NG.ts b/src/locale/en_NG.ts index 4fc30331083..af9ac897fc6 100644 --- a/src/locale/en_NG.ts +++ b/src/locale/en_NG.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/en_US.ts b/src/locale/en_US.ts index ab30817fc09..83f9990b1df 100644 --- a/src/locale/en_US.ts +++ b/src/locale/en_US.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/en_ZA.ts b/src/locale/en_ZA.ts index b5ef5cdec59..814b790d473 100644 --- a/src/locale/en_ZA.ts +++ b/src/locale/en_ZA.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/es.ts b/src/locale/es.ts index df7a6200155..70410667b7a 100644 --- a/src/locale/es.ts +++ b/src/locale/es.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/es_MX.ts b/src/locale/es_MX.ts index 16579a08c92..4e5dd628bc7 100644 --- a/src/locale/es_MX.ts +++ b/src/locale/es_MX.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/fa.ts b/src/locale/fa.ts index d28789d9e55..e44455f8f2a 100644 --- a/src/locale/fa.ts +++ b/src/locale/fa.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/fi.ts b/src/locale/fi.ts index 04eb86332e6..dc974ef7233 100644 --- a/src/locale/fi.ts +++ b/src/locale/fi.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/fr.ts b/src/locale/fr.ts index f8fa00be396..4791616f513 100644 --- a/src/locale/fr.ts +++ b/src/locale/fr.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/fr_BE.ts b/src/locale/fr_BE.ts index 2ba70dd2ef0..42be907bd65 100644 --- a/src/locale/fr_BE.ts +++ b/src/locale/fr_BE.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/fr_CA.ts b/src/locale/fr_CA.ts index 0aedecdb614..08a63145466 100644 --- a/src/locale/fr_CA.ts +++ b/src/locale/fr_CA.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/fr_CH.ts b/src/locale/fr_CH.ts index 7dda209b071..f274da9a4d8 100644 --- a/src/locale/fr_CH.ts +++ b/src/locale/fr_CH.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/ge.ts b/src/locale/ge.ts index ca3268a47d0..bb3989a7c96 100644 --- a/src/locale/ge.ts +++ b/src/locale/ge.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/he.ts b/src/locale/he.ts index 198eab6de2e..a61b170fda0 100644 --- a/src/locale/he.ts +++ b/src/locale/he.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/hr.ts b/src/locale/hr.ts index 98e39f76002..0e348746aeb 100644 --- a/src/locale/hr.ts +++ b/src/locale/hr.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/hy.ts b/src/locale/hy.ts index f50574563f9..debcd66b194 100644 --- a/src/locale/hy.ts +++ b/src/locale/hy.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/id_ID.ts b/src/locale/id_ID.ts index 6b35ff47ce5..ef19fbe1c89 100644 --- a/src/locale/id_ID.ts +++ b/src/locale/id_ID.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/it.ts b/src/locale/it.ts index 45005f744ca..cfd21707fc7 100644 --- a/src/locale/it.ts +++ b/src/locale/it.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/ja.ts b/src/locale/ja.ts index 627b178efcd..9f9b9f970d7 100644 --- a/src/locale/ja.ts +++ b/src/locale/ja.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/ko.ts b/src/locale/ko.ts index 8f0f498e576..254e5d28aae 100644 --- a/src/locale/ko.ts +++ b/src/locale/ko.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/lv.ts b/src/locale/lv.ts index e8cb7129935..95ad139df49 100644 --- a/src/locale/lv.ts +++ b/src/locale/lv.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/mk.ts b/src/locale/mk.ts index 5c188a0d476..aba8a8f69f8 100644 --- a/src/locale/mk.ts +++ b/src/locale/mk.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/nb_NO.ts b/src/locale/nb_NO.ts index dcab3a19159..44b522b5939 100644 --- a/src/locale/nb_NO.ts +++ b/src/locale/nb_NO.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/ne.ts b/src/locale/ne.ts index 78d7d8f140d..23f45734ce8 100644 --- a/src/locale/ne.ts +++ b/src/locale/ne.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/nl.ts b/src/locale/nl.ts index 82216f62a7d..dba921bfae3 100644 --- a/src/locale/nl.ts +++ b/src/locale/nl.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/nl_BE.ts b/src/locale/nl_BE.ts index 0bcc18a1cc4..8f342af37c5 100644 --- a/src/locale/nl_BE.ts +++ b/src/locale/nl_BE.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/pl.ts b/src/locale/pl.ts index 3b632a12a00..bcfcd695d7f 100644 --- a/src/locale/pl.ts +++ b/src/locale/pl.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/pt_BR.ts b/src/locale/pt_BR.ts index b4eede8e0d8..0a3ed5a93b3 100644 --- a/src/locale/pt_BR.ts +++ b/src/locale/pt_BR.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/pt_PT.ts b/src/locale/pt_PT.ts index 8583d30f663..0909bb6a6c3 100644 --- a/src/locale/pt_PT.ts +++ b/src/locale/pt_PT.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/ro.ts b/src/locale/ro.ts index 22c777c291e..2dce8064a08 100644 --- a/src/locale/ro.ts +++ b/src/locale/ro.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/ru.ts b/src/locale/ru.ts index 8167a0794de..0768988c815 100644 --- a/src/locale/ru.ts +++ b/src/locale/ru.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/sk.ts b/src/locale/sk.ts index 00e6e3abdca..b1ba74d1e6d 100644 --- a/src/locale/sk.ts +++ b/src/locale/sk.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/sv.ts b/src/locale/sv.ts index c440286e848..e0a16ba51a6 100644 --- a/src/locale/sv.ts +++ b/src/locale/sv.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/tr.ts b/src/locale/tr.ts index c7783e1423d..4ff2b9a677c 100644 --- a/src/locale/tr.ts +++ b/src/locale/tr.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/uk.ts b/src/locale/uk.ts index 32ba438a783..f18bf2ecb3c 100644 --- a/src/locale/uk.ts +++ b/src/locale/uk.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/ur.ts b/src/locale/ur.ts index 623530c66a0..f71c0cbdb51 100644 --- a/src/locale/ur.ts +++ b/src/locale/ur.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/vi.ts b/src/locale/vi.ts index 796d1843359..425029f6fec 100644 --- a/src/locale/vi.ts +++ b/src/locale/vi.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/zh_CN.ts b/src/locale/zh_CN.ts index e81a3022ca2..c21a96c0fb7 100644 --- a/src/locale/zh_CN.ts +++ b/src/locale/zh_CN.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/zh_TW.ts b/src/locale/zh_TW.ts index 02defd4f8b6..cf835784742 100644 --- a/src/locale/zh_TW.ts +++ b/src/locale/zh_TW.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; diff --git a/src/locale/zu_ZA.ts b/src/locale/zu_ZA.ts index 60c3ae6e48f..b76a1053eed 100644 --- a/src/locale/zu_ZA.ts +++ b/src/locale/zu_ZA.ts @@ -16,4 +16,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; From 37754e763eb7ac4a48288fac314d1278b445b3f2 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Thu, 27 Jan 2022 15:24:20 +0100 Subject: [PATCH 07/10] fix: also generate en locale file --- scripts/generateLocales.ts | 16 ++++++++-------- src/locale/en.ts | 7 ++++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/scripts/generateLocales.ts b/scripts/generateLocales.ts index ba93635c503..3f6559acb16 100644 --- a/scripts/generateLocales.ts +++ b/scripts/generateLocales.ts @@ -40,27 +40,27 @@ for (let locale of locales) { localizationLocales += `| ${locale} | ${localeTitle} |\n`; // src/locale/.ts - if (locale !== 'en') { - let content: string = ` + let content: string = ` ${autoGeneratedCommentHeader} import { Faker } from '..'; import ${locale} from '../locales/${locale}'; - import en from '../locales/en'; + ${locale !== 'en' ? "import en from '../locales/en';" : ''} const faker = new Faker({ locale: '${locale}', localeFallback: 'en', locales: { ${locale}, - en, + ${locale !== 'en' ? 'en,' : ''} }, }); - export = faker;`; - content = format(content, { ...options, parser: 'typescript' }); - writeFileSync(resolve(pathLocale, locale + '.ts'), content); - } + export = faker; + `; + + content = format(content, { ...options, parser: 'typescript' }); + writeFileSync(resolve(pathLocale, locale + '.ts'), content); } // src/locales/index.ts diff --git a/src/locale/en.ts b/src/locale/en.ts index 333a143752a..36f49269d67 100644 --- a/src/locale/en.ts +++ b/src/locale/en.ts @@ -1,3 +1,8 @@ +/* + * This file is automatically generated. + * Run 'pnpm run generate' to update. + */ + import { Faker } from '..'; import en from '../locales/en'; @@ -9,4 +14,4 @@ const faker = new Faker({ }, }); -export default faker; +export = faker; From d36cb665dac3b8df9f5fb14f12d7b5529ec0e221 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Thu, 27 Jan 2022 15:32:57 +0100 Subject: [PATCH 08/10] chore: rename generation command --- CONTRIBUTING.md | 2 +- docs/api/localization.md | 2 +- scripts/generateLocales.ts | 6 ++++-- src/locale/af_ZA.ts | 2 +- src/locale/ar.ts | 2 +- src/locale/az.ts | 2 +- src/locale/cz.ts | 2 +- src/locale/de.ts | 2 +- src/locale/de_AT.ts | 2 +- src/locale/de_CH.ts | 2 +- src/locale/el.ts | 2 +- src/locale/en.ts | 2 +- src/locale/en_AU.ts | 2 +- src/locale/en_AU_ocker.ts | 2 +- src/locale/en_BORK.ts | 2 +- src/locale/en_CA.ts | 2 +- src/locale/en_GB.ts | 2 +- src/locale/en_GH.ts | 2 +- src/locale/en_IE.ts | 2 +- src/locale/en_IND.ts | 2 +- src/locale/en_NG.ts | 2 +- src/locale/en_US.ts | 2 +- src/locale/en_ZA.ts | 2 +- src/locale/es.ts | 2 +- src/locale/es_MX.ts | 2 +- src/locale/fa.ts | 2 +- src/locale/fi.ts | 2 +- src/locale/fr.ts | 2 +- src/locale/fr_BE.ts | 2 +- src/locale/fr_CA.ts | 2 +- src/locale/fr_CH.ts | 2 +- src/locale/ge.ts | 2 +- src/locale/he.ts | 2 +- src/locale/hr.ts | 2 +- src/locale/hy.ts | 2 +- src/locale/id_ID.ts | 2 +- src/locale/it.ts | 2 +- src/locale/ja.ts | 2 +- src/locale/ko.ts | 2 +- src/locale/lv.ts | 2 +- src/locale/mk.ts | 2 +- src/locale/nb_NO.ts | 2 +- src/locale/ne.ts | 2 +- src/locale/nl.ts | 2 +- src/locale/nl_BE.ts | 2 +- src/locale/pl.ts | 2 +- src/locale/pt_BR.ts | 2 +- src/locale/pt_PT.ts | 2 +- src/locale/ro.ts | 2 +- src/locale/ru.ts | 2 +- src/locale/sk.ts | 2 +- src/locale/sv.ts | 2 +- src/locale/tr.ts | 2 +- src/locale/uk.ts | 2 +- src/locale/ur.ts | 2 +- src/locale/vi.ts | 2 +- src/locale/zh_CN.ts | 2 +- src/locale/zh_TW.ts | 2 +- src/locale/zu_ZA.ts | 2 +- src/locales/index.ts | 2 +- 60 files changed, 63 insertions(+), 61 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fec845a44cb..65e70c4759f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,7 +13,7 @@ If you want to make `Faker` a better, please read the following contribution gui Make sure you **build** the project before running the docs, cause some files depend on `dist`. Use `pnpm run docs:dev` to edit them in live mode. - The tests are executing `vitest` against `test/**/*.spec.ts` -- If you update the locales, make sure to run `pnpm run generate` to generate/update the related files. +- If you update the locales, make sure to run `pnpm run generate:locales` to generate/update the related files. ## Architecture diff --git a/docs/api/localization.md b/docs/api/localization.md index 2c9997b1661..375e5e54bad 100644 --- a/docs/api/localization.md +++ b/docs/api/localization.md @@ -15,7 +15,7 @@ faker.locale = 'de'; - + | Locale | Name | | :---------- | :------------------------ | diff --git a/scripts/generateLocales.ts b/scripts/generateLocales.ts index 3f6559acb16..c855f13bdfb 100644 --- a/scripts/generateLocales.ts +++ b/scripts/generateLocales.ts @@ -15,6 +15,8 @@ const pathDocsApiLocalization = resolve( 'localization.md' ); +const scriptCommand = 'pnpm run generate:locales'; + const locales = readdirSync(pathLocales); locales.splice(locales.indexOf('index.ts'), 1); @@ -26,7 +28,7 @@ let localizationLocales = '| Locale | Name |\n| :--- | :--- |\n'; const autoGeneratedCommentHeader = `/* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run '${scriptCommand}' to update. */`; for (let locale of locales) { @@ -93,6 +95,6 @@ localizationLocales = format(localizationLocales, { let localizationContent = readFileSync(pathDocsApiLocalization, 'utf-8'); localizationContent = localizationContent.replace( /(^$).*(^$)/gms, - `$1\n\n\n\n${localizationLocales}\n$2` + `$1\n\n\n\n${localizationLocales}\n$2` ); writeFileSync(pathDocsApiLocalization, localizationContent); diff --git a/src/locale/af_ZA.ts b/src/locale/af_ZA.ts index b09e07bd390..2054b1abe1e 100644 --- a/src/locale/af_ZA.ts +++ b/src/locale/af_ZA.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/ar.ts b/src/locale/ar.ts index f17c5479c68..51b012858c9 100644 --- a/src/locale/ar.ts +++ b/src/locale/ar.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/az.ts b/src/locale/az.ts index cea73c5c308..b59c9cd2d98 100644 --- a/src/locale/az.ts +++ b/src/locale/az.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/cz.ts b/src/locale/cz.ts index 01caa14f8a6..42be75571bd 100644 --- a/src/locale/cz.ts +++ b/src/locale/cz.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/de.ts b/src/locale/de.ts index db476abdd46..ed68f5262a9 100644 --- a/src/locale/de.ts +++ b/src/locale/de.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/de_AT.ts b/src/locale/de_AT.ts index 579e3ba03a7..56e5b93245a 100644 --- a/src/locale/de_AT.ts +++ b/src/locale/de_AT.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/de_CH.ts b/src/locale/de_CH.ts index 2c4066be72a..91188431c0e 100644 --- a/src/locale/de_CH.ts +++ b/src/locale/de_CH.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/el.ts b/src/locale/el.ts index 479cc358cf5..05485513ea0 100644 --- a/src/locale/el.ts +++ b/src/locale/el.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/en.ts b/src/locale/en.ts index 36f49269d67..bbb7f2a48ec 100644 --- a/src/locale/en.ts +++ b/src/locale/en.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_AU.ts b/src/locale/en_AU.ts index 6018d5942eb..e83c755c641 100644 --- a/src/locale/en_AU.ts +++ b/src/locale/en_AU.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_AU_ocker.ts b/src/locale/en_AU_ocker.ts index 09a7a9687d1..ef410ced0a9 100644 --- a/src/locale/en_AU_ocker.ts +++ b/src/locale/en_AU_ocker.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_BORK.ts b/src/locale/en_BORK.ts index fad7c1e399c..cc0eb5ad80e 100644 --- a/src/locale/en_BORK.ts +++ b/src/locale/en_BORK.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_CA.ts b/src/locale/en_CA.ts index 20689f69ae2..513eccba2cf 100644 --- a/src/locale/en_CA.ts +++ b/src/locale/en_CA.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_GB.ts b/src/locale/en_GB.ts index f349a9b7f77..be8fbd9f5cb 100644 --- a/src/locale/en_GB.ts +++ b/src/locale/en_GB.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_GH.ts b/src/locale/en_GH.ts index 40c2fd7a205..4bb0ef6b0d6 100644 --- a/src/locale/en_GH.ts +++ b/src/locale/en_GH.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_IE.ts b/src/locale/en_IE.ts index 4e518f2240e..64e6001aab4 100644 --- a/src/locale/en_IE.ts +++ b/src/locale/en_IE.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_IND.ts b/src/locale/en_IND.ts index 30187de2086..55444519e9a 100644 --- a/src/locale/en_IND.ts +++ b/src/locale/en_IND.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_NG.ts b/src/locale/en_NG.ts index af9ac897fc6..8f7be7cea6a 100644 --- a/src/locale/en_NG.ts +++ b/src/locale/en_NG.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_US.ts b/src/locale/en_US.ts index 83f9990b1df..24f38345424 100644 --- a/src/locale/en_US.ts +++ b/src/locale/en_US.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/en_ZA.ts b/src/locale/en_ZA.ts index 814b790d473..f7d1d5192ca 100644 --- a/src/locale/en_ZA.ts +++ b/src/locale/en_ZA.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/es.ts b/src/locale/es.ts index 70410667b7a..e1eb406bfe8 100644 --- a/src/locale/es.ts +++ b/src/locale/es.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/es_MX.ts b/src/locale/es_MX.ts index 4e5dd628bc7..2d357df405f 100644 --- a/src/locale/es_MX.ts +++ b/src/locale/es_MX.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/fa.ts b/src/locale/fa.ts index e44455f8f2a..778332b76b1 100644 --- a/src/locale/fa.ts +++ b/src/locale/fa.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/fi.ts b/src/locale/fi.ts index dc974ef7233..c44eb207edb 100644 --- a/src/locale/fi.ts +++ b/src/locale/fi.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/fr.ts b/src/locale/fr.ts index 4791616f513..503c98ffd36 100644 --- a/src/locale/fr.ts +++ b/src/locale/fr.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/fr_BE.ts b/src/locale/fr_BE.ts index 42be907bd65..7ac95179bb6 100644 --- a/src/locale/fr_BE.ts +++ b/src/locale/fr_BE.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/fr_CA.ts b/src/locale/fr_CA.ts index 08a63145466..35ffccc16f4 100644 --- a/src/locale/fr_CA.ts +++ b/src/locale/fr_CA.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/fr_CH.ts b/src/locale/fr_CH.ts index f274da9a4d8..fd8ecc4104a 100644 --- a/src/locale/fr_CH.ts +++ b/src/locale/fr_CH.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/ge.ts b/src/locale/ge.ts index bb3989a7c96..e8872a8140e 100644 --- a/src/locale/ge.ts +++ b/src/locale/ge.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/he.ts b/src/locale/he.ts index a61b170fda0..ed634c440ee 100644 --- a/src/locale/he.ts +++ b/src/locale/he.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/hr.ts b/src/locale/hr.ts index 0e348746aeb..9529dfd9bb5 100644 --- a/src/locale/hr.ts +++ b/src/locale/hr.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/hy.ts b/src/locale/hy.ts index debcd66b194..bd65f9a027f 100644 --- a/src/locale/hy.ts +++ b/src/locale/hy.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/id_ID.ts b/src/locale/id_ID.ts index ef19fbe1c89..f306cb45813 100644 --- a/src/locale/id_ID.ts +++ b/src/locale/id_ID.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/it.ts b/src/locale/it.ts index cfd21707fc7..f1816c8744f 100644 --- a/src/locale/it.ts +++ b/src/locale/it.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/ja.ts b/src/locale/ja.ts index 9f9b9f970d7..cc58410f031 100644 --- a/src/locale/ja.ts +++ b/src/locale/ja.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/ko.ts b/src/locale/ko.ts index 254e5d28aae..9b12ebd2bed 100644 --- a/src/locale/ko.ts +++ b/src/locale/ko.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/lv.ts b/src/locale/lv.ts index 95ad139df49..d9ff97827d3 100644 --- a/src/locale/lv.ts +++ b/src/locale/lv.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/mk.ts b/src/locale/mk.ts index aba8a8f69f8..70bc42089c9 100644 --- a/src/locale/mk.ts +++ b/src/locale/mk.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/nb_NO.ts b/src/locale/nb_NO.ts index 44b522b5939..e570db8ddf9 100644 --- a/src/locale/nb_NO.ts +++ b/src/locale/nb_NO.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/ne.ts b/src/locale/ne.ts index 23f45734ce8..d6f3461ad1c 100644 --- a/src/locale/ne.ts +++ b/src/locale/ne.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/nl.ts b/src/locale/nl.ts index dba921bfae3..9358c29bded 100644 --- a/src/locale/nl.ts +++ b/src/locale/nl.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/nl_BE.ts b/src/locale/nl_BE.ts index 8f342af37c5..c0ed1e30ae2 100644 --- a/src/locale/nl_BE.ts +++ b/src/locale/nl_BE.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/pl.ts b/src/locale/pl.ts index bcfcd695d7f..476ed746117 100644 --- a/src/locale/pl.ts +++ b/src/locale/pl.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/pt_BR.ts b/src/locale/pt_BR.ts index 0a3ed5a93b3..7e8bec1596e 100644 --- a/src/locale/pt_BR.ts +++ b/src/locale/pt_BR.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/pt_PT.ts b/src/locale/pt_PT.ts index 0909bb6a6c3..ff3e1c77048 100644 --- a/src/locale/pt_PT.ts +++ b/src/locale/pt_PT.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/ro.ts b/src/locale/ro.ts index 2dce8064a08..908b1a989d6 100644 --- a/src/locale/ro.ts +++ b/src/locale/ro.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/ru.ts b/src/locale/ru.ts index 0768988c815..6b140ba8898 100644 --- a/src/locale/ru.ts +++ b/src/locale/ru.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/sk.ts b/src/locale/sk.ts index b1ba74d1e6d..d97f29bcd37 100644 --- a/src/locale/sk.ts +++ b/src/locale/sk.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/sv.ts b/src/locale/sv.ts index e0a16ba51a6..eddb1806184 100644 --- a/src/locale/sv.ts +++ b/src/locale/sv.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/tr.ts b/src/locale/tr.ts index 4ff2b9a677c..580f7435cec 100644 --- a/src/locale/tr.ts +++ b/src/locale/tr.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/uk.ts b/src/locale/uk.ts index f18bf2ecb3c..e51c61eb3e5 100644 --- a/src/locale/uk.ts +++ b/src/locale/uk.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/ur.ts b/src/locale/ur.ts index f71c0cbdb51..3cfbeade6ef 100644 --- a/src/locale/ur.ts +++ b/src/locale/ur.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/vi.ts b/src/locale/vi.ts index 425029f6fec..2f9a0906fdf 100644 --- a/src/locale/vi.ts +++ b/src/locale/vi.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/zh_CN.ts b/src/locale/zh_CN.ts index c21a96c0fb7..4c8b39681aa 100644 --- a/src/locale/zh_CN.ts +++ b/src/locale/zh_CN.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/zh_TW.ts b/src/locale/zh_TW.ts index cf835784742..24ef462189b 100644 --- a/src/locale/zh_TW.ts +++ b/src/locale/zh_TW.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locale/zu_ZA.ts b/src/locale/zu_ZA.ts index b76a1053eed..1ae6eab7af5 100644 --- a/src/locale/zu_ZA.ts +++ b/src/locale/zu_ZA.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import { Faker } from '..'; diff --git a/src/locales/index.ts b/src/locales/index.ts index 2823960165e..8b61eae6601 100644 --- a/src/locales/index.ts +++ b/src/locales/index.ts @@ -1,6 +1,6 @@ /* * This file is automatically generated. - * Run 'pnpm run generate' to update. + * Run 'pnpm run generate:locales' to update. */ import type { LocaleDefinition } from '..'; From e2b74736bddfc7811fec5ad1c4589663b0d84d7b Mon Sep 17 00:00:00 2001 From: Shinigami Date: Sat, 29 Jan 2022 12:35:28 +0100 Subject: [PATCH 09/10] chore: use const instead of let --- scripts/generateLocales.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generateLocales.ts b/scripts/generateLocales.ts index c855f13bdfb..ae898de9db0 100644 --- a/scripts/generateLocales.ts +++ b/scripts/generateLocales.ts @@ -31,7 +31,7 @@ const autoGeneratedCommentHeader = `/* * Run '${scriptCommand}' to update. */`; -for (let locale of locales) { +for (const locale of locales) { const localeDef: LocaleDefinition = require('../src/locales/' + locale).default; const localeTitle = localeDef.title; From 7a5497b05e0075a57dd971d81312a8e23fc74657 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Sat, 29 Jan 2022 21:45:13 +0100 Subject: [PATCH 10/10] chore: fix lint warnings --- scripts/generateLocales.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/generateLocales.ts b/scripts/generateLocales.ts index ae898de9db0..0d3d2fd285b 100644 --- a/scripts/generateLocales.ts +++ b/scripts/generateLocales.ts @@ -1,5 +1,6 @@ import { readdirSync, readFileSync, writeFileSync } from 'node:fs'; import { resolve } from 'node:path'; +import type { Options } from 'prettier'; import { format } from 'prettier'; import options from '../.prettierrc.cjs'; import type { LocaleDefinition } from '../src'; @@ -16,6 +17,8 @@ const pathDocsApiLocalization = resolve( ); const scriptCommand = 'pnpm run generate:locales'; +const prettierTsOptions: Options = { ...options, parser: 'typescript' }; +const prettierMdOptions: Options = { ...options, parser: 'markdown' }; const locales = readdirSync(pathLocales); locales.splice(locales.indexOf('index.ts'), 1); @@ -32,6 +35,7 @@ const autoGeneratedCommentHeader = `/* */`; for (const locale of locales) { + // eslint-disable-next-line @typescript-eslint/no-var-requires const localeDef: LocaleDefinition = require('../src/locales/' + locale).default; const localeTitle = localeDef.title; @@ -42,7 +46,7 @@ for (const locale of locales) { localizationLocales += `| ${locale} | ${localeTitle} |\n`; // src/locale/.ts - let content: string = ` + let content = ` ${autoGeneratedCommentHeader} import { Faker } from '..'; @@ -61,7 +65,7 @@ for (const locale of locales) { export = faker; `; - content = format(content, { ...options, parser: 'typescript' }); + content = format(content, prettierTsOptions); writeFileSync(resolve(pathLocale, locale + '.ts'), content); } @@ -81,16 +85,13 @@ let indexContent = ` export default locales; `; -indexContent = format(indexContent, { ...options, parser: 'typescript' }); +indexContent = format(indexContent, prettierTsOptions); writeFileSync(pathLocalesIndex, indexContent); // docs/api/localization.md -localizationLocales = format(localizationLocales, { - ...options, - parser: 'markdown', -}); +localizationLocales = format(localizationLocales, prettierMdOptions); let localizationContent = readFileSync(pathDocsApiLocalization, 'utf-8'); localizationContent = localizationContent.replace(