Closed addlistener closed 3 months ago
We have a utility function defineLocale
that comes from createI18n
that you might be able to use here - though it's known that it is not perfect:
// locales/index.ts
export const { defineLocale, ... } = createI18n(...)
// locales/fr.ts
export default defineLocale({
hello: 'world',
})
TS2353: Object literal may only specify known properties, and '"product"' does not exist in type '{ "product.slogan": LocaleValue; "dash.leftnav.sites": LocaleValue; "dash.leftnav.account": LocaleValue; "dash.sites.Untitled": LocaleValue; ... 102 more ...; "spinner.Uploading assets": LocaleValue; }'.
This is what I get. "fr" is like the same structure with "en" but missing some property
I found this is already resolved when you enforce strict type check like tsc --noEmit
before building. LGTM!
I want to check no newly added i18n messages are missing in all locale files before publish.
In the typescript sense, aka, ensure all the locale files are of the same type. ( And I really like the idea of leveraging typescript to do the type-lifting. Kudos to @QuiiBz 💯 )
typeof en
results{ a: 1 } as const
will also consider the 1 as enum. and it's not the same astypeof fr
And I don't want to do
{ "a": 1 as number } as const
because there's a lot of unnecessary typing.