From 2bcd24e8722097b7a953d026374e45b62c5e8f41 Mon Sep 17 00:00:00 2001 From: Lukas Hass Date: Sun, 26 Mar 2023 18:21:59 +0200 Subject: [PATCH 1/2] feat(unplugin-vue-i18n): provide list of supported locales --- packages/unplugin-vue-i18n/src/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/unplugin-vue-i18n/src/index.ts b/packages/unplugin-vue-i18n/src/index.ts index 0a03893..d30bff3 100644 --- a/packages/unplugin-vue-i18n/src/index.ts +++ b/packages/unplugin-vue-i18n/src/index.ts @@ -675,6 +675,7 @@ async function generateBundleResources( } ) { const codes = [] + const locales = [] for (const res of resources) { debug(`${res} bundle loading ...`) @@ -700,12 +701,14 @@ async function generateBundleResources( debug('generated code', code) codes.push(`${JSON.stringify(name)}: ${code}`) + locales.push(name) } } return `export default { ${codes.join(`,\n`)} -}` +} +export const SUPPORTED_LOCALES = ${JSON.stringify(locales)}` } async function getCode( From 1de105ec6cbc837cfc3df39422111a844b412aa1 Mon Sep 17 00:00:00 2001 From: Lukas Hass Date: Sun, 17 Dec 2023 22:14:26 +0100 Subject: [PATCH 2/2] fix brace --- packages/unplugin-vue-i18n/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/unplugin-vue-i18n/src/index.ts b/packages/unplugin-vue-i18n/src/index.ts index 6cfb984..037bd63 100644 --- a/packages/unplugin-vue-i18n/src/index.ts +++ b/packages/unplugin-vue-i18n/src/index.ts @@ -817,7 +817,7 @@ const mergeDeep = (target, ...sources) => { export default mergeDeep({}, ${codes.map(code => `{${code}}`).join(',\n')} -} +); export const SUPPORTED_LOCALES = ${JSON.stringify(locales)};` }