diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/pages/Home.page.vue | 2 | ||||
-rw-r--r-- | src/plugins/i18n.plugin.ts | 24 |
2 files changed, 21 insertions, 5 deletions
diff --git a/src/pages/Home.page.vue b/src/pages/Home.page.vue index 49d90c6..5c7c3c4 100644 --- a/src/pages/Home.page.vue +++ b/src/pages/Home.page.vue @@ -49,7 +49,7 @@ const { t } = useI18n(); </transition> <div v-if="toolStore.newTools.length > 0"> - <n-h3>{{ t('home.categories.newestTools', 'Newest tools') }}</n-h3> + <n-h3>{{ t('home.categories.newestTools') }}</n-h3> <n-grid x-gap="12" y-gap="12" cols="1 400:2 800:3 1200:4 2000:8"> <n-gi v-for="tool in toolStore.newTools" :key="tool.name"> <ToolCard :tool="tool" /> diff --git a/src/plugins/i18n.plugin.ts b/src/plugins/i18n.plugin.ts index c38cdee..8e0b2d3 100644 --- a/src/plugins/i18n.plugin.ts +++ b/src/plugins/i18n.plugin.ts @@ -1,6 +1,22 @@ -import type { App } from 'vue'; +import type { Plugin } from 'vue'; import { createI18n } from 'vue-i18n'; -import messages from '@intlify/unplugin-vue-i18n/messages'; +import baseMessages from '@intlify/unplugin-vue-i18n/messages'; +import _ from 'lodash'; +import { parse as parseYaml } from 'yaml'; + +const i18nFiles = import.meta.glob('../tools/*/locales/**.yml', { as: 'raw' }); + +const messagesByTools = await Promise.all(_.map(i18nFiles, async (fileDescriptor, path) => { + const [, locale] = path.match(/\.\/tools\/.*?\/locales\/(.*)\.ya?ml$/i) ?? []; + const content = parseYaml(await fileDescriptor()); + + return { [locale]: content }; +})); + +const messages = _.merge( + baseMessages, + _.merge({}, ...messagesByTools), +); const i18n = createI18n({ legacy: false, @@ -8,8 +24,8 @@ const i18n = createI18n({ messages, }); -export const i18nPlugin = { - install: (app: App) => { +export const i18nPlugin: Plugin = { + install: (app) => { app.use(i18n); }, }; |