Closed warflash closed 4 months ago
const { locale, locales } = useI18n()
Currently locale is typed as string and locales is string[]. The suggestion is to use tighter types like locale -> "en" | "de" in the case of a config like:
locale
string
locales
string[]
locale -> "en" | "de"
i18n: { locales: [ { code: "en", iso: "en-US", file: "en.json" }, { code: "de", iso: "de-DE", file: "de.json" }, ], },
That would make type safe access to typed records possible. e.g.
const MIN_SEARCH_LEN_BY_LOCALE = { en: 3, de: 3, ko: 1, } const { locale, locales } = useI18n() const minLen = MIN_SEARCH_LEN_BY_LOCALE[locale]
Should be resolved by #3025, which will be included in v9
Thanks! 💚
Describe the feature
const { locale, locales } = useI18n()
Currently
locale
is typed asstring
andlocales
isstring[]
. The suggestion is to use tighter types likelocale -> "en" | "de"
in the case of a config like:That would make type safe access to typed records possible. e.g.
Additional information
Final checks