import type en from './locales/en.js'

export type Locale = 'en' | 'zh-CN'

type DeepString<T> = T extends string
  ? string
  : T extends Record<string, unknown>
    ? { [K in keyof T]: DeepString<T[K]> }
    : never

export type Translations = DeepString<typeof en>

type Join<K, P> = K extends string
  ? P extends string
    ? `${K}.${P}`
    : never
  : never

type Paths<T> = T extends string
  ? never
  : {
      [K in keyof T]: T[K] extends string
        ? K
        : T[K] extends Record<string, unknown>
          ? Join<K & string, Paths<T[K]>>
          : never
    }[keyof T]

export type TranslationKey = Paths<Translations>
