fix: Missing Locale Dates (#6116)

This commit is contained in:
Michael Genson
2025-09-08 04:47:37 -05:00
committed by GitHub
parent 72b47a1103
commit b2f8d63f33
2 changed files with 107 additions and 49 deletions

View File

@@ -173,9 +173,25 @@ the code generation ID is hardcoded into the script and required in the nuxt con
def inject_nuxt_values(): def inject_nuxt_values():
all_date_locales = [ datetime_files = list(datetime_dir.glob("*.json"))
f'"{match.stem}": () => import("./lang/dateTimeFormats/{match.name}"),' for match in datetime_dir.glob("*.json") datetime_files.sort()
]
datetime_imports = []
datetime_object_entries = []
for match in datetime_files:
# Convert locale name to camelCase variable name (e.g., "en-US" -> "enUS")
var_name = match.stem.replace("-", "")
# Generate import statement
import_line = f'import * as {var_name} from "./lang/dateTimeFormats/{match.name}";'
datetime_imports.append(import_line)
# Generate object entry
object_entry = f' "{match.stem}": {var_name},'
datetime_object_entries.append(object_entry)
all_date_locales = datetime_imports + ["", "const datetimeFormats = {"] + datetime_object_entries + ["};"]
all_langs = [] all_langs = []
for match in locales_dir.glob("*.json"): for match in locales_dir.glob("*.json"):
@@ -186,7 +202,6 @@ def inject_nuxt_values():
all_langs.append(lang_string) all_langs.append(lang_string)
all_langs.sort() all_langs.sort()
all_date_locales.sort()
log.debug(f"injecting locales into nuxt config -> {nuxt_config}") log.debug(f"injecting locales into nuxt config -> {nuxt_config}")
inject_inline(nuxt_config, CodeKeys.nuxt_local_messages, all_langs) inject_inline(nuxt_config, CodeKeys.nuxt_local_messages, all_langs)

View File

@@ -1,56 +1,99 @@
// CODE_GEN_ID: DATE_LOCALES
import * as afZA from "./lang/dateTimeFormats/af-ZA.json";
import * as arSA from "./lang/dateTimeFormats/ar-SA.json";
import * as bgBG from "./lang/dateTimeFormats/bg-BG.json";
import * as caES from "./lang/dateTimeFormats/ca-ES.json";
import * as csCZ from "./lang/dateTimeFormats/cs-CZ.json";
import * as daDK from "./lang/dateTimeFormats/da-DK.json";
import * as deDE from "./lang/dateTimeFormats/de-DE.json";
import * as elGR from "./lang/dateTimeFormats/el-GR.json";
import * as enGB from "./lang/dateTimeFormats/en-GB.json";
import * as enUS from "./lang/dateTimeFormats/en-US.json";
import * as esES from "./lang/dateTimeFormats/es-ES.json";
import * as etEE from "./lang/dateTimeFormats/et-EE.json";
import * as fiFI from "./lang/dateTimeFormats/fi-FI.json";
import * as frBE from "./lang/dateTimeFormats/fr-BE.json";
import * as frCA from "./lang/dateTimeFormats/fr-CA.json";
import * as frFR from "./lang/dateTimeFormats/fr-FR.json";
import * as glES from "./lang/dateTimeFormats/gl-ES.json";
import * as heIL from "./lang/dateTimeFormats/he-IL.json";
import * as hrHR from "./lang/dateTimeFormats/hr-HR.json";
import * as huHU from "./lang/dateTimeFormats/hu-HU.json";
import * as isIS from "./lang/dateTimeFormats/is-IS.json";
import * as itIT from "./lang/dateTimeFormats/it-IT.json";
import * as jaJP from "./lang/dateTimeFormats/ja-JP.json";
import * as koKR from "./lang/dateTimeFormats/ko-KR.json";
import * as ltLT from "./lang/dateTimeFormats/lt-LT.json";
import * as lvLV from "./lang/dateTimeFormats/lv-LV.json";
import * as nlNL from "./lang/dateTimeFormats/nl-NL.json";
import * as noNO from "./lang/dateTimeFormats/no-NO.json";
import * as plPL from "./lang/dateTimeFormats/pl-PL.json";
import * as ptBR from "./lang/dateTimeFormats/pt-BR.json";
import * as ptPT from "./lang/dateTimeFormats/pt-PT.json";
import * as roRO from "./lang/dateTimeFormats/ro-RO.json";
import * as ruRU from "./lang/dateTimeFormats/ru-RU.json";
import * as skSK from "./lang/dateTimeFormats/sk-SK.json";
import * as slSI from "./lang/dateTimeFormats/sl-SI.json";
import * as srSP from "./lang/dateTimeFormats/sr-SP.json";
import * as svSE from "./lang/dateTimeFormats/sv-SE.json";
import * as trTR from "./lang/dateTimeFormats/tr-TR.json";
import * as ukUA from "./lang/dateTimeFormats/uk-UA.json";
import * as viVN from "./lang/dateTimeFormats/vi-VN.json";
import * as zhCN from "./lang/dateTimeFormats/zh-CN.json";
import * as zhTW from "./lang/dateTimeFormats/zh-TW.json";
const datetimeFormats = { const datetimeFormats = {
// CODE_GEN_ID: DATE_LOCALES "af-ZA": afZA,
"af-ZA": () => import("./lang/dateTimeFormats/af-ZA.json"), "ar-SA": arSA,
"ar-SA": () => import("./lang/dateTimeFormats/ar-SA.json"), "bg-BG": bgBG,
"bg-BG": () => import("./lang/dateTimeFormats/bg-BG.json"), "ca-ES": caES,
"ca-ES": () => import("./lang/dateTimeFormats/ca-ES.json"), "cs-CZ": csCZ,
"cs-CZ": () => import("./lang/dateTimeFormats/cs-CZ.json"), "da-DK": daDK,
"da-DK": () => import("./lang/dateTimeFormats/da-DK.json"), "de-DE": deDE,
"de-DE": () => import("./lang/dateTimeFormats/de-DE.json"), "el-GR": elGR,
"el-GR": () => import("./lang/dateTimeFormats/el-GR.json"), "en-GB": enGB,
"en-GB": () => import("./lang/dateTimeFormats/en-GB.json"), "en-US": enUS,
"en-US": () => import("./lang/dateTimeFormats/en-US.json"), "es-ES": esES,
"es-ES": () => import("./lang/dateTimeFormats/es-ES.json"), "et-EE": etEE,
"et-EE": () => import("./lang/dateTimeFormats/et-EE.json"), "fi-FI": fiFI,
"fi-FI": () => import("./lang/dateTimeFormats/fi-FI.json"), "fr-BE": frBE,
"fr-BE": () => import("./lang/dateTimeFormats/fr-BE.json"), "fr-CA": frCA,
"fr-CA": () => import("./lang/dateTimeFormats/fr-CA.json"), "fr-FR": frFR,
"fr-FR": () => import("./lang/dateTimeFormats/fr-FR.json"), "gl-ES": glES,
"gl-ES": () => import("./lang/dateTimeFormats/gl-ES.json"), "he-IL": heIL,
"he-IL": () => import("./lang/dateTimeFormats/he-IL.json"), "hr-HR": hrHR,
"hr-HR": () => import("./lang/dateTimeFormats/hr-HR.json"), "hu-HU": huHU,
"hu-HU": () => import("./lang/dateTimeFormats/hu-HU.json"), "is-IS": isIS,
"is-IS": () => import("./lang/dateTimeFormats/is-IS.json"), "it-IT": itIT,
"it-IT": () => import("./lang/dateTimeFormats/it-IT.json"), "ja-JP": jaJP,
"ja-JP": () => import("./lang/dateTimeFormats/ja-JP.json"), "ko-KR": koKR,
"ko-KR": () => import("./lang/dateTimeFormats/ko-KR.json"), "lt-LT": ltLT,
"lt-LT": () => import("./lang/dateTimeFormats/lt-LT.json"), "lv-LV": lvLV,
"lv-LV": () => import("./lang/dateTimeFormats/lv-LV.json"), "nl-NL": nlNL,
"nl-NL": () => import("./lang/dateTimeFormats/nl-NL.json"), "no-NO": noNO,
"no-NO": () => import("./lang/dateTimeFormats/no-NO.json"), "pl-PL": plPL,
"pl-PL": () => import("./lang/dateTimeFormats/pl-PL.json"), "pt-BR": ptBR,
"pt-BR": () => import("./lang/dateTimeFormats/pt-BR.json"), "pt-PT": ptPT,
"pt-PT": () => import("./lang/dateTimeFormats/pt-PT.json"), "ro-RO": roRO,
"ro-RO": () => import("./lang/dateTimeFormats/ro-RO.json"), "ru-RU": ruRU,
"ru-RU": () => import("./lang/dateTimeFormats/ru-RU.json"), "sk-SK": skSK,
"sk-SK": () => import("./lang/dateTimeFormats/sk-SK.json"), "sl-SI": slSI,
"sl-SI": () => import("./lang/dateTimeFormats/sl-SI.json"), "sr-SP": srSP,
"sr-SP": () => import("./lang/dateTimeFormats/sr-SP.json"), "sv-SE": svSE,
"sv-SE": () => import("./lang/dateTimeFormats/sv-SE.json"), "tr-TR": trTR,
"tr-TR": () => import("./lang/dateTimeFormats/tr-TR.json"), "uk-UA": ukUA,
"uk-UA": () => import("./lang/dateTimeFormats/uk-UA.json"), "vi-VN": viVN,
"vi-VN": () => import("./lang/dateTimeFormats/vi-VN.json"), "zh-CN": zhCN,
"zh-CN": () => import("./lang/dateTimeFormats/zh-CN.json"), "zh-TW": zhTW,
"zh-TW": () => import("./lang/dateTimeFormats/zh-TW.json"),
// END: DATE_LOCALES
}; };
// END: DATE_LOCALES
export default defineI18nConfig(() => { export default defineI18nConfig(() => {
return { return {
legacy: false, legacy: false,
locale: "en-US", locale: "en-US",
availableLocales: Object.keys(datetimeFormats), availableLocales: Object.keys(datetimeFormats),
datetimeFormats, datetimeFormats: datetimeFormats as any,
fallbackLocale: "en-US", fallbackLocale: "en-US",
fallbackWarn: true, fallbackWarn: true,
}; };