import {DpValue, I18N} from 'tuya-panel-kit'
import Strings from './strings'

type Key = keyof typeof Strings.en

function getLang(key: Key, defaultString?: string): string {
  // @ts-ignore
  return new I18N(Strings).getLang(key, defaultString)
}

function getDpLang(code: string, value?: DpValue): string {
  return new I18N(Strings).getDpLang(code, value)
}

function formatString(key: string, values: string[]): string {
  return new I18N(Strings).formatString(key, ...values)
}

function formatValue(key: Key, ...values: string[]): string {
  // @ts-ignore
  return new I18N(Strings).formatValue(key, ...values)
}

function getDpName(code: string, defaultName?: string): string {
  return new I18N(Strings).getDpName(code, defaultName)
}

const I18n = {
  getLang,
  getDpLang,
  formatString,
  formatValue,
  getDpName,
}

export default I18n
export { Key as I18nKey }
