feat(i18n): add internationalization support

This commit introduces internationalization (i18n) support by integrating the `@nuxtjs/i18n` module. It configures English (en) and
Simplified Chinese (zh-CN) locales, adds a language selector to the header, and internationalizes the index page content using
translation files.
This commit is contained in:
xiaomai
2025-11-04 10:47:06 +08:00
parent 778f32b617
commit dccbe7599f
9 changed files with 101 additions and 2 deletions

2
.gitignore vendored
View File

@@ -22,3 +22,5 @@ logs
.env .env
.env.* .env.*
!.env.example !.env.example
repomix-output.xml

4
.repomixignore Normal file
View File

@@ -0,0 +1,4 @@
# Add patterns to ignore here, one per line
# Example:
# *.log
# tmp/

7
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,7 @@
{
"i18n-ally.localesPaths": ["i18n/locales"],
"i18n-ally.enabledFrameworks": [
"vue"
],
"i18n-ally.keystyle": "nested"
}

View File

@@ -1,6 +1,19 @@
<template> <template>
<UPage> <UPage>
<UPageSection title="Trusted by"> <UHeader>
<template #title> Tootaio Studio </template>
<template #right>
<ULocaleSelect
:model-value="locale"
:locales="[en, zh_cn]"
@update:model-value="(v) => setLocale(v as 'en' | 'zh-CN')"
/>
</template>
</UHeader>
<UPageSection
title="Trusted by"
:description="$t('index.trustedBy', { count: 10000 })"
>
<UMarquee> <UMarquee>
<img <img
v-for="logo in trustedBy" v-for="logo in trustedBy"
@@ -15,6 +28,9 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { en, zh_cn } from "@nuxt/ui/locale";
const { locale, setLocale } = useI18n();
const trustedBy = ref([ const trustedBy = ref([
{ src: "/index/trusted-by/logoipsum-284.svg", alt: "Logo Ipsum" }, { src: "/index/trusted-by/logoipsum-284.svg", alt: "Logo Ipsum" },
{ src: "/index/trusted-by/logoipsum-338.svg", alt: "Logo Ipsum" }, { src: "/index/trusted-by/logoipsum-338.svg", alt: "Logo Ipsum" },

View File

@@ -0,0 +1,5 @@
{
"index": {
"trustedBy": "Trusted by over {count} users worldwide"
}
}

View File

@@ -0,0 +1,5 @@
{
"index": {
"trustedBy": "全球有超过 {count} 用户信赖"
}
}

View File

@@ -2,6 +2,23 @@
export default defineNuxtConfig({ export default defineNuxtConfig({
compatibilityDate: "2025-07-15", compatibilityDate: "2025-07-15",
devtools: { enabled: true }, devtools: { enabled: true },
modules: ["@nuxt/content", "@nuxt/ui", "@nuxt/eslint"], modules: ["@nuxt/content", "@nuxt/ui", "@nuxt/eslint", "@nuxtjs/i18n"],
css: ["@/assets/css/main.css"], css: ["@/assets/css/main.css"],
i18n: {
defaultLocale: "en",
locales: [
{
code: "en",
iso: "en-US",
name: "English",
files: ["en-US/index.json"],
},
{
code: "zh-CN",
iso: "zh-CN",
name: "简体中文",
files: ["zh-CN/index.json"],
},
],
},
}); });

View File

@@ -13,6 +13,7 @@
"@nuxt/content": "3.8.0", "@nuxt/content": "3.8.0",
"@nuxt/eslint": "1.10.0", "@nuxt/eslint": "1.10.0",
"@nuxt/ui": "4.1.0", "@nuxt/ui": "4.1.0",
"@nuxtjs/i18n": "10.2.0",
"better-sqlite3": "^12.4.1", "better-sqlite3": "^12.4.1",
"eslint": "^9.39.0", "eslint": "^9.39.0",
"nuxt": "^4.2.0", "nuxt": "^4.2.0",

42
repomix.config.json Normal file
View File

@@ -0,0 +1,42 @@
{
"$schema": "https://repomix.com/schemas/latest/schema.json",
"input": {
"maxFileSize": 52428800
},
"output": {
"filePath": "repomix-output.xml",
"style": "xml",
"parsableStyle": false,
"fileSummary": true,
"directoryStructure": true,
"files": true,
"removeComments": false,
"removeEmptyLines": false,
"compress": false,
"topFilesLength": 5,
"showLineNumbers": false,
"truncateBase64": false,
"copyToClipboard": false,
"includeFullDirectoryStructure": false,
"tokenCountTree": false,
"git": {
"sortByChanges": true,
"sortByChangesMaxCommits": 100,
"includeDiffs": false,
"includeLogs": false,
"includeLogsCount": 50
}
},
"include": ["pages/index.vue", "i18n/locales/**/*.json", "nuxt.config.ts"],
"ignore": {
"useGitignore": true,
"useDefaultPatterns": true,
"customPatterns": []
},
"security": {
"enableSecurityCheck": true
},
"tokenCount": {
"encoding": "o200k_base"
}
}