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C,KAAD,EAAgB,KAAhB,EAAiC;AACxE,uBAAO,OAAO,OAAO,CAAC,KAAR,CAAP,CAAP;AACD,aAFM,CAAP;AAGD;AAbI,KAAP;AAeD","sourcesContent":["import en from '../../../locale/en'\nimport { getObjectValueByPath } from '../../../util/helpers'\nimport { consoleError, consoleWarn } from '../../../util/console'\nimport { VuetifyUseOptions as Options } from 'vuetify/types'\nimport { VuetifyLanguage, VuetifyLocale } from 'vuetify/types/lang'\n\nconst LANG_PREFIX = '$vuetify.'\nconst fallback = Symbol('Lang fallback')\n\nfunction getTranslation (locale: VuetifyLocale, key: string, usingFallback = false): string {\n const shortKey = key.replace(LANG_PREFIX, '')\n let translation = getObjectValueByPath(locale, shortKey, fallback) as string | typeof fallback\n\n if (translation === fallback) {\n if (usingFallback) {\n consoleError(`Translation key \"${shortKey}\" not found in fallback`)\n translation = key\n } else {\n consoleWarn(`Translation key \"${shortKey}\" not found, falling back to default`)\n translation = getTranslation(en, key, true)\n }\n }\n\n return translation\n}\n\nexport default function lang (config: Options['lang'] = {}): VuetifyLanguage {\n return {\n locales: Object.assign({ en }, config.locales),\n current: config.current || 'en',\n t (key, ...params) {\n if (!key.startsWith(LANG_PREFIX)) return key\n\n if (config.t) return config.t(key, ...params)\n\n const translation = getTranslation(this.locales[this.current], key)\n\n return translation.replace(/\\{(\\d+)\\}/g, (match: string, index: string) => {\n return String(params[+index])\n })\n }\n }\n}\n"],"sourceRoot":""}
|