feat(package/locale): update for parity with lua

Support for nested locales (flattening) and getLocale function.
This commit is contained in:
Linden
2024-01-14 12:34:13 +11:00
parent 6da661bef3
commit 2ad3503985
2 changed files with 38 additions and 4 deletions

View File

@@ -1 +1,8 @@
export * from './resource';
// https://www.raygesualdo.com/posts/flattening-object-keys-with-typescript-types/
export type FlattenObjectKeys<T extends Record<string, unknown>, Key = keyof T> = Key extends string
? T[Key] extends Record<string, unknown>
? `${Key}.${FlattenObjectKeys<T[Key]>}`
: `${Key}`
: never;