1 |
- {"version":3,"file":"vue-i18n.mjs","names":["useProxiedModel","watch","useProvided","props","prop","provided","internal","value","v","createProvideFunction","data","current","fallback","messages","i18n","useI18n","locale","fallbackLocale","useScope","legacy","inheritLocale","name","t","key","_len","arguments","length","params","Array","_key","n","provide","createVueI18nAdapter","_ref","global","_len2","_key2"],"sources":["../../../src/locale/adapters/vue-i18n.ts"],"sourcesContent":["// Composables\nimport { useProxiedModel } from '@/composables/proxiedModel'\n\n// Utilities\nimport { watch } from 'vue'\n\n// Types\nimport type { Ref } from 'vue'\nimport type { I18n, useI18n } from 'vue-i18n'\nimport type { LocaleInstance, LocaleMessages, LocaleOptions } from '@/composables/locale'\n\ntype VueI18nAdapterParams = {\n i18n: I18n<any, {}, {}, string, false>\n useI18n: typeof useI18n\n}\n\nfunction useProvided <T> (props: any, prop: string, provided: Ref<T>) {\n const internal = useProxiedModel(props, prop)\n\n internal.value = props[prop] ?? provided.value\n\n watch(provided, v => {\n if (props[prop] == null) {\n internal.value = v\n }\n })\n\n return internal as Ref<T>\n}\n\nfunction createProvideFunction (data: {\n current: Ref<string>\n fallback: Ref<string>\n messages: Ref<LocaleMessages>\n useI18n: typeof useI18n\n}) {\n return (props: LocaleOptions): LocaleInstance => {\n const current = useProvided(props, 'locale', data.current)\n const fallback = useProvided(props, 'fallback', data.fallback)\n const messages = useProvided(props, 'messages', data.messages)\n\n const i18n = data.useI18n({\n locale: current.value,\n fallbackLocale: fallback.value,\n messages: messages.value as any,\n useScope: 'local',\n legacy: false,\n inheritLocale: false,\n })\n\n watch(current, v => {\n i18n.locale.value = v\n })\n\n return {\n name: 'vue-i18n',\n current,\n fallback,\n messages,\n t: (key: string, ...params: unknown[]) => i18n.t(key, params),\n n: i18n.n,\n provide: createProvideFunction({ current, fallback, messages, useI18n: data.useI18n }),\n }\n }\n}\n\nexport function createVueI18nAdapter ({ i18n, useI18n }: VueI18nAdapterParams): LocaleInstance {\n const current = i18n.global.locale\n const fallback = i18n.global.fallbackLocale as Ref<any>\n const messages = i18n.global.messages\n\n return {\n name: 'vue-i18n',\n current,\n fallback,\n messages,\n // @ts-expect-error Type instantiation is excessively deep and possibly infinite\n t: (key: string, ...params: unknown[]) => i18n.global.t(key, params),\n n: i18n.global.n,\n provide: createProvideFunction({ current, fallback, messages, useI18n }),\n }\n}\n"],"mappings":"AAAA;AAAA,SACSA,eAAe,8CAExB;AACA,SAASC,KAAK,QAAQ,KAAK;;AAE3B;;AAUA,SAASC,WAAWA,CAAMC,KAAU,EAAEC,IAAY,EAAEC,QAAgB,EAAE;EACpE,MAAMC,QAAQ,GAAGN,eAAe,CAACG,KAAK,EAAEC,IAAI,CAAC;EAE7CE,QAAQ,CAACC,KAAK,GAAGJ,KAAK,CAACC,IAAI,CAAC,IAAIC,QAAQ,CAACE,KAAK;EAE9CN,KAAK,CAACI,QAAQ,EAAEG,CAAC,IAAI;IACnB,IAAIL,KAAK,CAACC,IAAI,CAAC,IAAI,IAAI,EAAE;MACvBE,QAAQ,CAACC,KAAK,GAAGC,CAAC;IACpB;EACF,CAAC,CAAC;EAEF,OAAOF,QAAQ;AACjB;AAEA,SAASG,qBAAqBA,CAAEC,IAK/B,EAAE;EACD,OAAQP,KAAoB,IAAqB;IAC/C,MAAMQ,OAAO,GAAGT,WAAW,CAACC,KAAK,EAAE,QAAQ,EAAEO,IAAI,CAACC,OAAO,CAAC;IAC1D,MAAMC,QAAQ,GAAGV,WAAW,CAACC,KAAK,EAAE,UAAU,EAAEO,IAAI,CAACE,QAAQ,CAAC;IAC9D,MAAMC,QAAQ,GAAGX,WAAW,CAACC,KAAK,EAAE,UAAU,EAAEO,IAAI,CAACG,QAAQ,CAAC;IAE9D,MAAMC,IAAI,GAAGJ,IAAI,CAACK,OAAO,CAAC;MACxBC,MAAM,EAAEL,OAAO,CAACJ,KAAK;MACrBU,cAAc,EAAEL,QAAQ,CAACL,KAAK;MAC9BM,QAAQ,EAAEA,QAAQ,CAACN,KAAY;MAC/BW,QAAQ,EAAE,OAAO;MAC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