acdr-ui/dist/dev/mp-weixin/locale/index.js.map

1 line
1.4 KiB
Plaintext
Raw Normal View History

2024-09-19 07:20:14 +08:00
{"version":3,"file":"index.js","sources":["../../../../src/locale/index.ts"],"sourcesContent":["import { createI18n } from 'vue-i18n'\r\n\r\nimport en from './en.json'\r\nimport zhHans from './zh-Hans.json' // 简体中文\r\n\r\nconst messages = {\r\n en,\r\n 'zh-Hans': zhHans, // key 不能乱写,查看截图 screenshots/i18n.png\r\n}\r\n\r\nconst i18n = createI18n({\r\n locale: uni.getLocale(), // 获取已设置的语言fallback 语言需要再 manifest.config.ts 中设置\r\n messages,\r\n})\r\n\r\nconsole.log(uni.getLocale())\r\nconsole.log(i18n.global.locale)\r\n\r\n/**\r\n * 非 vue 文件使用这个方法\r\n * @param { string } localeKey 多语言的keyeg: \"app.name\"\r\n */\r\nexport const translate = (localeKey: string) => {\r\n if (!localeKey) {\r\n console.error(`[i18n] Function translate(), localeKey param is required`)\r\n return ''\r\n }\r\n const locale = uni.getLocale()\r\n console.log('locale:', locale)\r\n\r\n const message = messages[locale]\r\n if (Object.keys(message).includes(localeKey)) {\r\n return message[localeKey]\r\n }\r\n return localeKey\r\n}\r\nexport default i18n\r\n"],"names":["createI18n","uni"],"mappings":";;;;;;;;;;;;;;;;AAKA,MAAM,WAAW;AAAA,EACf;AAAA,EACA,WAAW;AAAA;AACb;AAEA,MAAM,OAAOA,cAAAA,WAAW;AAAA,EACtB,QAAQC,oBAAI,UAAU;AAAA;AAAA,EACtB;AACF,CAAC;AAED,QAAQ,IAAIA,cAAAA,MAAI,UAAA,CAAW;AAC3B,QAAQ,IAAI,KAAK,OAAO,MAAM;;"}