diff --git a/src/layouts/tool.layout.vue b/src/layouts/tool.layout.vue index aa808f1c..f3813fb2 100644 --- a/src/layouts/tool.layout.vue +++ b/src/layouts/tool.layout.vue @@ -7,14 +7,17 @@ import BaseLayout from './base.layout.vue'; import FavoriteButton from '@/components/FavoriteButton.vue'; import type { Tool } from '@/tools/tools.types'; +const { t } = useI18n(); + const route = useRoute(); +const i18nKey = computed(() => route.path.trim().replace('/', '')); const head = computed(() => ({ - title: `${route.meta.name} - IT Tools`, + title: `${t(`tools.${i18nKey.value}.title`)} - IT Tools`, meta: [ { name: 'description', - content: route.meta?.description as string, + content: t(`tools.${i18nKey.value}.description`), }, { name: 'keywords', @@ -23,9 +26,7 @@ const head = computed(() => ({ ], })); useHead(head); -const { t } = useI18n(); -const i18nKey = computed(() => route.path.trim().replace('/', '')); const toolTitle = computed(() => t(`tools.${i18nKey.value}.title`, String(route.meta.name))); const toolDescription = computed(() => t(`tools.${i18nKey.value}.description`, String(route.meta.description))); diff --git a/src/tools/base64-file-converter/index.ts b/src/tools/base64-file-converter/index.ts index 4d94402b..d4ee5396 100644 --- a/src/tools/base64-file-converter/index.ts +++ b/src/tools/base64-file-converter/index.ts @@ -1,11 +1,11 @@ import { FileDigit } from '@vicons/tabler'; import { defineTool } from '../tool'; -import { translate } from '@/plugins/i18n.plugin'; +import { translate as t } from '@/plugins/i18n.plugin'; export const tool = defineTool({ - name: translate('tools.base64-file-converter.title'), + name: t('tools.base64-file-converter.title'), path: '/base64-file-converter', - description: translate('tools.base64-file-converter.description'), + description: t('tools.base64-file-converter.description'), keywords: ['base64', 'converter', 'upload', 'image', 'file', 'conversion', 'web', 'data', 'format'], component: () => import('./base64-file-converter.vue'), icon: FileDigit, diff --git a/src/tools/base64-file-converter/locales/en.yml b/src/tools/base64-file-converter/locales/en.yml index c370afa1..c29c44da 100644 --- a/src/tools/base64-file-converter/locales/en.yml +++ b/src/tools/base64-file-converter/locales/en.yml @@ -1,18 +1,18 @@ tools: base64-file-converter: - title: Base64 文件转换器 - description: 将字符串、文件或图像转换为其 base64 表示形式。 + title: Base64 file converter + description: Convert string, files or images into a it's base64 representation. base64ToFile: - title: Base64 转文件 - placeholder: 在此处放置您的 base64 文件字符串... + title: Base64 to file + placeholder: Put your base64 file string here... fileToBase64: - title: 文件转 base64 - placeholder: base64 文件将在此处 - uploadTip: 拖放文件到此处,或点击选择文件 + title: File to base64 + placeholder: File in base64 will be here + uploadTip: Drag and drop a file here, or click to select a file buttons: - downloadFile: 下载文件 - copy: 复制 + downloadFile: Download file + copy: Copy - copied: 已复制 base64 字符串到剪贴板 - invalidMessage: 无效的 base 64 字符串 \ No newline at end of file + copied: Base64 string copied to the clipboard + invalidMessage: Invalid base 64 string \ No newline at end of file diff --git a/src/tools/base64-file-converter/locales/zh.yml b/src/tools/base64-file-converter/locales/zh.yml index e69de29b..d0269fd8 100644 --- a/src/tools/base64-file-converter/locales/zh.yml +++ b/src/tools/base64-file-converter/locales/zh.yml @@ -0,0 +1,18 @@ +tools: + base64-file-converter: + title: Base64 文件转换器 + description: 将字符串、文件或图像转换为其 base64 表示形式。 + + base64ToFile: + title: Base64 转文件 + placeholder: 在此处放置您的 base64 文件字符串... + fileToBase64: + title: 文件转 base64 + placeholder: base64 文件将在此处 + uploadTip: 拖放文件到此处,或点击选择文件 + buttons: + downloadFile: 下载文件 + copy: 复制 + + copied: 已复制 base64 字符串到剪贴板 + invalidMessage: 无效的 base 64 字符串 diff --git a/src/tools/base64-string-converter/index.ts b/src/tools/base64-string-converter/index.ts index e51d54df..63cfadeb 100644 --- a/src/tools/base64-string-converter/index.ts +++ b/src/tools/base64-string-converter/index.ts @@ -1,11 +1,11 @@ import { FileDigit } from '@vicons/tabler'; import { defineTool } from '../tool'; -import { translate } from '@/plugins/i18n.plugin'; +import { translate as t } from '@/plugins/i18n.plugin'; export const tool = defineTool({ - name: translate('tools.base64-string-converter.title'), + name: t('tools.base64-string-converter.title'), path: '/base64-string-converter', - description: translate('tools.base64-string-converter.description'), + description: t('tools.base64-string-converter.description'), keywords: ['base64', 'converter', 'conversion', 'web', 'data', 'format', 'atob', 'btoa'], component: () => import('./base64-string-converter.vue'), icon: FileDigit, diff --git a/src/tools/basic-auth-generator/basic-auth-generator.vue b/src/tools/basic-auth-generator/basic-auth-generator.vue index a8946127..14fcfe23 100644 --- a/src/tools/basic-auth-generator/basic-auth-generator.vue +++ b/src/tools/basic-auth-generator/basic-auth-generator.vue @@ -2,20 +2,21 @@ import { useCopy } from '@/composable/copy'; import { textToBase64 } from '@/utils/base64'; +const { t } = useI18n(); const username = ref(''); const password = ref(''); const header = computed(() => `Authorization: Basic ${textToBase64(`${username.value}:${password.value}`)}`); -const { copy } = useCopy({ source: header, text: 'Header copied to the clipboard' }); +const { copy } = useCopy({ source: header, text: t('tools.basic-auth-generator.copied') });