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AP,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":""}
|