diff --git a/.github/scripts/mobile_smoke.py b/.github/scripts/mobile_smoke.py index 0a1b1fd1f..88c3955d0 100644 --- a/.github/scripts/mobile_smoke.py +++ b/.github/scripts/mobile_smoke.py @@ -29,6 +29,8 @@ 'email': 'mobile-ci@example.test', 'createTime': '2026-01-01T00:00:00Z', 'timeZone': 'America/New_York', + 'locale': 'en-US', + 'localeRevision': '0', } @@ -50,7 +52,12 @@ async def api(route: Route) -> None: """ request = route.request path = urlparse(request.url).path.removeprefix('/dev-api') - headers = {'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': '*'} + headers = { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Headers': '*', + 'Access-Control-Expose-Headers': 'Content-Language', + 'Content-Language': request.headers.get('accept-language', 'zh-CN'), + } if request.method == 'OPTIONS': await route.fulfill(status=204, headers=headers) return @@ -60,6 +67,7 @@ async def api(route: Route) -> None: 'method': request.method, 'authorization': request.headers.get('authorization'), 'timezone': request.headers.get('x-timezone'), + 'locale': request.headers.get('accept-language'), } ) payload: dict[str, Any] @@ -135,6 +143,21 @@ async def check_login_styles(framework: str, page: Page, login_button: Locator) return styles +def check_profile_requests(observed: list[dict[str, Any]]) -> None: + """ + 验证账号恢复后的认证、时区、语言与初始化请求头。 + + :param observed: 实际发出的 API 请求记录 + :return: None + """ + profile_requests = [request for request in observed if request['path'] == '/system/user/profile'] + assert profile_requests, '个人资料页未发送真实 API 请求' + assert all(request['authorization'] == f'Bearer {TOKEN}' for request in profile_requests) + assert all(request['timezone'] == 'America/New_York' for request in profile_requests) + assert all(request['locale'] == 'en-US' for request in profile_requests) + assert all(request['locale'] in {'zh-CN', 'en-US'} for request in observed) + + async def run_smoke(framework: str, base_url: str, output: Path) -> None: """ 使用真实 H5 构建验证登录、持久化身份和个人资料页。 @@ -165,7 +188,7 @@ async def run_smoke(framework: str, base_url: str, output: Path) -> None: try: await page.goto(f'{base_url}/#/pages/login') await expect(page.locator('input[type="text"]')).to_be_visible(timeout=30000) - await expect(page.locator('input')).to_have_count(2, timeout=15000) + await expect(page.locator('input:visible')).to_have_count(2, timeout=15000) button = page.get_by_role('button') if framework == 'react' else page.locator('uni-button') login_button = button.filter(has_text=re.compile(r'登\s*录')) login_styles = await check_login_styles(framework, page, login_button) @@ -176,11 +199,15 @@ async def run_smoke(framework: str, base_url: str, output: Path) -> None: await expect(page).to_have_url(re.compile(r'/pages/index'), timeout=30000) await page.goto(f'{base_url}/#/pages/mine/info/index') await expect(page.get_by_text(USER['nickName'], exact=True)).to_be_visible(timeout=30000) - await expect(page.get_by_text('2025-12-31 19:00:00', exact=True)).to_be_visible(timeout=15000) - profile_requests = [request for request in observed if request['path'] == '/system/user/profile'] - assert profile_requests, '个人资料页未发送真实 API 请求' - assert all(request['authorization'] == f'Bearer {TOKEN}' for request in profile_requests) - assert all(request['timezone'] == 'America/New_York' for request in profile_requests) + await expect(page.get_by_text('Nickname', exact=True)).to_be_visible(timeout=15000) + created_at = await page.evaluate( + """({locale, timeZone, createTime}) => new Intl.DateTimeFormat(locale, { + dateStyle: 'medium', timeStyle: 'medium', timeZone + }).format(new Date(createTime))""", + {key: USER[key] for key in ('locale', 'timeZone', 'createTime')}, + ) + await expect(page.get_by_text(created_at, exact=True)).to_be_visible(timeout=15000) + check_profile_requests(observed) assert not errors, errors (output / 'result.json').write_text( json.dumps( @@ -190,7 +217,7 @@ async def run_smoke(framework: str, base_url: str, output: Path) -> None: ), encoding='utf-8', ) - print(f'{framework}: H5 login, persisted session and timezone profile PASS') + print(f'{framework}: H5 login, account locale, language headers and timezone profile PASS') except BaseException: failed = True await page.screenshot(path=str(output / 'failure.png'), full_page=True) diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml index df6a0085e..e8e45324a 100644 --- a/.github/workflows/ci-backend.yml +++ b/.github/workflows/ci-backend.yml @@ -33,6 +33,33 @@ jobs: ruoyi-fastapi-backend/plugins/ai/plugin.yaml - name: Install MySQL, PostgreSQL and test dependencies run: python -m pip install -r requirements.txt -r requirements-pg.txt -r requirements-test.txt + - name: Compile and validate gettext catalogs + run: python scripts/compile_i18n.py + - uses: actions/setup-node@v6 + with: + node-version: '22' + - uses: pnpm/action-setup@v5 + with: + package_json_file: ruoyi-fastapi-frontend/vue2/web/package.json + - name: Locate the pnpm store + id: pnpm-store + run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT" + working-directory: ruoyi-fastapi-frontend/vue2/web + - uses: actions/cache@v5 + with: + path: ${{ steps.pnpm-store.outputs.path }} + key: ${{ runner.os }}-generator-web-node22-${{ hashFiles('ruoyi-fastapi-frontend/*/web/pnpm-lock.yaml', 'ruoyi-fastapi-frontend/*/web/pnpm-workspace.yaml', 'ruoyi-fastapi-frontend/*/web/package.json') }} + - name: Install Web dependencies for generator tests + working-directory: ruoyi-fastapi-frontend + run: | + for framework in vue2 vue3 react; do + pnpm --dir "$framework/web" install --frozen-lockfile + done + - name: Install locked backend translation tooling and run read-only checks + run: | + npm ci --prefix .x18n/tooling --ignore-scripts + node .x18n/tooling/check-domains.mjs + npm test --prefix .x18n/tooling - name: Install AI plugin dependencies from its manifest run: python ../.github/scripts/install_ai_test_dependencies.py - name: Check dependency consistency @@ -63,6 +90,7 @@ jobs: cache: pip cache-dependency-path: ruoyi-fastapi-backend/requirements*.txt - run: python -m pip install -r requirements.txt -r requirements-test.txt + - run: python scripts/compile_i18n.py - name: Verify CLI, paths, artifacts and portable runtime contracts run: >- python -m pytest tests/cli @@ -96,6 +124,7 @@ jobs: cache: pip cache-dependency-path: ruoyi-fastapi-backend/requirements*.txt - run: python -m pip install -r requirements.txt -r requirements-test.txt + - run: python scripts/compile_i18n.py - name: Verify UTC, Shanghai and New York in separate processes shell: bash run: | diff --git a/.github/workflows/ci-frontend.yml b/.github/workflows/ci-frontend.yml index 5457108b3..0b1b02237 100644 --- a/.github/workflows/ci-frontend.yml +++ b/.github/workflows/ci-frontend.yml @@ -56,6 +56,10 @@ jobs: if ! pnpm list --depth Infinity --json > test-results/dependency-tree.json; then echo "Dependency tree includes peer diagnostics; inspect dependency-tree.json." >&2 fi + - name: Verify independent locale resources and runtime contracts + run: | + pnpm run i18n:check > test-results/i18n.json.log + pnpm run test:i18n - name: Run unit and component behavior tests run: pnpm run test:unit - name: Verify time contracts in three host timezones diff --git a/.github/workflows/ci-integration.yml b/.github/workflows/ci-integration.yml index 69506f405..dba1d6e69 100644 --- a/.github/workflows/ci-integration.yml +++ b/.github/workflows/ci-integration.yml @@ -59,6 +59,7 @@ jobs: cache: pip cache-dependency-path: ruoyi-fastapi-backend/requirements*.txt - run: python -m pip install -r requirements.txt -r requirements-pg.txt -r requirements-test.txt + - run: python scripts/compile_i18n.py - name: Configure isolated database verification run: | mkdir -p target/ci/timezone @@ -169,6 +170,7 @@ jobs: cache: pip cache-dependency-path: ruoyi-fastapi-backend/requirements*.txt - run: python -m pip install -r requirements.txt -r requirements-pg.txt + - run: python scripts/compile_i18n.py - name: Verify MySQL and PostgreSQL maintenance releases shell: bash run: | @@ -220,6 +222,7 @@ jobs: path: ${{ steps.pnpm-store.outputs.path }} key: ${{ runner.os }}-network-${{ matrix.framework }}-${{ hashFiles(format('ruoyi-fastapi-frontend/{0}/web/pnpm-lock.yaml', matrix.framework)) }} - run: python -m pip install -r requirements.txt -r requirements-test.txt playwright==1.64.0 + - run: python scripts/compile_i18n.py - run: python -m playwright install --with-deps chromium - name: Install Web dependencies working-directory: ruoyi-fastapi-frontend/${{ matrix.framework }}/web diff --git a/.github/workflows/ci-native.yml b/.github/workflows/ci-native.yml index 13c4eaa0d..b8eff3d9c 100644 --- a/.github/workflows/ci-native.yml +++ b/.github/workflows/ci-native.yml @@ -55,6 +55,7 @@ jobs: cache: pip cache-dependency-path: ruoyi-fastapi-backend/requirements*.txt - run: python -m pip install -r requirements.txt -r requirements-test.txt 'maturin>=1.15,<2' + - run: python scripts/compile_i18n.py - run: rustup toolchain install 1.99.0 --profile minimal - run: rustup default 1.99.0 - uses: actions/cache@v5 diff --git a/.gitignore b/.gitignore index f13d541cb..51a077062 100644 --- a/.gitignore +++ b/.gitignore @@ -153,3 +153,6 @@ cython_debug/ .opencode/ .qoder/ .trae/ + +# Backend development-only translation tool dependencies +/ruoyi-fastapi-backend/.x18n/tooling/node_modules/ diff --git a/README.md b/README.md index a4a965598..baaed0c41 100644 --- a/README.md +++ b/README.md @@ -216,6 +216,24 @@ RuoYi-FastAPI/ └── ruoyi-fastapi-test/ # 端到端与跨工程契约测试 ``` +### 国际化词库 + +六个前端各自在 `src/i18n/locales/<语言>/<命名空间>.json` 维护页面文案。同一功能的中英文使用相同的语义 key,并保留各语言需要的复数形式。新增词条时,按使用它的功能选择文件。 + +| 文案用途 | 归属与示例 | +| --- | --- | +| 跨功能通用操作 | `common`,如 `common:cancel` | +| 应用登录、注册和密码校验 | `auth`,如 `auth:login.passwordRequired` | +| Web 统一认证中心与 OAuth 后台 | 用户授权页归 `authCenter`;后台应用、授权、密钥等按 `oauth:client.*`、`oauth:grant.*`、`oauth:key.*` 分组 | +| 业务页面与可复用组件 | 菜单、字典等归 `system`;编辑器、Cron 选择器等归 `components`;移动端首页、个人资料等在 `mobile` 下按页面分组 | +| 插件自有文案 | Web 源码插件在自己的 `plugins//locales` 中维护;宿主的插件管理页面使用宿主词库 | + +在对应前端目录运行 `pnpm run i18n:check` 和 `pnpm run test:i18n`。新增命名空间时,同时确认该应用的 `src/i18n/registry.js` 已加载新文件。 + +后端 API 消息使用 gettext。宿主词库源文件位于 `i18n/catalogs/<语言>/LC_MESSAGES/core/<模块>.po`。例如,用户和角色消息放在 `system.po`,文件服务消息放在 `file.po`,插件运行时消息放在 `plugin_runtime.po`。新增业务模块时,在每个已启用语言下添加同名 PO,保持消息标识、上下文和复数标识一致。代码生成器按业务表输出独立的 `generated.<模块>.<业务>.po`。 + +在后端目录运行 `python scripts/compile_i18n.py` 会自动发现并校验各模块,每种语言合并生成一份 `LC_MESSAGES/core.mo`。业务代码继续使用原有消息 key。插件专属消息由插件自己的 `i18n/catalogs/<语言>/LC_MESSAGES/plugin..po` 维护。 + ### 传输层加解密配置说明 后端密钥配置与轮换说明:[ruoyi-fastapi-backend/docs/transport_crypto_config.md](./ruoyi-fastapi-backend/docs/transport_crypto_config.md) @@ -310,7 +328,7 @@ ruoyi plugin install-deps ai 1.新建数据库ruoyi-fastapi(默认,可修改) 2.如果使用的是MySQL数据库,使用命令或数据库连接工具运行sql文件夹下的ruoyi-fastapi.sql;如果使用的是PostgreSQL数据库,使用命令或数据库连接工具运行sql文件夹下的ruoyi-fastapi-pg.sql -# 运行后端 +# 启动后端(自动编译语言资源) ruoyi app run --env=dev ``` @@ -347,7 +365,7 @@ pnpm run build:prod # 配置环境 在.env.prod文件中配置生产环境的数据库和redis -# 运行后端 +# 在后端目录启动生产服务 ruoyi app run --env=prod ``` diff --git a/ruoyi-fastapi-backend/.dockerignore b/ruoyi-fastapi-backend/.dockerignore index 9ed186256..2c0e9d07d 100644 --- a/ruoyi-fastapi-backend/.dockerignore +++ b/ruoyi-fastapi-backend/.dockerignore @@ -10,3 +10,5 @@ target logs *.log *.egg-info + +.x18n diff --git a/ruoyi-fastapi-backend/.env.dev b/ruoyi-fastapi-backend/.env.dev index e11547f4e..5cefef25d 100644 --- a/ruoyi-fastapi-backend/.env.dev +++ b/ruoyi-fastapi-backend/.env.dev @@ -40,6 +40,10 @@ APP_DEFAULT_ENABLED_PLUGINS = 'ai' # 应用业务时区,使用IANA时区名称(如Asia/Shanghai),用于时间展示、日期范围查询和定时任务默认时区 APP_TIMEZONE = 'Asia/Shanghai' +# -------- 国际化配置 -------- +# 默认响应语言,必须使用后端语言注册表中已启用的语言标识 +I18N_DEFAULT_LOCALE = 'zh-CN' + # -------- Jwt配置 -------- # Jwt秘钥,留空时自动生成,开发环境下不要留空;也可使用 openssl rand -hex 32 手动生成 JWT_SECRET_KEY = 'b01c66dc2c58dc6a0aabfe2144256be36226de378bf87f72c0c795dda67f4d55' diff --git a/ruoyi-fastapi-backend/.env.dockermy b/ruoyi-fastapi-backend/.env.dockermy index ddce0fa84..02dafd946 100644 --- a/ruoyi-fastapi-backend/.env.dockermy +++ b/ruoyi-fastapi-backend/.env.dockermy @@ -40,6 +40,10 @@ APP_DEFAULT_ENABLED_PLUGINS = 'ai' # 应用业务时区,使用IANA时区名称(如Asia/Shanghai),用于时间展示、日期范围查询和定时任务默认时区 APP_TIMEZONE = 'Asia/Shanghai' +# -------- 国际化配置 -------- +# 默认响应语言,必须使用后端语言注册表中已启用的语言标识 +I18N_DEFAULT_LOCALE = 'zh-CN' + # -------- Jwt配置 -------- # Jwt秘钥,留空时自动生成;也可使用 openssl rand -hex 32 手动生成 JWT_SECRET_KEY = '' diff --git a/ruoyi-fastapi-backend/.env.dockerpg b/ruoyi-fastapi-backend/.env.dockerpg index c81575a86..2e9dd5ef3 100644 --- a/ruoyi-fastapi-backend/.env.dockerpg +++ b/ruoyi-fastapi-backend/.env.dockerpg @@ -40,6 +40,10 @@ APP_DEFAULT_ENABLED_PLUGINS = 'ai' # 应用业务时区,使用IANA时区名称(如Asia/Shanghai),用于时间展示、日期范围查询和定时任务默认时区 APP_TIMEZONE = 'Asia/Shanghai' +# -------- 国际化配置 -------- +# 默认响应语言,必须使用后端语言注册表中已启用的语言标识 +I18N_DEFAULT_LOCALE = 'zh-CN' + # -------- Jwt配置 -------- # Jwt秘钥,留空时自动生成;也可使用 openssl rand -hex 32 手动生成 JWT_SECRET_KEY = '' diff --git a/ruoyi-fastapi-backend/.env.prod b/ruoyi-fastapi-backend/.env.prod index 1b11e6f6d..aa3f77c29 100644 --- a/ruoyi-fastapi-backend/.env.prod +++ b/ruoyi-fastapi-backend/.env.prod @@ -40,6 +40,10 @@ APP_DEFAULT_ENABLED_PLUGINS = 'ai' # 应用业务时区,使用IANA时区名称(如Asia/Shanghai),用于时间展示、日期范围查询和定时任务默认时区 APP_TIMEZONE = 'Asia/Shanghai' +# -------- 国际化配置 -------- +# 默认响应语言,必须使用后端语言注册表中已启用的语言标识 +I18N_DEFAULT_LOCALE = 'zh-CN' + # -------- Jwt配置 -------- # Jwt秘钥,留空时自动生成;也可使用 openssl rand -hex 32 手动生成 JWT_SECRET_KEY = '' diff --git a/ruoyi-fastapi-backend/.x18n/core.mjs b/ruoyi-fastapi-backend/.x18n/core.mjs new file mode 100644 index 000000000..6be302b17 --- /dev/null +++ b/ruoyi-fastapi-backend/.x18n/core.mjs @@ -0,0 +1,26 @@ +import pythonDomain from './python-domain.mjs' + +// https://x18n.dev/raw/presets/python-gettext.md +// PO 的完整语义由 scripts/compile_i18n.py 校验并编译。 +export default { + name: 'core', + root: '..', + sourceLocale: 'zh-CN', + presets: ['python-gettext'], + plugins: [pythonDomain('core')], + resources: [{ pattern: 'i18n/catalogs/{locale}/LC_MESSAGES/core/*.po' }], + usage: { + include: ['**/*.py'], + // 这三个文件只生成前端源码,其中的 t() 由目标应用的 x18n 检查。 + exclude: [ + 'tests/**', + '.x18n/**', + 'target/**', + 'i18n/translator.py', + 'cli/runtime/plugin/scaffold/frontend.py', + 'cli/runtime/plugin/scaffold/frontend_vue2.py', + 'cli/runtime/plugin/scaffold/frontend_react.py', + ], + }, + checks: { 'missing-translation': 'error', 'empty-translation': 'error', 'unused-key': 'warning' }, +} diff --git a/ruoyi-fastapi-backend/.x18n/python-domain.mjs b/ruoyi-fastapi-backend/.x18n/python-domain.mjs new file mode 100644 index 000000000..369d3ca23 --- /dev/null +++ b/ruoyi-fastapi-backend/.x18n/python-domain.mjs @@ -0,0 +1,79 @@ +// 官方 Scanner API:https://x18n.dev/raw/plugins/capabilities.md +import { spawnSync } from 'node:child_process' +import { existsSync } from 'node:fs' +import { join } from 'node:path' +import { fileURLToPath } from 'node:url' + +const script = fileURLToPath(new URL('./scan_python_domains.py', import.meta.url)) +function parse(sources) { + const result = spawnSync(process.env.X18N_PYTHON || 'python', [script], { + input: JSON.stringify(sources), + encoding: 'utf8', + maxBuffer: 32 * 1024 * 1024, + }) + if (result.error || result.status !== 0) + throw new Error(`Python domain scan failed: ${result.error?.message || result.stderr}`) + return JSON.parse(result.stdout) +} + +function select(usages, domain, root) { + for (const usage of usages) { + if (usage.domain === 'core' || usage.domain === domain) continue + const match = /^plugin\.([a-z][a-z0-9_-]{0,63})$/.exec(usage.domain) + if ( + (domain && domain !== 'core') || + !match || + !existsSync(join(root, 'plugins', match[1], 'i18n/locale-meta.json')) + ) + throw new Error(`Undeclared gettext domain: ${usage.domain}`) + } + return usages + .filter((usage) => !domain || usage.domain === domain) + .map(({ domain: namespace, ...usage }) => (domain ? usage : { ...usage, namespace })) +} + +export default function pythonDomain(domain) { + let root + const scans = new Map() + return { + name: 'ruoyi-python-domains', + enforce: 'post', + async config(draft, { host, user }) { + root = host.root + // 保留预设中的其他文件类型;Python 调用通过 AST 分类,支持嵌套参数。 + draft.usage.regex = draft.usage.regex + .map((rule) => ({ + ...rule, + extensions: rule.extensions.filter((extension) => extension !== 'py'), + })) + .filter((rule) => rule.extensions.length) + const include = user.usage?.include || draft.usage.include + const ignore = [...draft.usage.exclude, ...(user.usage?.exclude || [])] + const paths = (await host.glob(include, { ignore })).filter((path) => path.endsWith('.py')) + const sources = await Promise.all( + paths.map(async (path) => ({ path, text: await host.readFile(path) })) + ) + const parsed = parse(sources) + parsed.forEach((item, index) => + scans.set(item.path, { + text: sources[index].text, + usages: select(item.usages, domain, root), + }) + ) + }, + scanners: [ + { + id: 'ruoyi-python-domain-calls', + extensions: ['py'], + scan(file) { + let result = scans.get(file.path) + if (result?.text !== file.text) { + result = { text: file.text, usages: select(parse([file])[0].usages, domain, root) } + scans.set(file.path, result) + } + return { usages: result.usages } + }, + }, + ], + } +} diff --git a/ruoyi-fastapi-backend/.x18n/scan_python_domains.py b/ruoyi-fastapi-backend/.x18n/scan_python_domains.py new file mode 100644 index 000000000..519bd43e1 --- /dev/null +++ b/ruoyi-fastapi-backend/.x18n/scan_python_domains.py @@ -0,0 +1,88 @@ +""" +使用标准库 AST 为 x18n 扫描消息调用,不导入或执行应用代码 +""" + +import ast +import json +import sys + + +def scan(source: dict) -> dict: + """ + 提取静态消息标识和显式 domain,位置使用 JavaScript UTF-16 偏移 + + :param source: 包含源码路径和文本的扫描输入 + :return: 源码路径及消息调用信息 + """ + text = source['text'] + tree = ast.parse(text, filename=source['path']) + constants = { + node.targets[0].id: node.value.value + for node in tree.body + if isinstance(node, ast.Assign) + and len(node.targets) == 1 + and isinstance(node.targets[0], ast.Name) + and isinstance(node.value, ast.Constant) + and isinstance(node.value.value, str) + } + lines = text.splitlines(keepends=True) + offsets = [] + total = 0 + for line in lines: + offsets.append(total) + total += len(line.encode('utf-16-le')) // 2 + + def position(line: int, column: int) -> int: + """ + 将 Python AST 的 UTF-8 字节位置转换为 JavaScript UTF-16 偏移 + + :param line: 从 1 开始的源码行号 + :param column: 从 0 开始的 UTF-8 字节列偏移 + :return: 从源码开头计算的 UTF-16 偏移 + """ + prefix = lines[line - 1].encode('utf-8')[:column].decode('utf-8') + return offsets[line - 1] + len(prefix.encode('utf-16-le')) // 2 + + usages = [] + for node in ast.walk(tree): + if not isinstance(node, ast.Call): + continue + options = {option.arg: option.value for option in node.keywords if option.arg is not None} + direct = isinstance(node.func, ast.Name) and node.func.id in ('t', '_', 'gettext', 'ngettext') + translate = ( + isinstance(node.func, ast.Attribute) + and isinstance(node.func.value, ast.Name) + and node.func.value.id == 'I18nUtil' + and node.func.attr == 'translate' + ) + key = options.get('msg_key') + if key is None and (direct or translate) and node.args: + key = node.args[0] + if not isinstance(key, ast.Constant) or not isinstance(key.value, str): + continue + domain = options.get('domain', ast.Constant(value='core')) + if isinstance(domain, ast.Name) and domain.id in constants: + domain = ast.Constant(value=constants[domain.id]) + if not isinstance(domain, ast.Constant) or not isinstance(domain.value, str): + raise ValueError( + f'{source["path"]}:{node.lineno}: static message requires a literal or module constant domain' + ) + usages.append( + { + 'domain': domain.value, + 'raw': key.value, + 'range': { + 'start': position(key.lineno, key.col_offset), + 'end': position(key.end_lineno, key.end_col_offset), + }, + 'kind': 'call', + 'dynamic': False, + } + ) + return {'path': source['path'], 'usages': usages} + + +if __name__ == '__main__': + print( + json.dumps([scan(source) for source in json.loads(sys.stdin.buffer.read().decode('utf-8'))], ensure_ascii=True) + ) diff --git a/ruoyi-fastapi-backend/.x18n/tooling/check-domains.mjs b/ruoyi-fastapi-backend/.x18n/tooling/check-domains.mjs new file mode 100644 index 000000000..e2da567b9 --- /dev/null +++ b/ruoyi-fastapi-backend/.x18n/tooling/check-domains.mjs @@ -0,0 +1,89 @@ +import { spawnSync } from 'node:child_process' +import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs' +import { tmpdir } from 'node:os' +import { dirname, join, resolve } from 'node:path' +import { fileURLToPath, pathToFileURL } from 'node:url' + +const cli = fileURLToPath(new URL('./node_modules/@x18n/cli/bin.mjs', import.meta.url)) +const scanner = fileURLToPath(new URL('../python-domain.mjs', import.meta.url)) +let root = fileURLToPath(new URL('../../', import.meta.url)) +const plugins = [] +for (let index = 2; index < process.argv.length; index++) { + const flag = process.argv[index] + const value = process.argv[++index] + if (flag === '--root' && value) root = resolve(value) + else if (flag === '--plugin' && value?.includes('=')) { + const separator = value.indexOf('=') + plugins.push({ id: value.slice(0, separator), root: resolve(value.slice(separator + 1)) }) + } else throw new Error('Usage: check-domains.mjs [--root BACKEND] [--plugin ID=ROOT ...]') +} + +const independent = plugins.length > 0 +if (!independent && existsSync(join(root, 'plugins'))) { + for (const entry of readdirSync(join(root, 'plugins'), { withFileTypes: true })) { + if (!entry.isDirectory()) continue + const pluginRoot = join(root, 'plugins', entry.name) + if ( + existsSync(join(pluginRoot, 'i18n/locale-meta.json')) || + existsSync(join(pluginRoot, 'i18n/catalogs')) + ) + plugins.push({ id: entry.name, root: pluginRoot }) + } +} + +function check(name, projectRoot, config) { + const args = [cli, '--root', projectRoot, '--no-cache'] + if (config) args.push('--config', config) + args.push('check', '--json') + const result = spawnSync(process.execPath, args, { + encoding: 'utf8', + maxBuffer: 32 * 1024 * 1024, + }) + if (result.error) throw result.error + if (!result.stdout) throw new Error(result.stderr || `${name}: x18n returned no report`) + return { domain: name, status: result.status, report: JSON.parse(result.stdout) } +} + +const directory = mkdtempSync(join(tmpdir(), 'ruoyi-domain-check-')) +try { + const reports = independent ? [] : [check('core', root, join(root, '.x18n/core.mjs'))] + for (const plugin of plugins) { + if (!/^[a-z][a-z0-9_-]{0,63}$/.test(plugin.id)) throw new Error('Invalid plugin domain owner') + const meta = JSON.parse(readFileSync(join(plugin.root, 'i18n/locale-meta.json'), 'utf8')) + const locales = meta.locales.map((entry) => entry.code) + if ( + !locales.length || + new Set(locales).size !== locales.length || + !locales.includes(meta.defaultLocale) + ) + throw new Error(`Invalid domain locale registry: ${plugin.id}`) + for (const code of locales) + if ( + typeof code !== 'string' || + code.includes('/') || + code.includes('\\') || + code.includes('..') + ) + throw new Error(`Invalid domain locale: ${plugin.id}`) + const domain = `plugin.${plugin.id}` + const config = join(directory, `${domain}.mjs`) + // 配置只读引用原始资源,不复制词库或依赖宿主语言配置。 + writeFileSync( + config, + `import scanner from ${JSON.stringify(pathToFileURL(scanner).href)}\nexport default { + name: ${JSON.stringify(domain)}, root: ${JSON.stringify(plugin.root)}, + sourceLocale: ${JSON.stringify(meta.sourceLocale || meta.defaultLocale)}, locales: ${JSON.stringify(locales)}, + presets: ['python-gettext'], plugins: [scanner(${JSON.stringify(domain)})], + resources: [{ pattern: ${JSON.stringify(`i18n/catalogs/{locale}/LC_MESSAGES/${domain}.po`)} }], + usage: { include: ['**/*.py'], exclude: ['tests/**', '.x18n/**', 'target/**'] }, + checks: { 'missing-translation': 'error', 'empty-translation': 'error', 'unused-key': 'warning' }, + }\n` + ) + reports.push(check(domain, plugin.root, config)) + } + console.log(JSON.stringify({ domains: reports }, null, 2)) + process.exitCode = reports.every((report) => report.status === 0) ? 0 : 1 +} finally { + if (dirname(directory) !== tmpdir()) throw new Error('Unexpected temporary check directory') + rmSync(directory, { recursive: true, force: true }) +} diff --git a/ruoyi-fastapi-backend/.x18n/tooling/package-lock.json b/ruoyi-fastapi-backend/.x18n/tooling/package-lock.json new file mode 100644 index 000000000..82d44a674 --- /dev/null +++ b/ruoyi-fastapi-backend/.x18n/tooling/package-lock.json @@ -0,0 +1,1417 @@ +{ + "name": "ruoyi-backend-i18n-tools", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "ruoyi-backend-i18n-tools", + "version": "1.0.0", + "devDependencies": { + "@x18n/cli": "0.1.14" + }, + "engines": { + "node": ">=22" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.14.tgz", + "integrity": "sha512-CXvKMFvM80ihI7Vox9jb+kQjnyjESQNPM+vB7U0Zz6TWuZA+Z/FL0QPMH300h33qJtIx+REeBhXqWOPW48TcAQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.14.tgz", + "integrity": "sha512-VL220vXuyO2z3rNIQwY7ftj9UwpqOt+33sH+sBWkOekbsSR2g7EEMnOx24ZlCH0xOA3DM/33SifVFGbnJD8r/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.14" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.14.tgz", + "integrity": "sha512-UjI/dKmwJwT9pOszJitq2G6EObZPnsZUfdCr92z2TlF3EZK9J3EdfOKUrCzHl6wFthbzwhzl1Soc/UIwxRiq6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.14", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@devframes/agentic": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@devframes/agentic/-/agentic-1.2.5.tgz", + "integrity": "sha512-2bVZFxGD7C+U1y0vkesUnLWHtrU3qD/Gq/Ri+aWkpXhDe/0EQ64ODA9gxCqFunUvJZ5z1rFvP1XLRLfUiSpvGg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@modelcontextprotocol/client": "^2.3.1", + "@modelcontextprotocol/server": "^2.3.1", + "h3": "^2.0.1", + "pathe": "^2.0.3" + }, + "peerDependencies": { + "devframe": "1.2.5" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.3.tgz", + "integrity": "sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@modelcontextprotocol/client": { + "version": "2.4.0", + "resolved": "https://registry.npmmirror.com/@modelcontextprotocol/client/-/client-2.4.0.tgz", + "integrity": "sha512-LgrD2OphHuG12vfKFKz6SOnq7bKHQmhGJIAYdD+MZBn2npHEyry6uD8zvktodtl5CQM85MO0anUyD9JwmUmxww==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@modelcontextprotocol/core": "2.4.0", + "cross-spawn": "^7.0.5", + "eventsource": "^3.0.2", + "eventsource-parser": "^3.0.8", + "jose": "^6.1.3", + "pkce-challenge": "^5.0.0", + "zod": "^4.2.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@modelcontextprotocol/core": { + "version": "2.4.0", + "resolved": "https://registry.npmmirror.com/@modelcontextprotocol/core/-/core-2.4.0.tgz", + "integrity": "sha512-z8QBKqdfXLPzkLQuG4xp8hrVEMm1PZ1IgxMN2sMbJiFiAKOWXnAzogXn2W4aqIBlP1ea6U5yiqVquvUNM1Cj6Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "zod": "^4.2.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@modelcontextprotocol/server": { + "version": "2.4.0", + "resolved": "https://registry.npmmirror.com/@modelcontextprotocol/server/-/server-2.4.0.tgz", + "integrity": "sha512-rgR9yxSaAJ+bcsi/XroT/S2AfPiIWloXAnrdfYSCms9ivVju0ishu/wW0J21Ho6+ZOR1r7RyeRbjiRuF87ix5Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@modelcontextprotocol/core": "2.4.0", + "zod": "^4.2.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@oxc-parser/binding-android-arm-eabi": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-android-arm-eabi/-/binding-android-arm-eabi-0.155.0.tgz", + "integrity": "sha512-A6xv7hDtnTm+xlZ7utn6rRQpRMJHRhVr3gjRGqlx0RUX84mNk0pAsy6YN/wWhuOTkaZhRrrzaLxf0NfbH77j2w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-android-arm64": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-android-arm64/-/binding-android-arm64-0.155.0.tgz", + "integrity": "sha512-T1wWwH9/JI5g7Z4kEQwDOwhToxdDhRyOTklH+uuNpJ16m3MZFmGl+l2rKc0NHQdbVRG2LTOBsNjpW3h1BWytPA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-darwin-arm64": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-darwin-arm64/-/binding-darwin-arm64-0.155.0.tgz", + "integrity": "sha512-ZoRB3qJxJ8DWA41jHja+YeB0lLfjBy4T+Kr15vnN1k65X3zbJt3rPZftEwN4Ju4tmA4K/T9dWWD7Z8ewQLnrVA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-darwin-x64": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-darwin-x64/-/binding-darwin-x64-0.155.0.tgz", + "integrity": "sha512-vxtL86BtM+IgrpejA86nbTk5j0HKTIMeuaJ1fQciw6p9RfavPtIPjI7gN34owap0yG9txXBaAWpGdxokNwdqIw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-freebsd-x64": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-freebsd-x64/-/binding-freebsd-x64-0.155.0.tgz", + "integrity": "sha512-tN6Ru5e0UVnWaIuiH8jEwnvxuxg7FvhWwSd3oe5oDhOD4ObsSr9/N6WfHLjilUWlPPj65ptwrSDH0Y7lzwTzmw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-arm-gnueabihf": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-0.155.0.tgz", + "integrity": "sha512-h4ozA5n6L6lwolsz9iwunEhKWnIVbmFRots5QxEix0H6nJ5ICpuDa7PuShuhfpIDFe3+Qvyscioyiv+9g+4Syg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-arm-musleabihf": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-arm-musleabihf/-/binding-linux-arm-musleabihf-0.155.0.tgz", + "integrity": "sha512-058/+LardpfuUlsKIvBGk/CYoakEVcMgqYx8GgyUZeOxFWTojYLlCc1Gb60/y21v3esDhHidgiY/Zbq9LpBhaQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-arm64-gnu": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-0.155.0.tgz", + "integrity": "sha512-nrOt2Y3xIAzu+lSPzH0864ieO+iCCXgoo9qFlGANE8Xh0cQ+RP8Wstfp+/wXN2YCyb98cAGzX0VruKYw7it/jw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-arm64-musl": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-arm64-musl/-/binding-linux-arm64-musl-0.155.0.tgz", + "integrity": "sha512-KYAayyN5hQbJPtGKtRxlyc8XYmyntOplyXSQzTDrmbz7l/GCrzQbSswvyJFBTH1LGtsZrbXOAfN52i/Kz6kLKg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-ppc64-gnu": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-0.155.0.tgz", + "integrity": "sha512-CSuSY5hfjtsBnHXydOj8jiNfS1qHbdPZuPz1YL1cSgK7VmNYP+QlZIbG0BBYYBgX/vYEgZwbG9mBdW4YairZ5w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-riscv64-gnu": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-0.155.0.tgz", + "integrity": "sha512-7KCfOQm+Nz2N8trAXbQkal4TQ5756WVEmhm35y816YHvyFnEfVsICsiV5k0pEszNf/fRm4cm2i6i18SJ6/iCWg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-riscv64-musl": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-0.155.0.tgz", + "integrity": "sha512-JSlhgoK+/g1TGJI5NuADx2+6syhxnQNLCWLXyO5QLFyetomcr/vIxSdiNlmyAv963YXUzCuwAwRG6npZ5xyJ1A==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-s390x-gnu": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-0.155.0.tgz", + "integrity": "sha512-WFIX+dPokWp64mi434Md3U3lJaTwNxAphvGjpltoyQjGUsdXavOIRrnp9dOS34Hd75HOAwDxAI+YwWOwqmJbtg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-x64-gnu": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-x64-gnu/-/binding-linux-x64-gnu-0.155.0.tgz", + "integrity": "sha512-g6xSDC/JpbnVOz5uafMGyK3txBVRFMQTx8opv/yHXGxqV3ZMVl3bf7W8XrSnF68dmy3gM4dgReNryuE53+WkeQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-x64-musl": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-x64-musl/-/binding-linux-x64-musl-0.155.0.tgz", + "integrity": "sha512-6/4xlxKlZJWrQ0uwDFPc0H9+xLu7068CKhX3vIDW3SbvP/lVgnVuT5v6dyugeWskWpuxqF/WJ4WKwhxjU3pG2w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-openharmony-arm64": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-openharmony-arm64/-/binding-openharmony-arm64-0.155.0.tgz", + "integrity": "sha512-tltklL0J0XjDxIRTBXWOBhvc2mitcmES45pIxhwDWfxRyqz7Vkeu0NekTZEIxGE4f/lXgq3vZcjjffteQOVorg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-win32-arm64-msvc": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-0.155.0.tgz", + "integrity": "sha512-alAb9TzjatUEsOeoncAziUnfdTDxfyswhalFZ9sC6plUgATIUx2NIZ0+bMn6aJ28AduS1OpG/OAisr/YISn4Ig==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-win32-ia32-msvc": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-0.155.0.tgz", + "integrity": "sha512-yc5cbSfcGmRv/KpxDFuyk8adEBaWd/9HilWvBbQ4bFbus1V2PUh2mGB2Cfq9rqZTqLeiMT8x0skV+LKp9hOMgQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-win32-x64-msvc": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-win32-x64-msvc/-/binding-win32-x64-msvc-0.155.0.tgz", + "integrity": "sha512-8heq6jGq+rfpTDRDjoQiBHw0maQZf3IXkS99pdHQZPoTL5kyF5qyPS0RidUlSdnWDIqxXb5nux7GBD9cT+imUw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-project/types": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.155.0.tgz", + "integrity": "sha512-SeE8JPwW1xs1tHeNycjUtUBdhorRa8o4jlvjwk49R7/Z291i+4DQa7JJIgOm/TaYQZx+QrPQbVJ/9c8dMIZN8Q==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/oxc-project" + } + }, + "node_modules/@sveltejs/acorn-typescript": { + "version": "1.0.13", + "resolved": "https://registry.npmjs.org/@sveltejs/acorn-typescript/-/acorn-typescript-1.0.13.tgz", + "integrity": "sha512-wgKggnhZVL9Bfx1OaKKTrYY9BFRk6C8UAkQNUcIv1+llzYrIqy+RZm5HPKzn0NpEBvTVhTqB4kQyllZywsRBRQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^8.9.0" + } + }, + "node_modules/@types/estree": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.10.tgz", + "integrity": "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@valibot/to-json-schema": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@valibot/to-json-schema/-/to-json-schema-1.8.0.tgz", + "integrity": "sha512-a0M+uwCuQZEPAo65NYkFSJ14O5c213KoSZmPdoCfuFvUhfULi4T2Z6Tpjv6lTVMW9RoLm74RpRAjNEa43KcN+g==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "valibot": "^1.5.0" + } + }, + "node_modules/@vue/compiler-core": { + "version": "3.5.45", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.45.tgz", + "integrity": "sha512-XGHJrM6ufZARAc/w+tyOswStw9tdKiqCKBScI4gGaNxD+aaGu/HQWgKJ+JItjRLPqenQ7iE7G8AJC7T5ew1p+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.12", + "@vue/shared": "3.5.45", + "entities": "^7.0.1", + "estree-walker": "^2.0.2", + "source-map-js": "^1.2.2" + } + }, + "node_modules/@vue/compiler-dom": { + "version": "3.5.45", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.45.tgz", + "integrity": "sha512-LbP2d19GSOYGPmvMBBCVJVlv7TKtjM1Cfeyu3cYia720pknZP+1cLX7H5MVatvruT6MuJhiPuNbQBW/MDn/EwA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vue/compiler-core": "3.5.45", + "@vue/shared": "3.5.45" + } + }, + "node_modules/@vue/compiler-sfc": { + "version": "3.5.45", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.45.tgz", + "integrity": "sha512-MKFjb2UX0M/l/jhfzqMLrI8VM4pfvFKG3pqFZkSZFHRLtNld/O4RtUPZFWSwhro/14qP88UQEkWzHxAZAQ0tsw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.12", + "@vue/compiler-core": "3.5.45", + "@vue/compiler-dom": "3.5.45", + "@vue/compiler-ssr": "3.5.45", + "@vue/shared": "3.5.45", + "estree-walker": "^2.0.2", + "magic-string": "^0.30.21", + "postcss": "^8.5.32", + "source-map-js": "^1.2.2" + } + }, + "node_modules/@vue/compiler-ssr": { + "version": "3.5.45", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.45.tgz", + "integrity": "sha512-RF5sbZOfYz5AK00tOJUn2PwFXR2fS1u2HVzI8D9VF9rGAFxuGBqg2bB1kJ3ZHMprqSltXnT9MZE1IsqjSM8oew==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vue/compiler-dom": "3.5.45", + "@vue/shared": "3.5.45" + } + }, + "node_modules/@vue/shared": { + "version": "3.5.45", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.45.tgz", + "integrity": "sha512-ue9fgHmVNPlP7iW3+cxoBX/Cnlw53dHlVSw0JKGY6z1lObg8pHoj928M2nzG4/yVsMZ3NaRZ2s2z61uC16NDwQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@x18n/builtins": { + "version": "0.1.14", + "resolved": "https://registry.npmjs.org/@x18n/builtins/-/builtins-0.1.14.tgz", + "integrity": "sha512-ezxyuOAK+YsAL4PbVPyZTOpwsZp1Qoo2vIr8MJQivcQyC80GAaxbpQvmRExikhnThH/OyienjaGRceUsDBYQ6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vue/compiler-sfc": "^3.5.44", + "@x18n/core": "0.1.14", + "json5": "^2.2.3", + "jsonc-parser": "^3.3.1", + "oxc-parser": "^0.155.0", + "svelte": "^5.57.2", + "yaml": "^2.9.1" + } + }, + "node_modules/@x18n/cli": { + "version": "0.1.14", + "resolved": "https://registry.npmjs.org/@x18n/cli/-/cli-0.1.14.tgz", + "integrity": "sha512-b38DwR0ZUWujNNIsVE/tRQ4tud5wACIyui4dN578T85r8iH5VvfxNjBj7m8LYOwxNwVGOOheenskVItRvVQEQw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@x18n/builtins": "0.1.14", + "@x18n/core": "0.1.14", + "@x18n/node": "0.1.14", + "@x18n/ui": "0.1.14", + "cac": "^7.1.0", + "devframe": "^1.2.6", + "nostics": "^1.3.0", + "yaml": "^2.9.1" + }, + "bin": { + "x18n": "bin.mjs" + }, + "engines": { + "node": ">=22" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/@x18n/cli/node_modules/@devframes/agentic": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@devframes/agentic/-/agentic-1.3.5.tgz", + "integrity": "sha512-oAxHbfJ0MxLKRzkkOsEsLCBLdVn4MtCj7MOV+BZ4OHU4Ip88lNu5F1VLbfyvoTOJthLLglj9BqrOMpW7IDTN9A==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "@modelcontextprotocol/client": "^2.4.0", + "@modelcontextprotocol/server": "^2.4.0", + "h3": "^2.0.8", + "pathe": "^2.0.3" + }, + "peerDependencies": { + "devframe": "1.3.5" + } + }, + "node_modules/@x18n/cli/node_modules/devframe": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/devframe/-/devframe-1.3.5.tgz", + "integrity": "sha512-WvMFRU/quCkZFl4ZVd69UDfDoHdSwn1Wd4ThuycOa6YPvy/NRv8vxbraWREEbAGmiBFexWIzLcywyshbAcLc4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "crossws": "^0.4.17", + "h3": "^2.0.8", + "nostics": "^1.3.0", + "pathe": "^2.0.3" + }, + "bin": { + "devframe": "bin/devframe.mjs" + }, + "peerDependencies": { + "@devframes/agentic": "1.3.5", + "cac": "^7.0.0" + }, + "peerDependenciesMeta": { + "@devframes/agentic": { + "optional": true + }, + "cac": { + "optional": true + } + } + }, + "node_modules/@x18n/core": { + "version": "0.1.14", + "resolved": "https://registry.npmjs.org/@x18n/core/-/core-0.1.14.tgz", + "integrity": "sha512-gQWKzyX2B9Ppl3AG6Fcls+bshqUJMhfbgtzbFeKlDKNE6IS/w7VSHkm/NLEnLEfxTenwFFQAAPL5NO7i/Ke0Fw==", + "dev": true, + "license": "MIT", + "dependencies": { + "nostics": "^1.3.0", + "valibot": "^1.5.0" + } + }, + "node_modules/@x18n/node": { + "version": "0.1.14", + "resolved": "https://registry.npmjs.org/@x18n/node/-/node-0.1.14.tgz", + "integrity": "sha512-Q5W9mjap2fL3CeDmbPrgH11KuKLju3LplAtHvmH6iPttNKgy1JkwOyuKjAr2dpgErRYJOEHhpY4ySZ3j0JNyag==", + "dev": true, + "license": "MIT", + "dependencies": { + "@x18n/builtins": "0.1.14", + "@x18n/core": "0.1.14", + "chokidar": "^6.0.0", + "ignore": "^7.0.13", + "jiti": "^2.7.0", + "jsonc-parser": "^3.3.1", + "tinyglobby": "^0.2.17", + "yaml": "^2.9.1" + }, + "engines": { + "node": ">=22" + } + }, + "node_modules/@x18n/ui": { + "version": "0.1.14", + "resolved": "https://registry.npmjs.org/@x18n/ui/-/ui-0.1.14.tgz", + "integrity": "sha512-5JH91Lli5V66oYk26ebaaEUN6vdhAibWSAX30wxFZLdy952jvKkwzOwQMJlO9b7ftHU/lZneYNH/8+0fH2ZCaQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@devframes/agentic": "1.2.5", + "@valibot/to-json-schema": "^1.8.0", + "@x18n/builtins": "0.1.14", + "@x18n/core": "0.1.14", + "devframe": "^1.2.6", + "valibot": "^1.5.0" + }, + "engines": { + "node": ">=22" + } + }, + "node_modules/@x18n/ui/node_modules/devframe": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/devframe/-/devframe-1.3.5.tgz", + "integrity": "sha512-WvMFRU/quCkZFl4ZVd69UDfDoHdSwn1Wd4ThuycOa6YPvy/NRv8vxbraWREEbAGmiBFexWIzLcywyshbAcLc4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "crossws": "^0.4.17", + "h3": "^2.0.8", + "nostics": "^1.3.0", + "pathe": "^2.0.3" + }, + "bin": { + "devframe": "bin/devframe.mjs" + }, + "peerDependencies": { + "@devframes/agentic": "1.3.5", + "cac": "^7.0.0" + }, + "peerDependenciesMeta": { + "@devframes/agentic": { + "optional": true + }, + "cac": { + "optional": true + } + } + }, + "node_modules/acorn": { + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.19.0.tgz", + "integrity": "sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/aria-query": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.1.tgz", + "integrity": "sha512-Z/ZeOgVl7bcSYZ/u/rh0fOpvEpq//LZmdbkXyc7syVzjPAhfOa9ebsdTSjEBDU4vs5nC98Kfduj1uFo0qyET3g==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/axobject-query": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz", + "integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/cac": { + "version": "7.1.0", + "resolved": "https://registry.npmmirror.com/cac/-/cac-7.1.0.tgz", + "integrity": "sha512-LMDU/U2yA4IPIY8KT0NsNPWEYZvAMkbgyspxJ6btJaYV+WMDOHAZCmB0lsTObiHaRS1V/ztKAl7+TSkTqXyeoA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/chokidar": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-6.0.0.tgz", + "integrity": "sha512-Ec2Z7wpcKBiMpR7DxteoqS/sq5G5d2A4fpxzPv6+fD7xNNdrTghn7L11YwV5EN1B3i72Erc3XVT5FkWIDx90+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "readdirp": "^5.1.1" + }, + "engines": { + "node": ">= 22.22" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmmirror.com/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/crossws": { + "version": "0.4.17", + "resolved": "https://registry.npmmirror.com/crossws/-/crossws-0.4.17.tgz", + "integrity": "sha512-YG2kyfafNXKmu7e6k64yrj6whrw7m5sBIsOSXOlJ/72X3TQWRQuw8DhvXFDcBk8HF77PnTSygnm7xpYCTnFpow==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "srvx": ">=0.11.5" + }, + "peerDependenciesMeta": { + "srvx": { + "optional": true + } + } + }, + "node_modules/devalue": { + "version": "5.9.4", + "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.9.4.tgz", + "integrity": "sha512-sPAT4pztbu6586/hrhOnMKS17IJrvg12mXiSPSS3W5qDeN2RGgvZ0diZCm31dBbnevfVmujNO3IM2wrS4Y2Rhg==", + "dev": true, + "license": "MIT" + }, + "node_modules/devframe": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/devframe/-/devframe-1.2.5.tgz", + "integrity": "sha512-7txhfBgFafXHN/KIyP/M6F1W5WF1VPypoB4mZtZEa4KM8n1Y57EtnVm281Y3cg7SHti/PtfCtmmmtDh/k/CS3g==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "crossws": "^0.4.12", + "h3": "^2.0.1", + "nostics": "^1.3.0", + "pathe": "^2.0.3" + }, + "bin": { + "devframe": "bin/devframe.mjs" + }, + "peerDependencies": { + "@devframes/agentic": "1.2.5", + "cac": "^7.0.0" + }, + "peerDependenciesMeta": { + "@devframes/agentic": { + "optional": true + }, + "cac": { + "optional": true + } + } + }, + "node_modules/entities": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz", + "integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/esm-env": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/esm-env/-/esm-env-1.2.2.tgz", + "integrity": "sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/esrap": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/esrap/-/esrap-2.4.0.tgz", + "integrity": "sha512-CQPcneEHw/czj32uwQC52nYnax8H4SXt25FCM+LIwGZ49cMIxpOj3bP8wmzcI+Z0HIy5KkClaPhRLfCySzwHPA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15" + }, + "peerDependencies": { + "@typescript-eslint/types": "^8.2.0" + }, + "peerDependenciesMeta": { + "@typescript-eslint/types": { + "optional": true + } + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/eventsource": { + "version": "3.0.7", + "resolved": "https://registry.npmmirror.com/eventsource/-/eventsource-3.0.7.tgz", + "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==", + "dev": true, + "license": "MIT", + "dependencies": { + "eventsource-parser": "^3.0.1" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/eventsource-parser": { + "version": "3.1.1", + "resolved": "https://registry.npmmirror.com/eventsource-parser/-/eventsource-parser-3.1.1.tgz", + "integrity": "sha512-EKN1vKAMcZ8MlYMpaNuxN6R9yakzH6uajHcHVTqWJzvu5pWw9DyhbP35HH8MVBQ+dZjAfDxk+A8NiR9KWaXiyQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/h3": { + "version": "2.0.8", + "resolved": "https://registry.npmmirror.com/h3/-/h3-2.0.8.tgz", + "integrity": "sha512-ENuKlF9kC6E6PrvY1PUyE0qkrnnPTIt2/v48uyEEfTVfgoiqBCE0uwwf++2XrWwT1gxjQBDLQ8PAsmZVniKvTw==", + "dev": true, + "license": "MIT", + "dependencies": { + "rou3": "^1.0.0", + "srvx": "^1.0.6" + }, + "bin": { + "h3": "bin/h3.mjs" + }, + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "crossws": "^0.4.12", + "ocache": ">=0.3.0" + }, + "peerDependenciesMeta": { + "crossws": { + "optional": true + }, + "ocache": { + "optional": true + } + } + }, + "node_modules/ignore": { + "version": "7.0.14", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.14.tgz", + "integrity": "sha512-wCBiZ77u1tuWde6G/nfOtLaCTYcFDU5yCzARzK10y+rLhzYoL7a7yEemcopcc2Mzow7gZOIjnV2ym1NYmdiJOQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/is-reference": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz", + "integrity": "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.6" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/jiti": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", + "integrity": "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==", + "dev": true, + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, + "node_modules/jose": { + "version": "6.2.14", + "resolved": "https://registry.npmmirror.com/jose/-/jose-6.2.14.tgz", + "integrity": "sha512-3JasLuki1NRLQvY4wCoC37KZk4qxoBx2k2aFqLxT84IezqW0bkJKnNtxnZj/Fu1xsQivoc/lytxaRHJoGLjJ1A==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/jsonc-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz", + "integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/locate-character": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz", + "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==", + "dev": true, + "license": "MIT" + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/nanoid": { + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/nostics": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/nostics/-/nostics-1.3.0.tgz", + "integrity": "sha512-wzRsrJwNlFbqIRQt8aCeL2WE8USip/uuvGSOZV1D02CxX8ABTMbw8IywKjH7yWHETMXbWJI4OBpihg9rmz2Vyg==", + "dev": true, + "license": "MIT" + }, + "node_modules/oxc-parser": { + "version": "0.155.0", + "resolved": "https://registry.npmjs.org/oxc-parser/-/oxc-parser-0.155.0.tgz", + "integrity": "sha512-C/ReSf1JUFukK/zvk6jhcNibSssvas5+ktIzK7fbKVd3CedWe59C3QwHEOrEZj/4Rt9+xg0Jeis/Jv1F/KM1mw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@oxc-project/types": "^0.155.0" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/sponsors/oxc-project" + }, + "optionalDependencies": { + "@oxc-parser/binding-android-arm-eabi": "0.155.0", + "@oxc-parser/binding-android-arm64": "0.155.0", + "@oxc-parser/binding-darwin-arm64": "0.155.0", + "@oxc-parser/binding-darwin-x64": "0.155.0", + "@oxc-parser/binding-freebsd-x64": "0.155.0", + "@oxc-parser/binding-linux-arm-gnueabihf": "0.155.0", + "@oxc-parser/binding-linux-arm-musleabihf": "0.155.0", + "@oxc-parser/binding-linux-arm64-gnu": "0.155.0", + "@oxc-parser/binding-linux-arm64-musl": "0.155.0", + "@oxc-parser/binding-linux-ppc64-gnu": "0.155.0", + "@oxc-parser/binding-linux-riscv64-gnu": "0.155.0", + "@oxc-parser/binding-linux-riscv64-musl": "0.155.0", + "@oxc-parser/binding-linux-s390x-gnu": "0.155.0", + "@oxc-parser/binding-linux-x64-gnu": "0.155.0", + "@oxc-parser/binding-linux-x64-musl": "0.155.0", + "@oxc-parser/binding-openharmony-arm64": "0.155.0", + "@oxc-parser/binding-win32-arm64-msvc": "0.155.0", + "@oxc-parser/binding-win32-ia32-msvc": "0.155.0", + "@oxc-parser/binding-win32-x64-msvc": "0.155.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmmirror.com/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmmirror.com/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pkce-challenge": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/pkce-challenge/-/pkce-challenge-5.0.1.tgz", + "integrity": "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/postcss": { + "version": "8.5.33", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.33.tgz", + "integrity": "sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.20", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/readdirp": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.1.1.tgz", + "integrity": "sha512-Kko+Y5XQ6fM+Ce3dq3m9YGxnacYZYl9cA1wZjaF3Vbry2L3i1qVg8+CAgNPsXRArPMUMCaOR7oa9Nqntc43JKA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 20.19.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/rou3": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/rou3/-/rou3-1.0.0.tgz", + "integrity": "sha512-ySeaQkSrua+ut9g+65I7FHqOFBaY8tV0FmccXItoq0q21se32Q3u4YiW7/RqXSosWgYJaaKwRHXy3BST9PeCNQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/source-map-js": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/srvx": { + "version": "1.0.8", + "resolved": "https://registry.npmmirror.com/srvx/-/srvx-1.0.8.tgz", + "integrity": "sha512-ngFS/J6St4PJfHRHGjr78xkPPtbyXtdMOLNE4x/XZunEK3OhV7aGUWMHf9WTUEy6wm1U0W4okkd82ZFFWRVQTw==", + "dev": true, + "license": "MIT", + "bin": { + "srvx": "bin/srvx.mjs" + }, + "engines": { + "node": ">=20.16.0" + } + }, + "node_modules/svelte": { + "version": "5.57.3", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.57.3.tgz", + "integrity": "sha512-5mAftM3SoDV9X0zdF386F9p2pv8iKOwi/KfBS1XnBAkVCKFzVOLHUoa8iGWAt4buoicLmyWVRpuuD5wplXOQsg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/remapping": "^2.3.5", + "@jridgewell/sourcemap-codec": "^1.6.0", + "@sveltejs/acorn-typescript": "^1.0.13", + "@types/estree": "^1.0.9", + "acorn": "^8.18.0", + "aria-query": "5.3.1", + "axobject-query": "^4.1.0", + "clsx": "^2.1.1", + "devalue": "^5.9.2", + "esm-env": "^1.2.1", + "esrap": "^2.3.6", + "is-reference": "^3.0.3", + "locate-character": "^3.0.0", + "magic-string": "^0.30.11", + "zimmerframe": "^1.1.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/valibot": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/valibot/-/valibot-1.5.0.tgz", + "integrity": "sha512-nil6AkP2TChWL43Z5uJ6GTxX01CUA+g8LWUM+N/rB9NBbkUMaUsi9PUNzlUPgoKASgmx9f7eGOYpJ04/fSa6FQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "typescript": ">=5" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/yaml": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz", + "integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==", + "dev": true, + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + }, + "funding": { + "url": "https://github.com/sponsors/eemeli" + } + }, + "node_modules/zimmerframe": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/zimmerframe/-/zimmerframe-1.1.5.tgz", + "integrity": "sha512-msJxIvYDYcoNL+PJsu+7qmpDWsYmAxTY+2TNYXXF0hzBzBk0BMecOqDOG/EckUoKCuKwObfbugIl8QpqHDXeFA==", + "dev": true, + "license": "MIT" + }, + "node_modules/zod": { + "version": "4.6.7", + "resolved": "https://registry.npmmirror.com/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + } + } +} diff --git a/ruoyi-fastapi-backend/.x18n/tooling/package.json b/ruoyi-fastapi-backend/.x18n/tooling/package.json new file mode 100644 index 000000000..1718a9092 --- /dev/null +++ b/ruoyi-fastapi-backend/.x18n/tooling/package.json @@ -0,0 +1,15 @@ +{ + "name": "ruoyi-backend-i18n-tools", + "private": true, + "version": "1.0.0", + "engines": { + "node": ">=22" + }, + "devDependencies": { + "@x18n/cli": "0.1.14" + }, + "scripts": { + "i18n:check": "node check-domains.mjs", + "test": "node --test tests/*.test.mjs" + } +} diff --git a/ruoyi-fastapi-backend/.x18n/tooling/tests/domains.test.mjs b/ruoyi-fastapi-backend/.x18n/tooling/tests/domains.test.mjs new file mode 100644 index 000000000..b07a19db7 --- /dev/null +++ b/ruoyi-fastapi-backend/.x18n/tooling/tests/domains.test.mjs @@ -0,0 +1,170 @@ +import assert from 'node:assert/strict' +import { spawnSync } from 'node:child_process' +import { cp, mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import { join } from 'node:path' +import { test } from 'node:test' +import { fileURLToPath } from 'node:url' + +const backend = new URL('../../../', import.meta.url) +const checker = fileURLToPath(new URL('../check-domains.mjs', import.meta.url)) +const cli = fileURLToPath(new URL('../node_modules/@x18n/cli/bin.mjs', import.meta.url)) + +function check(args) { + const result = spawnSync(process.execPath, [checker, ...args], { + encoding: 'utf8', + maxBuffer: 16 * 1024 * 1024, + }) + assert.ifError(result.error) + assert.ok(result.stdout, result.stderr) + return { status: result.status, domains: JSON.parse(result.stdout).domains } +} + +function catalog(locale, value = 'Translated') { + return `msgid "" +msgstr "" +"Language: ${locale}\\n" +"Content-Type: text/plain; charset=UTF-8\\n" + +msgid "plugin.only" +msgstr "${value}" + +msgid "plugin.other" +msgstr "Other message" + +msgid "common.success" +msgstr "Plugin success" +` +} + +test('real CLI isolates plugin locales and domains while retaining core calls in plugin code', async () => { + const root = await mkdtemp(join(tmpdir(), 'ruoyi-domain-cli-')) + const plugin = join(root, 'plugins/domain_demo') + try { + await mkdir(join(root, '.x18n'), { recursive: true }) + await cp(new URL('x18n.config.mjs', backend), join(root, 'x18n.config.mjs')) + for (const name of ['core.mjs', 'python-domain.mjs', 'scan_python_domains.py']) + await cp(new URL(`.x18n/${name}`, backend), join(root, '.x18n', name)) + await cp(new URL('i18n/catalogs/', backend), join(root, 'i18n/catalogs'), { recursive: true }) + await mkdir(join(plugin, 'i18n'), { recursive: true }) + await writeFile( + join(plugin, 'i18n/locale-meta.json'), + JSON.stringify({ + defaultLocale: 'en-US', + locales: [{ code: 'en-US' }, { code: 'ru-RU', fallback: ['en-US'] }], + }) + ) + for (const code of ['en-US', 'ru-RU']) { + const directory = join(plugin, `i18n/catalogs/${code}/LC_MESSAGES`) + await mkdir(directory, { recursive: true }) + await writeFile(join(directory, 'plugin.domain_demo.po'), catalog(code)) + } + const source = `from i18n import t +DOMAIN = 'plugin.domain_demo' +t( + 'plugin.only', + {'value': nested('a closing ) in a string')}, + domain=DOMAIN, +) +I18nMessage('原文', msg_key='plugin.other', domain='plugin.domain_demo') +ResponseUtil.success(msg_key='common.success') +ResponseUtil.success(msg_key='common.success', domain=DOMAIN) +` + await writeFile(join(plugin, 'messages.py'), source) + let result = check(['--root', root]) + assert.equal(result.status, 0, JSON.stringify(result.domains)) + assert.deepEqual( + result.domains.map((item) => item.domain), + ['core', 'plugin.domain_demo'] + ) + const pluginReport = result.domains.find((item) => item.domain === 'plugin.domain_demo').report + assert.deepEqual(pluginReport.data.projects[0].coverage.map((item) => item.locale).sort(), [ + 'en-US', + 'ru-RU', + ]) + assert.ok( + !pluginReport.diagnostics.some( + (item) => item.code === 'unused-key' && item.key === 'plugin.only' + ) + ) + + // 编辑器在同一个 Python 文件中根据调用的域跳到各自的 PO,即使 msgid 相同。 + for (const [domain, usage, resource] of [ + ['core', "msg_key='common.success')", 'i18n/catalogs/en-US/LC_MESSAGES/core/common.po'], + [ + 'plugin.domain_demo', + "msg_key='common.success', domain=DOMAIN)", + 'plugins/domain_demo/i18n/catalogs/en-US/LC_MESSAGES/plugin.domain_demo.po', + ], + ]) { + const result = spawnSync( + process.execPath, + [cli, '--root', root, 'get', `${domain}:common.success`, '--json'], + { + cwd: root, + encoding: 'utf8', + } + ) + assert.ifError(result.error) + assert.equal(result.status, 0, result.stderr || result.stdout) + const [key] = JSON.parse(result.stdout).data.projects + assert.equal(key.messages.find((item) => item.locale === 'en-US').file, resource) + assert.deepEqual( + key.usages.map((item) => [item.file, item.line]), + [ + [ + 'plugins/domain_demo/messages.py', + source.split('\n').findIndex((line) => line.includes(usage)) + 1, + ], + ] + ) + } + + // 插件中默认使用 core 的调用仍须按核心词库检查。 + await writeFile( + join(plugin, 'messages.py'), + source.replace('common.success', 'missing.coreInPlugin') + ) + result = check(['--root', root]) + assert.equal(result.status, 1) + assert.ok( + result.domains[0].report.diagnostics.some( + (item) => item.code === 'missing-key' && item.key === 'missing.coreInPlugin' + ) + ) + assert.equal(result.domains[1].status, 0) + + // 独立插件校验不依赖宿主词库、宿主语言或其他插件。 + await rm(join(root, 'i18n'), { recursive: true, force: true }) + result = check(['--plugin', `domain_demo=${plugin}`]) + assert.equal(result.status, 0, JSON.stringify(result.domains)) + assert.deepEqual( + result.domains.map((item) => item.domain), + ['plugin.domain_demo'] + ) + await writeFile( + join(plugin, 'messages.py'), + source + "t('missing.pluginOnly', domain=DOMAIN)\n" + ) + result = check(['--plugin', `domain_demo=${plugin}`]) + assert.equal(result.status, 1) + assert.ok( + result.domains[0].report.diagnostics.some( + (item) => item.code === 'missing-key' && item.key === 'missing.pluginOnly' + ) + ) + + await writeFile(join(plugin, 'messages.py'), source) + await writeFile( + join(plugin, 'i18n/catalogs/ru-RU/LC_MESSAGES/plugin.domain_demo.po'), + catalog('ru-RU', '') + ) + result = check(['--plugin', `domain_demo=${plugin}`]) + assert.equal(result.status, 1) + assert.ok( + result.domains[0].report.diagnostics.some((item) => item.code === 'empty-translation') + ) + } finally { + await rm(root, { recursive: true, force: true }) + } +}) diff --git a/ruoyi-fastapi-backend/.x18n/tooling/tests/usage.test.mjs b/ruoyi-fastapi-backend/.x18n/tooling/tests/usage.test.mjs new file mode 100644 index 000000000..658cdd833 --- /dev/null +++ b/ruoyi-fastapi-backend/.x18n/tooling/tests/usage.test.mjs @@ -0,0 +1,124 @@ +import assert from 'node:assert/strict' +import { spawnSync } from 'node:child_process' +import { cp, mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import { join } from 'node:path' +import { test } from 'node:test' +import { fileURLToPath } from 'node:url' + +const backend = new URL('../../../', import.meta.url) +const cli = fileURLToPath(new URL('../node_modules/@x18n/cli/bin.mjs', import.meta.url)) + +test('Python translation entry points are scanned with the project config', async () => { + const root = await mkdtemp(join(tmpdir(), 'ruoyi-python-x18n-')) + function check() { + const config = join(root, '.x18n/core.mjs') + const result = spawnSync( + process.execPath, + [cli, '--root', root, '--config', config, 'check', '--json'], + { + encoding: 'utf8', + } + ) + assert.ifError(result.error) + assert.ok(result.stdout, result.stderr) + return { status: result.status, report: JSON.parse(result.stdout) } + } + + try { + await mkdir(join(root, '.x18n'), { recursive: true }) + for (const name of ['core.mjs', 'python-domain.mjs', 'scan_python_domains.py']) + await cp(new URL(`.x18n/${name}`, backend), join(root, '.x18n', name)) + await cp(new URL('i18n/catalogs/', backend), join(root, 'i18n/catalogs'), { recursive: true }) + const scaffold = join(root, 'cli/runtime/plugin/scaffold') + await mkdir(scaffold, { recursive: true }) + for (const name of ['frontend.py', 'frontend_vue2.py', 'frontend_react.py']) { + await cp(new URL(`cli/runtime/plugin/scaffold/${name}`, backend), join(scaffold, name)) + } + await writeFile( + join(root, 'messages.py'), + `from i18n import t +from i18n.translator import I18nUtil + +t('common.success') +t('generated.sample.order.created') +t("common.failure", locale='en-US') +I18nUtil.translate('common.error') +I18nUtil.translate("common.forbidden") +t( + 'common.unavailable', + locale='en-US', +) +ResponseUtil.success(msg_key='profile.localeSaved') +my_t('missing.otherFunction') +item.t('missing.otherObject') +OtherI18nUtil.translate('missing.otherClass') +t('missing.' + suffix) +t(f'missing.{suffix}') +` + ) + // 生成模块和内置模块使用同一个 core 域;新增分片不需要修改扫描配置。 + const modulePath = (code) => + join(root, 'i18n/catalogs', code, 'LC_MESSAGES/core/generated.sample.order.po') + function moduleCatalog(code, translation) { + return `msgid "" +msgstr "" +"Language: ${code}\\n" +"Content-Type: text/plain; charset=UTF-8\\n" + +msgid "generated.sample.order.created" +msgstr "${translation}" +` + } + await writeFile(modulePath('zh-CN'), moduleCatalog('zh-CN', '订单已创建')) + const missingModule = check() + assert.equal(missingModule.status, 1, JSON.stringify(missingModule.report)) + assert.ok( + missingModule.report.diagnostics.some( + (item) => + item.code === 'missing-translation' && + item.key === 'generated.sample.order.created' && + item.message.includes('en-US') + ) + ) + await writeFile(modulePath('en-US'), moduleCatalog('en-US', 'Order created')) + let result = check() + assert.equal(result.status, 0, JSON.stringify(result.report)) + assert.ok(result.report.data.projects[0].coverage.every((item) => item.total > 0)) + const unused = new Set( + result.report.diagnostics.filter((item) => item.code === 'unused-key').map((item) => item.key) + ) + for (const key of [ + 'common.success', + 'generated.sample.order.created', + 'common.failure', + 'common.error', + 'common.forbidden', + 'common.unavailable', + 'profile.localeSaved', + ]) { + assert.ok(!unused.has(key), `Usage was not found: ${key}`) + } + + await writeFile( + join(root, 'missing.py'), + `t('missing.shortEntry')\nI18nUtil.translate("missing.classEntry")\n` + ) + await writeFile( + join(scaffold, 'backend.py'), + `ResponseUtil.failure(msg_key='missing.scaffoldBackend')\n` + ) + result = check() + assert.equal(result.status, 1) + assert.deepEqual( + new Set( + result.report.diagnostics + .filter((item) => item.code === 'missing-key') + .map((item) => item.key) + ), + new Set(['missing.shortEntry', 'missing.classEntry', 'missing.scaffoldBackend']) + ) + } finally { + await rm(root, { recursive: true, force: true }) + } +}) diff --git a/ruoyi-fastapi-backend/Dockerfile.my b/ruoyi-fastapi-backend/Dockerfile.my index f872739dc..62973ce19 100644 --- a/ruoyi-fastapi-backend/Dockerfile.my +++ b/ruoyi-fastapi-backend/Dockerfile.my @@ -10,6 +10,8 @@ COPY . . # 安装依赖 RUN pip install --no-cache-dir -r requirements.txt -i ${PIP_INDEX_URL} +RUN python scripts/compile_i18n.py + # 暴露端口 EXPOSE 9099 diff --git a/ruoyi-fastapi-backend/Dockerfile.pg b/ruoyi-fastapi-backend/Dockerfile.pg index 28ddb35bd..daa2907d9 100644 --- a/ruoyi-fastapi-backend/Dockerfile.pg +++ b/ruoyi-fastapi-backend/Dockerfile.pg @@ -10,6 +10,8 @@ COPY . . # 安装依赖 RUN pip install --no-cache-dir -r requirements-pg.txt -i ${PIP_INDEX_URL} +RUN python scripts/compile_i18n.py + # 暴露端口 EXPOSE 9099 diff --git a/ruoyi-fastapi-backend/app.py b/ruoyi-fastapi-backend/app.py index 1ae047082..d9f0ebfca 100644 --- a/ruoyi-fastapi-backend/app.py +++ b/ruoyi-fastapi-backend/app.py @@ -1,8 +1,11 @@ import uvicorn from config.env import AppConfig +from scripts.compile_i18n import compile_catalogs from server import create_app +compile_catalogs(isolate_plugin_errors=True) + if __name__ != '__main__': app = create_app() diff --git a/ruoyi-fastapi-backend/cli/runtime/plugin/scaffold/assets/web/dev.html.tmpl b/ruoyi-fastapi-backend/cli/runtime/plugin/scaffold/assets/web/dev.html.tmpl index d895436db..3d21dc786 100644 --- a/ruoyi-fastapi-backend/cli/runtime/plugin/scaffold/assets/web/dev.html.tmpl +++ b/ruoyi-fastapi-backend/cli/runtime/plugin/scaffold/assets/web/dev.html.tmpl @@ -63,6 +63,7 @@

__PLUGIN_ID__ · 模拟宿主

仅使用本地模拟响应,不连接真实后端。此页面不进入生产构建。

+ + ) +} + +test('language changes update React text and html.lang without remounting a draft', async () => { + i18n.setAccount(null) + await i18n.setPreference('zh-CN') + render( + + + + ) + const input = screen.getByRole('textbox', { name: 'draft' }) + fireEvent.change(input, { target: { value: 'unsaved input' } }) + await act(() => i18n.setPreference('en-US')) + expect(screen.getByText('Username')).toBeTruthy() + expect(screen.getByRole('textbox', { name: 'draft' })).toBe(input) + expect(input.value).toBe('unsaved input') + expect(document.documentElement.lang).toBe('en-US') + await act(() => i18n.setPreference('zh-CN')) +}) + +function ValidationEditor() { + const { t } = useI18n() + const [form] = Form.useForm() + useLocalizedFormErrors(form) + const [notice, setNotice] = useLocalizedText('') + return ( +
+ + + + + + + + + + + + {notice} +
+ ) +} + +test('locale changes refresh shown errors and local dialog text while keeping untouched fields and drafts', async () => { + await i18n.setPreference('zh-CN') + render() + const draft = screen.getByRole('textbox', { name: 'preserved draft' }) + fireEvent.change(draft, { target: { value: 'unsaved business value' } }) + fireEvent.click(screen.getByRole('button', { name: 'validate' })) + fireEvent.click(screen.getByRole('button', { name: 'show notice' })) + expect(await screen.findByText('字典名称不能为空')).toBeTruthy() + expect(screen.getByText('修改')).toBeTruthy() + await act(() => i18n.setPreference('en-US')) + expect(await screen.findByText('Dictionary name is required')).toBeTruthy() + expect(screen.getByText('Edit')).toBeTruthy() + expect(screen.queryByText('untouched validation')).toBeNull() + expect(screen.getByRole('textbox', { name: 'preserved draft' })).toBe(draft) + expect(draft.value).toBe('unsaved business value') + await act(() => i18n.setPreference('zh-CN')) +}) + +function DictionaryReader() { + const values = useDict('i18n_test_status') + return ( + + {values.i18n_test_status.map((item) => `${item.label}:${item.value}`).join(',')} + + ) +} + +test('dictionary labels update from cached maps without another request or changing business values', async () => { + clearDictCache() + getDicts.mockResolvedValue({ + data: [{ dictLabel: '启用', dictLabelI18n: { 'en-US': 'Enabled' }, dictValue: '0' }], + }) + await i18n.setPreference('zh-CN') + render() + expect(await screen.findByText('启用:0')).toBeTruthy() + await act(() => i18n.setPreference('en-US')) + expect(await screen.findByText('Enabled:0')).toBeTruthy() + expect(getDicts).toHaveBeenCalledTimes(1) + await act(() => i18n.setPreference('zh-CN')) +}) + +test('exported designer forms translate at runtime and preserve user labels, validation text and drafts', async () => { + await i18n.setPreference('en-US') + const fields = [ + { + tag: 'Input', + vModel: 'business', + label: '保留用户标签', + required: true, + regList: [{ pattern: '/^ok$/', message: '保留用户提示' }], + }, + { tag: 'Input', vModel: 'notes', label: '用户备注' }, + ] + const source = makeUpJs(fields, { formBtns: true, size: 'default' }) + const executable = source + .replace(/^import[^\n]+\n/gm, '') + .replace('export default function', 'function') + const compiled = await transformWithOxc(executable, 'GeneratedForm.jsx', { + jsx: { runtime: 'classic' }, + }) + const scope = { + React, + Form, + Input, + Row, + Col, + Button, + Space, + useI18n, + useLocalizedFormErrors, + fieldRules, + } + const GeneratedForm = new Function( + ...Object.keys(scope), + `${compiled.code}; return GeneratedForm` + )(...Object.values(scope)) + render() + const draft = screen.getByRole('textbox', { name: '用户备注' }) + fireEvent.change(draft, { target: { value: '保留草稿' } }) + fireEvent.click(screen.getByRole('button', { name: 'Submit' })) + expect(await screen.findByText('Enter 保留用户标签')).toBeTruthy() + await act(() => i18n.setPreference('zh-CN')) + expect(await screen.findByText('请填写保留用户标签')).toBeTruthy() + expect(screen.getByRole('button', { name: /提\s*交/ })).toBeTruthy() + expect(screen.getByRole('textbox', { name: '用户备注' })).toBe(draft) + expect(draft.value).toBe('保留草稿') + fireEvent.change(screen.getByRole('textbox', { name: '保留用户标签' }), { + target: { value: 'invalid' }, + }) + expect(await screen.findByText('保留用户提示')).toBeTruthy() +}) + +function PluginEditor() { + const { t } = usePluginI18n() + return ( + + ) +} + +test('a source plugin subscribes to its own engine and preserves a draft when the host switches language', async () => { + i18n.setAccount(null) + await act(async () => i18n.setPreference('zh-CN')) + render() + const input = screen.getByRole('textbox', { name: 'plugin draft' }) + fireEvent.change(input, { target: { value: 'unsaved plugin input' } }) + await act(async () => i18n.setPreference('en-US')) + expect(screen.getByText('Model code')).toBeTruthy() + expect(screen.getByRole('textbox', { name: 'plugin draft' })).toBe(input) + expect(input.value).toBe('unsaved plugin input') + expect(i18n.engine.hasResourceBundle('en-US', 'plugin.ai')).toBe(false) +}) diff --git a/ruoyi-fastapi-frontend/react/web/tests/react/translationFields.test.jsx b/ruoyi-fastapi-frontend/react/web/tests/react/translationFields.test.jsx new file mode 100644 index 000000000..0f213c552 --- /dev/null +++ b/ruoyi-fastapi-frontend/react/web/tests/react/translationFields.test.jsx @@ -0,0 +1,84 @@ +import React from 'react' +import { Button, Form } from 'antd' +import { act, fireEvent, render, screen, waitFor } from '@testing-library/react' +import { expect, test, vi } from 'vitest' +import TranslationFields from '@/components/TranslationFields' +import BusinessFileUpload from '@/components/BusinessFileUpload' +import { i18n } from '@/i18n' + +test('source and English labels identify separate editable values in the submitted form', async () => { + i18n.setAccount(null) + await act(() => i18n.setPreference('zh-CN')) + const onFinish = vi.fn() + render( +
+ + + + ) + const source = screen.getByRole('textbox', { name: '字典名称' }) + const english = screen.getByRole('textbox', { name: '字典名称 · English' }) + expect(source.closest('.ant-space-compact').textContent).toContain('简体中文') + expect(english.closest('.ant-space-compact').textContent).toContain('English') + expect(source.value).toBe('原始名称') + expect(english.value).toBe('Original name') + fireEvent.change(english, { target: { value: 'Updated English name' } }) + expect(source.value).toBe('原始名称') + fireEvent.click(screen.getByRole('button', { name: '收起译名' })) + expect(screen.queryByRole('textbox', { name: '字典名称 · English' })).toBeNull() + fireEvent.click(screen.getByRole('button', { name: 'Save translations' })) + await waitFor(() => + expect(onFinish).toHaveBeenCalledWith({ + dictName: '原始名称', + dictNameI18n: { 'en-US': 'Updated English name' }, + }) + ) +}) + +test('a new record only shows translation inputs after Add translation', async () => { + await act(() => i18n.setPreference('en-US')) + render( +
+ + + ) + expect(screen.queryByRole('textbox', { name: 'Menu name · English' })).toBeNull() + fireEvent.click(screen.getByRole('button', { name: 'Add translation' })) + expect(screen.getByRole('textbox', { name: 'Menu name · English' }).maxLength).toBe(50) +}) + +test.each(['zh-CN', 'en-US'])( + 'business upload guidance resolves a string in %s', + async (locale) => { + await act(() => i18n.setPreference(locale)) + const { container } = render( + + ) + const hint = container.querySelector('small').textContent + expect(hint.startsWith(i18n.t('common:upload') + ' ')).toBe(true) + expect(hint).toContain('pdf') + expect(hint).not.toContain('returned an object') + } +) diff --git a/ruoyi-fastapi-frontend/react/web/tests/security/logout.test.mjs b/ruoyi-fastapi-frontend/react/web/tests/security/logout.test.mjs index 643d17261..cbb1f0be5 100644 --- a/ruoyi-fastapi-frontend/react/web/tests/security/logout.test.mjs +++ b/ruoyi-fastapi-frontend/react/web/tests/security/logout.test.mjs @@ -1,3 +1,7 @@ -import { runLogoutTests } from '../../../../../ruoyi-fastapi-test/frontend/logout-behavior.mjs' +import { + runLogoutTests, + runUserInfoSessionTests, +} from '../../../../../ruoyi-fastapi-test/frontend/logout-behavior.mjs' runLogoutTests(new URL('../../', import.meta.url), 'react-web') +runUserInfoSessionTests(new URL('../../', import.meta.url), 'react-web') diff --git a/ruoyi-fastapi-frontend/react/web/x18n.config.mjs b/ruoyi-fastapi-frontend/react/web/x18n.config.mjs new file mode 100644 index 000000000..1369b76ee --- /dev/null +++ b/ruoyi-fastapi-frontend/react/web/x18n.config.mjs @@ -0,0 +1,15 @@ +import { existsSync, readdirSync } from 'node:fs' + +// 每个项目单独声明语言,新增宿主语言不会要求插件补齐该语言。 +const plugins = new URL('./plugins/', import.meta.url) +export default { + projects: [ + 'src/i18n', + ...readdirSync(plugins, { withFileTypes: true }) + .filter( + (entry) => + entry.isDirectory() && existsSync(new URL(`${entry.name}/x18n.config.mjs`, plugins)) + ) + .map((entry) => `plugins/${entry.name}`), + ], +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/package.json b/ruoyi-fastapi-frontend/vue2/mobile/package.json index 314381e01..c53ea6339 100644 --- a/ruoyi-fastapi-frontend/vue2/mobile/package.json +++ b/ruoyi-fastapi-frontend/vue2/mobile/package.json @@ -55,7 +55,9 @@ "test:unit": "node --experimental-vm-modules --test tests/behavior.test.mjs", "test:contract": "node --test tests/time.test.mjs tests/time-polyfill.test.mjs", "test:bundle": "node --test tests/time-bundle.test.cjs tests/h5-template.test.cjs", - "test": "pnpm run test:unit && pnpm run test:time" + "test": "pnpm run test:unit && pnpm run test:time", + "i18n:check": "node scripts/check-i18n.mjs && x18n --root . check --json", + "test:i18n": "node --test tests/i18n/*.test.mjs" }, "dependencies": { "@dcloudio/uni-app": "2.0.2-5020620260917001", @@ -89,6 +91,7 @@ "core-js": "3.50.0", "dayjs": "1.11.23", "flyio": "0.6.14", + "i18next": "26.5.11", "node-forge": "1.4.0", "regenerator-runtime": "0.14.1", "vue": "2.6.14", @@ -116,6 +119,7 @@ "@vue/cli-plugin-babel": "5.0.9", "@vue/cli-plugin-typescript": "5.0.9", "@vue/cli-service": "5.0.9", + "@x18n/cli": "0.1.14", "autoprefixer": "10.6.1", "babel-loader": "8.4.1", "babel-plugin-import": "1.13.8", diff --git a/ruoyi-fastapi-frontend/vue2/mobile/pnpm-lock.yaml b/ruoyi-fastapi-frontend/vue2/mobile/pnpm-lock.yaml index 809120b73..ab96f8d0b 100644 --- a/ruoyi-fastapi-frontend/vue2/mobile/pnpm-lock.yaml +++ b/ruoyi-fastapi-frontend/vue2/mobile/pnpm-lock.yaml @@ -104,6 +104,9 @@ importers: flyio: specifier: 0.6.14 version: 0.6.14 + i18next: + specifier: 26.5.11 + version: 26.5.11(typescript@5.9.3) node-forge: specifier: 1.4.0 version: 1.4.0 @@ -180,6 +183,9 @@ importers: '@vue/cli-service': specifier: 5.0.9 version: 5.0.9(@vue/compiler-sfc@3.5.44)(clean-css@5.3.3)(csso@4.2.0)(html-minifier-terser@6.1.0)(lodash@4.18.1)(mustache@3.2.1)(prettier@3.9.10)(sass-loader@14.2.1(sass@1.105.2)(webpack@5.112.0(clean-css@5.3.3)(cssnano@5.1.15(postcss@8.5.30))(csso@4.2.0)(html-minifier-terser@6.1.0)(postcss@8.5.30)(sharp@0.35.5(@types/node@26.6.5))(svgo@2.8.4)))(sharp@0.35.5(@types/node@26.6.5))(supports-color@8.1.1)(svgo@2.8.4)(vue-template-compiler@2.6.14)(vue@2.6.14)(webpack-sources@3.6.0) + '@x18n/cli': + specifier: 0.1.14 + version: 0.1.14(@devframes/agentic@1.2.5(crossws@0.4.17(srvx@1.0.8))(devframe@1.2.6))(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(typescript@5.9.3) autoprefixer: specifier: 10.6.1 version: 10.6.1(postcss@8.5.30) @@ -1380,6 +1386,11 @@ packages: '@dcloudio/webpack-uni-pages-loader@2.0.2-5020620260917001': resolution: {integrity: sha512-ZdneeVW+uF+6ePqxl+YytKEyOfFKeTlGrWD97M5BKptSRmdS9zivj8y4tsVQDukaLTjZbMwMPqNJ+9bai/WJiw==} + '@devframes/agentic@1.2.5': + resolution: {integrity: sha512-2bVZFxGD7C+U1y0vkesUnLWHtrU3qD/Gq/Ri+aWkpXhDe/0EQ64ODA9gxCqFunUvJZ5z1rFvP1XLRLfUiSpvGg==} + peerDependencies: + devframe: 1.2.5 + '@discoveryjs/json-ext@0.5.7': resolution: {integrity: sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==} engines: {node: '>=10.0.0'} @@ -1886,6 +1897,14 @@ packages: '@messageformat/runtime@3.0.3': resolution: {integrity: sha512-FE0hP0m15+9p/ia5HWQ/JsUSNLcxZkl1jl1HlRrWCiMAsgiulg7AuOFLaBR6dpPqtPWWuApY7VLo3rIAcrgrkA==} + '@modelcontextprotocol/client@2.4.0': + resolution: {integrity: sha512-LgrD2OphHuG12vfKFKz6SOnq7bKHQmhGJIAYdD+MZBn2npHEyry6uD8zvktodtl5CQM85MO0anUyD9JwmUmxww==} + engines: {node: '>=20'} + + '@modelcontextprotocol/core@2.4.0': + resolution: {integrity: sha512-z8QBKqdfXLPzkLQuG4xp8hrVEMm1PZ1IgxMN2sMbJiFiAKOWXnAzogXn2W4aqIBlP1ea6U5yiqVquvUNM1Cj6Q==} + engines: {node: '>=20'} + '@modelcontextprotocol/sdk@1.32.1': resolution: {integrity: sha512-2DdE+SJDtzLEEWzY1ZjY7Q+VcPhcV1KisD3zI4u0XZyktsjHum1mwbMI+JaulUBi2OZk+KJAi2uPXzxichPkdw==} engines: {node: '>=18'} @@ -1896,6 +1915,10 @@ packages: '@cfworker/json-schema': optional: true + '@modelcontextprotocol/server@2.4.0': + resolution: {integrity: sha512-rgR9yxSaAJ+bcsi/XroT/S2AfPiIWloXAnrdfYSCms9ivVju0ishu/wW0J21Ho6+ZOR1r7RyeRbjiRuF87ix5Q==} + engines: {node: '>=20'} + '@node-ipc/js-queue@2.0.3': resolution: {integrity: sha512-fL1wpr8hhD5gT2dA1qifeVaoDFlQR5es8tFuKqjHX+kdOtdNHnxkVZbtIrR2rxnMFvehkjaZRNV2H/gPXlb0hw==} engines: {node: '>=1.0.0'} @@ -1918,42 +1941,84 @@ packages: cpu: [arm] os: [android] + '@oxc-parser/binding-android-arm-eabi@0.155.0': + resolution: {integrity: sha512-A6xv7hDtnTm+xlZ7utn6rRQpRMJHRhVr3gjRGqlx0RUX84mNk0pAsy6YN/wWhuOTkaZhRrrzaLxf0NfbH77j2w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + '@oxc-parser/binding-android-arm64@0.154.0': resolution: {integrity: sha512-UHrDPELzvWZoVkIDdSycj4bzcTMCJG3IbN++mSUgVBaUtNtWHjQ98U6Vz5bpF/1Ic3FYJyYhMr74huO5tVvpZw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [android] + '@oxc-parser/binding-android-arm64@0.155.0': + resolution: {integrity: sha512-T1wWwH9/JI5g7Z4kEQwDOwhToxdDhRyOTklH+uuNpJ16m3MZFmGl+l2rKc0NHQdbVRG2LTOBsNjpW3h1BWytPA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + '@oxc-parser/binding-darwin-arm64@0.154.0': resolution: {integrity: sha512-mokYzajOSXxtSRDWCdHARGdntrKH+rZZ24Jzo8AtafyNzz0NARmpMm26Tc5B6qiGrr6UliWibHCOif1qRN2vaA==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [darwin] + '@oxc-parser/binding-darwin-arm64@0.155.0': + resolution: {integrity: sha512-ZoRB3qJxJ8DWA41jHja+YeB0lLfjBy4T+Kr15vnN1k65X3zbJt3rPZftEwN4Ju4tmA4K/T9dWWD7Z8ewQLnrVA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + '@oxc-parser/binding-darwin-x64@0.154.0': resolution: {integrity: sha512-WbtUBrclOVItWfLRSvs+Z/WLtXxJ2Ctv50PyuX894HzDN5/e0qzxVpTNPIVMzOerBhgKtFsSMcfxlYIAbvdVgg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [darwin] + '@oxc-parser/binding-darwin-x64@0.155.0': + resolution: {integrity: sha512-vxtL86BtM+IgrpejA86nbTk5j0HKTIMeuaJ1fQciw6p9RfavPtIPjI7gN34owap0yG9txXBaAWpGdxokNwdqIw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + '@oxc-parser/binding-freebsd-x64@0.154.0': resolution: {integrity: sha512-YooHZSLawOe2fqm+lDdG8oAaQh2NYV/RMYTYzWRLy72stm2BgE9O/8Al6kFENjkmzyyBccDLLBirGxVtpzQfrw==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [freebsd] + '@oxc-parser/binding-freebsd-x64@0.155.0': + resolution: {integrity: sha512-tN6Ru5e0UVnWaIuiH8jEwnvxuxg7FvhWwSd3oe5oDhOD4ObsSr9/N6WfHLjilUWlPPj65ptwrSDH0Y7lzwTzmw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + '@oxc-parser/binding-linux-arm-gnueabihf@0.154.0': resolution: {integrity: sha512-hKOwhZbrXdTwc4bGVfbLCXl9f2swl6zWdISocLQSNX9MgPmwHE3qGzOUkCrkuGpwdCVHPnkfOwsqTuYsrP5uNg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm] os: [linux] + '@oxc-parser/binding-linux-arm-gnueabihf@0.155.0': + resolution: {integrity: sha512-h4ozA5n6L6lwolsz9iwunEhKWnIVbmFRots5QxEix0H6nJ5ICpuDa7PuShuhfpIDFe3+Qvyscioyiv+9g+4Syg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + '@oxc-parser/binding-linux-arm-musleabihf@0.154.0': resolution: {integrity: sha512-tnjiooXEU013349O/yxKbF5Cusp1CfHWQ8kYR8tGeRzR/P4sOpQGQo21fsS71M0fMD6ESLq+lbvXFWi43PuKeQ==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm] os: [linux] + '@oxc-parser/binding-linux-arm-musleabihf@0.155.0': + resolution: {integrity: sha512-058/+LardpfuUlsKIvBGk/CYoakEVcMgqYx8GgyUZeOxFWTojYLlCc1Gb60/y21v3esDhHidgiY/Zbq9LpBhaQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + '@oxc-parser/binding-linux-arm64-gnu@0.154.0': resolution: {integrity: sha512-Cao2kj+8d7BT6XJU1gV9eVQjV+Cr+e8vQm3tddDRZiM2hHrMDxwy3j6t+ofaSl0idyuPPCZ4AlpmQoj8yOT1QA==} engines: {node: ^20.19.0 || >=22.12.0} @@ -1961,6 +2026,13 @@ packages: os: [linux] libc: [glibc] + '@oxc-parser/binding-linux-arm64-gnu@0.155.0': + resolution: {integrity: sha512-nrOt2Y3xIAzu+lSPzH0864ieO+iCCXgoo9qFlGANE8Xh0cQ+RP8Wstfp+/wXN2YCyb98cAGzX0VruKYw7it/jw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + '@oxc-parser/binding-linux-arm64-musl@0.154.0': resolution: {integrity: sha512-uiwA0V3q8llWA7/8r+a9BBjk4j5YMDmi6wfOsyQfGOJMQSLHEiZ3HI8ulea766ykUa9wJFWk9XWEl4uJrZLQqw==} engines: {node: ^20.19.0 || >=22.12.0} @@ -1968,6 +2040,13 @@ packages: os: [linux] libc: [musl] + '@oxc-parser/binding-linux-arm64-musl@0.155.0': + resolution: {integrity: sha512-KYAayyN5hQbJPtGKtRxlyc8XYmyntOplyXSQzTDrmbz7l/GCrzQbSswvyJFBTH1LGtsZrbXOAfN52i/Kz6kLKg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + '@oxc-parser/binding-linux-ppc64-gnu@0.154.0': resolution: {integrity: sha512-LICfN0Xs4Zdko+bJy6eOAEQojDuIR26suF2JtOsMaXjgbCrpRSH7/NCvJhY13YvYBx12V6hnwrL8n0lk0rbNJQ==} engines: {node: ^20.19.0 || >=22.12.0} @@ -1975,6 +2054,13 @@ packages: os: [linux] libc: [glibc] + '@oxc-parser/binding-linux-ppc64-gnu@0.155.0': + resolution: {integrity: sha512-CSuSY5hfjtsBnHXydOj8jiNfS1qHbdPZuPz1YL1cSgK7VmNYP+QlZIbG0BBYYBgX/vYEgZwbG9mBdW4YairZ5w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + '@oxc-parser/binding-linux-riscv64-gnu@0.154.0': resolution: {integrity: sha512-gbbSYxLF8ssRbQ2qQPy+2EhGNwNH1bAoRdkk6cnWaKHqmCikpSIPtpXjFbCCtjTi0uojqOM3ghFQwQPbDQsU0Q==} engines: {node: ^20.19.0 || >=22.12.0} @@ -1982,6 +2068,13 @@ packages: os: [linux] libc: [glibc] + '@oxc-parser/binding-linux-riscv64-gnu@0.155.0': + resolution: {integrity: sha512-7KCfOQm+Nz2N8trAXbQkal4TQ5756WVEmhm35y816YHvyFnEfVsICsiV5k0pEszNf/fRm4cm2i6i18SJ6/iCWg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + libc: [glibc] + '@oxc-parser/binding-linux-riscv64-musl@0.154.0': resolution: {integrity: sha512-nSnRYYDLCcRVjSQzF3g6rKqCNYwo5o+aQgnn8BBXfe+ofCgMGlGqkfRyvXm6ptZvoxNkkWtLlqM8W7Xc3j6ZnQ==} engines: {node: ^20.19.0 || >=22.12.0} @@ -1989,6 +2082,13 @@ packages: os: [linux] libc: [musl] + '@oxc-parser/binding-linux-riscv64-musl@0.155.0': + resolution: {integrity: sha512-JSlhgoK+/g1TGJI5NuADx2+6syhxnQNLCWLXyO5QLFyetomcr/vIxSdiNlmyAv963YXUzCuwAwRG6npZ5xyJ1A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + libc: [musl] + '@oxc-parser/binding-linux-s390x-gnu@0.154.0': resolution: {integrity: sha512-BxBQoJKtzRQgZEKQIt6CDUm8RGKC5T8Qo4576yDa5/xgc10X3fBDItMbRabzLtbUBfTqKLl+8AVr/H6CF7W22g==} engines: {node: ^20.19.0 || >=22.12.0} @@ -1996,6 +2096,13 @@ packages: os: [linux] libc: [glibc] + '@oxc-parser/binding-linux-s390x-gnu@0.155.0': + resolution: {integrity: sha512-WFIX+dPokWp64mi434Md3U3lJaTwNxAphvGjpltoyQjGUsdXavOIRrnp9dOS34Hd75HOAwDxAI+YwWOwqmJbtg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + '@oxc-parser/binding-linux-x64-gnu@0.154.0': resolution: {integrity: sha512-/whkust2vYy+GjRUVL5cWaJmEu6jkdFfo5mkxgckyeOX61eMwo4iBoiwzeJZeMWAdzb/XOtQyLApHhFht3sOWA==} engines: {node: ^20.19.0 || >=22.12.0} @@ -2003,6 +2110,13 @@ packages: os: [linux] libc: [glibc] + '@oxc-parser/binding-linux-x64-gnu@0.155.0': + resolution: {integrity: sha512-g6xSDC/JpbnVOz5uafMGyK3txBVRFMQTx8opv/yHXGxqV3ZMVl3bf7W8XrSnF68dmy3gM4dgReNryuE53+WkeQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + '@oxc-parser/binding-linux-x64-musl@0.154.0': resolution: {integrity: sha512-EXURTyW9riw4B/kZnnE+58emAtw6+3VEszQfXUZkRqGaKIcmWDYkZtKB+xY/blHvuZ+Qy/fDclc31nmUCgtkSA==} engines: {node: ^20.19.0 || >=22.12.0} @@ -2010,33 +2124,67 @@ packages: os: [linux] libc: [musl] + '@oxc-parser/binding-linux-x64-musl@0.155.0': + resolution: {integrity: sha512-6/4xlxKlZJWrQ0uwDFPc0H9+xLu7068CKhX3vIDW3SbvP/lVgnVuT5v6dyugeWskWpuxqF/WJ4WKwhxjU3pG2w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + '@oxc-parser/binding-openharmony-arm64@0.154.0': resolution: {integrity: sha512-ZRFooyH3qsR6vuR4jFGlG3XM36490SvvXtNaUahBK4zHpooMdTHNaOMtGGJI0EW38m5hi4rOco9kw7ZwCIp28w==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [openharmony] + '@oxc-parser/binding-openharmony-arm64@0.155.0': + resolution: {integrity: sha512-tltklL0J0XjDxIRTBXWOBhvc2mitcmES45pIxhwDWfxRyqz7Vkeu0NekTZEIxGE4f/lXgq3vZcjjffteQOVorg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + '@oxc-parser/binding-win32-arm64-msvc@0.154.0': resolution: {integrity: sha512-U0Vp+4lvwUa/PnOCJTZOjydj1rX2+VLHz4Y2vSFqlN8/7LTiURgD7z4uQ9yNv9O/NlU3mELBnPDlu7aaSYG1zQ==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [arm64] os: [win32] + '@oxc-parser/binding-win32-arm64-msvc@0.155.0': + resolution: {integrity: sha512-alAb9TzjatUEsOeoncAziUnfdTDxfyswhalFZ9sC6plUgATIUx2NIZ0+bMn6aJ28AduS1OpG/OAisr/YISn4Ig==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + '@oxc-parser/binding-win32-ia32-msvc@0.154.0': resolution: {integrity: sha512-Hc8QgsFY5eUUP25we8TISUruibG2cDt0H4IcPG9RKdabb6odkCzIqjV6Gk9beGWGuOwMVCr81H/Su1q363LCCg==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [ia32] os: [win32] + '@oxc-parser/binding-win32-ia32-msvc@0.155.0': + resolution: {integrity: sha512-yc5cbSfcGmRv/KpxDFuyk8adEBaWd/9HilWvBbQ4bFbus1V2PUh2mGB2Cfq9rqZTqLeiMT8x0skV+LKp9hOMgQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ia32] + os: [win32] + '@oxc-parser/binding-win32-x64-msvc@0.154.0': resolution: {integrity: sha512-hD7judkUMA/hZPoamvKADs6+an1smp8UTK0aMYRijkvi00K/1vl7vEtmyn2JyQ9S+vibtnfcNzxqTLGyJUZCRQ==} engines: {node: ^20.19.0 || >=22.12.0} cpu: [x64] os: [win32] + '@oxc-parser/binding-win32-x64-msvc@0.155.0': + resolution: {integrity: sha512-8heq6jGq+rfpTDRDjoQiBHw0maQZf3IXkS99pdHQZPoTL5kyF5qyPS0RidUlSdnWDIqxXb5nux7GBD9cT+imUw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + '@oxc-project/types@0.154.0': resolution: {integrity: sha512-KYOUGQFlLWR+s4QMV2Q9ko38TZm7EdO87Qm7rvZLqk/webse/cDjtyxKhg/47l0byCbs/k46LT8qc4PKjAikzA==} + '@oxc-project/types@0.155.0': + resolution: {integrity: sha512-SeE8JPwW1xs1tHeNycjUtUBdhorRa8o4jlvjwk49R7/Z291i+4DQa7JJIgOm/TaYQZx+QrPQbVJ/9c8dMIZN8Q==} + '@parcel/watcher-android-arm64@2.6.0': resolution: {integrity: sha512-trgpLSCKRC/huFjXX/Smh+0sWe4+YtKfktIToiMl59ghz7z+qkH6kMvNnUbLyRs9N11t8l4svSCs1+5B3rOAhA==} engines: {node: '>= 10.0.0'} @@ -2150,6 +2298,11 @@ packages: '@soda/get-current-script@1.0.2': resolution: {integrity: sha512-T7VNNlYVM1SgQ+VsMYhnDkcGmWhQdL0bDyGm5TlQ3GBXnJscEClUUOKduWTmm2zCnvNLC1hc3JpuXjs/nFOc5w==} + '@sveltejs/acorn-typescript@1.0.13': + resolution: {integrity: sha512-wgKggnhZVL9Bfx1OaKKTrYY9BFRk6C8UAkQNUcIv1+llzYrIqy+RZm5HPKzn0NpEBvTVhTqB4kQyllZywsRBRQ==} + peerDependencies: + acorn: ^8.9.0 + '@tailwindcss/node@4.3.3': resolution: {integrity: sha512-/T8IKEsf9VTU6tLjgC7+sv2mOPtQxzE2jMw7u4Tt40Tx+QSZxpzh95/H6cMKoja9XuW7iMdLJYBB0o9G1CaAgg==} @@ -2371,6 +2524,11 @@ packages: '@types/yauzl@2.10.3': resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==} + '@valibot/to-json-schema@1.8.0': + resolution: {integrity: sha512-a0M+uwCuQZEPAo65NYkFSJ14O5c213KoSZmPdoCfuFvUhfULi4T2Z6Tpjv6lTVMW9RoLm74RpRAjNEa43KcN+g==} + peerDependencies: + valibot: ^1.5.0 + '@vue/babel-helper-vue-jsx-merge-props@1.4.0': resolution: {integrity: sha512-JkqXfCkUDp4PIlFdDQ0TdXoIejMtTHP67/pvxlgeY+u5k3LEdKuWZ3LK6xkxo52uDoABIVyRwqVkfLQJhk7VBA==} @@ -2764,6 +2922,25 @@ packages: '@webassemblyjs/wast-printer@1.9.0': resolution: {integrity: sha512-2J0nE95rHXHyQ24cWjMKJ1tqB/ds8z/cyeOZxJhcb+rW+SQASVjuznUSmdz5GpVJTzU8JkhYut0D3siFDD6wsA==} + '@x18n/builtins@0.1.14': + resolution: {integrity: sha512-ezxyuOAK+YsAL4PbVPyZTOpwsZp1Qoo2vIr8MJQivcQyC80GAaxbpQvmRExikhnThH/OyienjaGRceUsDBYQ6g==} + + '@x18n/cli@0.1.14': + resolution: {integrity: sha512-b38DwR0ZUWujNNIsVE/tRQ4tud5wACIyui4dN578T85r8iH5VvfxNjBj7m8LYOwxNwVGOOheenskVItRvVQEQw==} + engines: {node: '>=22'} + hasBin: true + + '@x18n/core@0.1.14': + resolution: {integrity: sha512-gQWKzyX2B9Ppl3AG6Fcls+bshqUJMhfbgtzbFeKlDKNE6IS/w7VSHkm/NLEnLEfxTenwFFQAAPL5NO7i/Ke0Fw==} + + '@x18n/node@0.1.14': + resolution: {integrity: sha512-Q5W9mjap2fL3CeDmbPrgH11KuKLju3LplAtHvmH6iPttNKgy1JkwOyuKjAr2dpgErRYJOEHhpY4ySZ3j0JNyag==} + engines: {node: '>=22'} + + '@x18n/ui@0.1.14': + resolution: {integrity: sha512-5JH91Lli5V66oYk26ebaaEUN6vdhAibWSAX30wxFZLdy952jvKkwzOwQMJlO9b7ftHU/lZneYNH/8+0fH2ZCaQ==} + engines: {node: '>=22'} + '@xtuc/ieee754@1.2.0': resolution: {integrity: sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==} @@ -2939,6 +3116,10 @@ packages: argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} + aria-query@5.3.1: + resolution: {integrity: sha512-Z/ZeOgVl7bcSYZ/u/rh0fOpvEpq//LZmdbkXyc7syVzjPAhfOa9ebsdTSjEBDU4vs5nC98Kfduj1uFo0qyET3g==} + engines: {node: '>= 0.4'} + arr-diff@4.0.0: resolution: {integrity: sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==} engines: {node: '>=0.10.0'} @@ -3038,6 +3219,10 @@ packages: aws4@1.13.2: resolution: {integrity: sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==} + axobject-query@4.1.0: + resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==} + engines: {node: '>= 0.4'} + babel-jest@25.5.1: resolution: {integrity: sha512-9dA9+GmMjIzgPnYtkhBg73gOo/RHqPmLruP3BaGL4KEX3Dwz6pI8auSN8G8+iuEG90+GSswyKvslN+JYSaacaQ==} engines: {node: '>= 8.3'} @@ -3342,6 +3527,10 @@ packages: resolution: {integrity: sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==} engines: {node: '>= 20.19.0'} + chokidar@6.0.0: + resolution: {integrity: sha512-Ec2Z7wpcKBiMpR7DxteoqS/sq5G5d2A4fpxzPv6+fD7xNNdrTghn7L11YwV5EN1B3i72Erc3XVT5FkWIDx90+A==} + engines: {node: '>= 22.22'} + chownr@1.1.4: resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} @@ -3402,6 +3591,10 @@ packages: resolution: {integrity: sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==} engines: {node: '>=0.8'} + clsx@2.1.1: + resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==} + engines: {node: '>=6'} + co-body@5.2.0: resolution: {integrity: sha512-sX/LQ7LqUhgyaxzbe7IqwPeTr2yfpfUIQ/dgpKo6ZI4y4lpQA0YxAomWIY+7I7rHWcG02PG+OuPREzMW/5tszQ==} @@ -3804,6 +3997,14 @@ packages: resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} + crossws@0.4.17: + resolution: {integrity: sha512-YG2kyfafNXKmu7e6k64yrj6whrw7m5sBIsOSXOlJ/72X3TQWRQuw8DhvXFDcBk8HF77PnTSygnm7xpYCTnFpow==} + peerDependencies: + srvx: '>=0.11.5' + peerDependenciesMeta: + srvx: + optional: true + crypt@0.0.2: resolution: {integrity: sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==} @@ -4088,6 +4289,21 @@ packages: detect-node@2.1.0: resolution: {integrity: sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==} + devalue@5.9.4: + resolution: {integrity: sha512-sPAT4pztbu6586/hrhOnMKS17IJrvg12mXiSPSS3W5qDeN2RGgvZ0diZCm31dBbnevfVmujNO3IM2wrS4Y2Rhg==} + + devframe@1.2.6: + resolution: {integrity: sha512-mHzcm6ADzXgRMWdoSX+5PjwhmwAuC3SpDPi3+URznlpzxJF6tXwy5h1xr82zPKju38EVtdnYRnnP4hZwLK01vA==} + hasBin: true + peerDependencies: + '@devframes/agentic': 1.2.6 + cac: ^7.0.0 + peerDependenciesMeta: + '@devframes/agentic': + optional: true + cac: + optional: true + diff-sequences@25.2.6: resolution: {integrity: sha512-Hq8o7+6GaZeoFjtpgvRBUknSXNeJiCx7V9Fr94ZMljNiCr9n9L8H8aJqgWOQiDDGdyn29fRNcDdRVJ5fdyihfg==} engines: {node: '>= 8.3'} @@ -4303,11 +4519,22 @@ packages: resolution: {integrity: sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==} engines: {node: '>=4.0.0'} + esm-env@1.2.2: + resolution: {integrity: sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==} + esprima@4.0.1: resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==} engines: {node: '>=4'} hasBin: true + esrap@2.4.0: + resolution: {integrity: sha512-CQPcneEHw/czj32uwQC52nYnax8H4SXt25FCM+LIwGZ49cMIxpOj3bP8wmzcI+Z0HIy5KkClaPhRLfCySzwHPA==} + peerDependencies: + '@typescript-eslint/types': ^8.2.0 + peerDependenciesMeta: + '@typescript-eslint/types': + optional: true + esrecurse@4.3.0: resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} engines: {node: '>=4.0'} @@ -4461,6 +4688,15 @@ packages: fd-slicer@1.1.0: resolution: {integrity: sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==} + fdir@6.5.0: + resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} + engines: {node: '>=12.0.0'} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + figgy-pudding@3.5.2: resolution: {integrity: sha512-0btnI/H8f2pavGMN8w40mlSKOfTK2SVJmBfBeVIj3kNw0swwgzyRq0d5TJVOwodFmtvpPeWPN/MCcfuWF0Ezbw==} deprecated: This module is no longer supported. @@ -4727,6 +4963,19 @@ packages: resolution: {integrity: sha512-ax7ZYomf6jqPTQ4+XCpUGyXKHk5WweS+e05MBO4/y3WJ5RkmPXNKvX+bx1behVILVwr6JSQvZAku021CHPXG3Q==} engines: {node: '>=10'} + h3@2.0.8: + resolution: {integrity: sha512-ENuKlF9kC6E6PrvY1PUyE0qkrnnPTIt2/v48uyEEfTVfgoiqBCE0uwwf++2XrWwT1gxjQBDLQ8PAsmZVniKvTw==} + engines: {node: '>=20.19.0'} + hasBin: true + peerDependencies: + crossws: ^0.4.12 + ocache: '>=0.3.0' + peerDependenciesMeta: + crossws: + optional: true + ocache: + optional: true + handle-thing@2.0.1: resolution: {integrity: sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg==} @@ -4923,6 +5172,14 @@ packages: resolution: {integrity: sha512-rR122qceQidRpn/oJE16fC1rNtYUZsrgpQ8vKkFgu6hTgcM/s0yMBsGpj0Nbe2df8gh3Fb10AeEyWFZZZatvPg==} engines: {node: '>=10'} + i18next@26.5.11: + resolution: {integrity: sha512-Wc0klBPKxqZ2tL2qdAnF8xvvnWgr1IMGSY2ikTiAvaFVbz7xiFARtkoU4RidBDw1SyziGROp0qxu6qnJ7l2Wug==} + peerDependencies: + typescript: ^5 || ^6 || ^7 + peerDependenciesMeta: + typescript: + optional: true + iconv-lite@0.4.24: resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} engines: {node: '>=0.10.0'} @@ -4954,6 +5211,10 @@ packages: resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} engines: {node: '>= 4'} + ignore@7.0.14: + resolution: {integrity: sha512-wCBiZ77u1tuWde6G/nfOtLaCTYcFDU5yCzARzK10y+rLhzYoL7a7yEemcopcc2Mzow7gZOIjnV2ym1NYmdiJOQ==} + engines: {node: '>= 4'} + immediate@3.0.6: resolution: {integrity: sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==} @@ -5150,6 +5411,9 @@ packages: is-promise@4.0.0: resolution: {integrity: sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==} + is-reference@3.0.3: + resolution: {integrity: sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==} + is-regex@1.2.1: resolution: {integrity: sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==} engines: {node: '>= 0.4'} @@ -5669,6 +5933,9 @@ packages: resolution: {integrity: sha512-++gUqRDEvcnN6Zhqrr+y/CkVEHhlrR96vZn3nZZPYzMcBUyBtTKzB9NadClFIsIVSsu+3i9tfk/erqy9kAmt7Q==} engines: {node: '>=14'} + locate-character@3.0.0: + resolution: {integrity: sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==} + locate-path@3.0.0: resolution: {integrity: sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==} engines: {node: '>=6'} @@ -6103,6 +6370,9 @@ packages: resolution: {integrity: sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==} engines: {node: '>=10'} + nostics@1.3.0: + resolution: {integrity: sha512-wzRsrJwNlFbqIRQt8aCeL2WE8USip/uuvGSOZV1D02CxX8ABTMbw8IywKjH7yWHETMXbWJI4OBpihg9rmz2Vyg==} + npm-run-path@2.0.2: resolution: {integrity: sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw==} engines: {node: '>=4'} @@ -6223,6 +6493,10 @@ packages: resolution: {integrity: sha512-Gr/6fkjZwi937c4Tsz8y0iO4U0FLPkZI6JSVucLAIvQyqh379px7RS8ORIc0HOORbFjXZ6zyqWLl53qxhSeofw==} engines: {node: ^20.19.0 || >=22.12.0} + oxc-parser@0.155.0: + resolution: {integrity: sha512-C/ReSf1JUFukK/zvk6jhcNibSssvas5+ktIzK7fbKVd3CedWe59C3QwHEOrEZj/4Rt9+xg0Jeis/Jv1F/KM1mw==} + engines: {node: ^20.19.0 || >=22.12.0} + oxc-walker@1.1.1: resolution: {integrity: sha512-Hwd7dq28zu/Er99+bpWp16CGwFrhyalJh0W3JOB7XpPvgWo3MqMi2ksWGKuzzA9zt50mJ2pIUwR5lpAdZ9ACNQ==} peerDependencies: @@ -7289,6 +7563,10 @@ packages: resolution: {integrity: sha512-5Di9UC0+8h1L6ZD2d7awM7E/T4uA1fJRlx6zk/NvdCCVEoAnFqvHmCuNeIKoCeIixBX/q8uM+6ycDvF8woqosA==} engines: {node: '>= 0.8'} + rou3@1.0.0: + resolution: {integrity: sha512-ySeaQkSrua+ut9g+65I7FHqOFBaY8tV0FmccXItoq0q21se32Q3u4YiW7/RqXSosWgYJaaKwRHXy3BST9PeCNQ==} + engines: {node: '>=20.19.0'} + router@2.2.0: resolution: {integrity: sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==} engines: {node: '>= 18'} @@ -7628,6 +7906,11 @@ packages: sprintf-js@1.0.3: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} + srvx@1.0.8: + resolution: {integrity: sha512-ngFS/J6St4PJfHRHGjr78xkPPtbyXtdMOLNE4x/XZunEK3OhV7aGUWMHf9WTUEy6wm1U0W4okkd82ZFFWRVQTw==} + engines: {node: '>=20.16.0'} + hasBin: true + sshpk@1.18.0: resolution: {integrity: sha512-2p2KJZTSqQ/I3+HX42EpYOa2l3f8Erv8MWKsy2I9uf4wA7yFIkXRffYdsx86y6z4vHtV8u7g+pPlr8/4ouAxsQ==} engines: {node: '>=0.10.0'} @@ -7758,6 +8041,10 @@ packages: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} + svelte@5.57.3: + resolution: {integrity: sha512-5mAftM3SoDV9X0zdF386F9p2pv8iKOwi/KfBS1XnBAkVCKFzVOLHUoa8iGWAt4buoicLmyWVRpuuD5wplXOQsg==} + engines: {node: '>=18'} + svg-tags@1.0.0: resolution: {integrity: sha512-ovssysQTa+luh7A5Weu3Rta6FJlFBBbInjOh722LIt6klpU2/HtdUbszju/G4devcvk8PGt7FCLv5wftu3THUA==} @@ -7904,6 +8191,10 @@ packages: resolution: {integrity: sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==} engines: {node: '>=18'} + tinyglobby@0.2.17: + resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} + engines: {node: '>=12.0.0'} + tmpl@1.0.5: resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==} @@ -8157,6 +8448,14 @@ packages: resolution: {integrity: sha512-Rw6vJHj1mbdK8edjR7+zuJrpDtKIgNdAvTSAcpYfgMIw+u2dPDntD3dgN4XQFLU2/fvFQdzj+EeSGfd/jnY5fQ==} engines: {node: 8.x.x || >=10.10.0} + valibot@1.5.0: + resolution: {integrity: sha512-nil6AkP2TChWL43Z5uJ6GTxX01CUA+g8LWUM+N/rB9NBbkUMaUsi9PUNzlUPgoKASgmx9f7eGOYpJ04/fSa6FQ==} + peerDependencies: + typescript: '>=5' + peerDependenciesMeta: + typescript: + optional: true + validate-npm-package-license@3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} @@ -8535,6 +8834,9 @@ packages: resolution: {integrity: sha512-xYqdZFUK/VYazNl/oCDYN+3WloWQwMfZxBoiNt6qNyk+xfOdi598muWE42rNZFp1kNOiqW936q5RhUdnpqElSg==} engines: {node: '>=18'} + zimmerframe@1.1.5: + resolution: {integrity: sha512-msJxIvYDYcoNL+PJsu+7qmpDWsYmAxTY+2TNYXXF0hzBzBk0BMecOqDOG/EckUoKCuKwObfbugIl8QpqHDXeFA==} + zod-to-json-schema@3.25.2: resolution: {integrity: sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==} peerDependencies: @@ -9967,6 +10269,17 @@ snapshots: merge: 2.1.1 strip-json-comments: 2.0.1 + '@devframes/agentic@1.2.5(crossws@0.4.17(srvx@1.0.8))(devframe@1.2.6)': + dependencies: + '@modelcontextprotocol/client': 2.4.0 + '@modelcontextprotocol/server': 2.4.0 + devframe: 1.2.6(@devframes/agentic@1.2.5(crossws@0.4.17(srvx@1.0.8))(devframe@1.2.6))(cac@7.1.0)(srvx@1.0.8) + h3: 2.0.8(crossws@0.4.17(srvx@1.0.8)) + pathe: 2.0.3 + transitivePeerDependencies: + - crossws + - ocache + '@discoveryjs/json-ext@0.5.7': {} '@egoist/tailwindcss-icons@1.9.2(tailwindcss@4.3.3)': @@ -10797,6 +11110,20 @@ snapshots: dependencies: make-plural: 7.5.0 + '@modelcontextprotocol/client@2.4.0': + dependencies: + '@modelcontextprotocol/core': 2.4.0 + cross-spawn: 7.0.6 + eventsource: 3.0.7 + eventsource-parser: 3.1.1 + jose: 6.2.12 + pkce-challenge: 5.0.1 + zod: 4.6.7 + + '@modelcontextprotocol/core@2.4.0': + dependencies: + zod: 4.6.7 + '@modelcontextprotocol/sdk@1.32.1(supports-color@8.1.1)(zod@4.6.7)': dependencies: '@hono/node-server': 2.1.5(hono@4.13.13) @@ -10819,6 +11146,11 @@ snapshots: transitivePeerDependencies: - supports-color + '@modelcontextprotocol/server@2.4.0': + dependencies: + '@modelcontextprotocol/core': 2.4.0 + zod: 4.6.7 + '@node-ipc/js-queue@2.0.3': dependencies: easy-stack: 1.0.1 @@ -10838,62 +11170,121 @@ snapshots: '@oxc-parser/binding-android-arm-eabi@0.154.0': optional: true + '@oxc-parser/binding-android-arm-eabi@0.155.0': + optional: true + '@oxc-parser/binding-android-arm64@0.154.0': optional: true + '@oxc-parser/binding-android-arm64@0.155.0': + optional: true + '@oxc-parser/binding-darwin-arm64@0.154.0': optional: true + '@oxc-parser/binding-darwin-arm64@0.155.0': + optional: true + '@oxc-parser/binding-darwin-x64@0.154.0': optional: true + '@oxc-parser/binding-darwin-x64@0.155.0': + optional: true + '@oxc-parser/binding-freebsd-x64@0.154.0': optional: true + '@oxc-parser/binding-freebsd-x64@0.155.0': + optional: true + '@oxc-parser/binding-linux-arm-gnueabihf@0.154.0': optional: true + '@oxc-parser/binding-linux-arm-gnueabihf@0.155.0': + optional: true + '@oxc-parser/binding-linux-arm-musleabihf@0.154.0': optional: true + '@oxc-parser/binding-linux-arm-musleabihf@0.155.0': + optional: true + '@oxc-parser/binding-linux-arm64-gnu@0.154.0': optional: true + '@oxc-parser/binding-linux-arm64-gnu@0.155.0': + optional: true + '@oxc-parser/binding-linux-arm64-musl@0.154.0': optional: true + '@oxc-parser/binding-linux-arm64-musl@0.155.0': + optional: true + '@oxc-parser/binding-linux-ppc64-gnu@0.154.0': optional: true + '@oxc-parser/binding-linux-ppc64-gnu@0.155.0': + optional: true + '@oxc-parser/binding-linux-riscv64-gnu@0.154.0': optional: true + '@oxc-parser/binding-linux-riscv64-gnu@0.155.0': + optional: true + '@oxc-parser/binding-linux-riscv64-musl@0.154.0': optional: true + '@oxc-parser/binding-linux-riscv64-musl@0.155.0': + optional: true + '@oxc-parser/binding-linux-s390x-gnu@0.154.0': optional: true + '@oxc-parser/binding-linux-s390x-gnu@0.155.0': + optional: true + '@oxc-parser/binding-linux-x64-gnu@0.154.0': optional: true + '@oxc-parser/binding-linux-x64-gnu@0.155.0': + optional: true + '@oxc-parser/binding-linux-x64-musl@0.154.0': optional: true + '@oxc-parser/binding-linux-x64-musl@0.155.0': + optional: true + '@oxc-parser/binding-openharmony-arm64@0.154.0': optional: true + '@oxc-parser/binding-openharmony-arm64@0.155.0': + optional: true + '@oxc-parser/binding-win32-arm64-msvc@0.154.0': optional: true + '@oxc-parser/binding-win32-arm64-msvc@0.155.0': + optional: true + '@oxc-parser/binding-win32-ia32-msvc@0.154.0': optional: true + '@oxc-parser/binding-win32-ia32-msvc@0.155.0': + optional: true + '@oxc-parser/binding-win32-x64-msvc@0.154.0': optional: true + '@oxc-parser/binding-win32-x64-msvc@0.155.0': + optional: true + '@oxc-project/types@0.154.0': {} + '@oxc-project/types@0.155.0': {} + '@parcel/watcher-android-arm64@2.6.0': optional: true @@ -10979,6 +11370,10 @@ snapshots: '@soda/get-current-script@1.0.2': {} + '@sveltejs/acorn-typescript@1.0.13(acorn@8.19.0)': + dependencies: + acorn: 8.19.0 + '@tailwindcss/node@4.3.3': dependencies: '@jridgewell/remapping': 2.3.5 @@ -11201,6 +11596,10 @@ snapshots: '@types/node': 26.6.5 optional: true + '@valibot/to-json-schema@1.8.0(valibot@1.5.0(typescript@5.9.3))': + dependencies: + valibot: 1.5.0(typescript@5.9.3) + '@vue/babel-helper-vue-jsx-merge-props@1.4.0': {} '@vue/babel-helper-vue-transform-on@1.5.0': {} @@ -11976,6 +12375,74 @@ snapshots: '@webassemblyjs/wast-parser': 1.9.0 '@xtuc/long': 4.2.2 + '@x18n/builtins@0.1.14(typescript@5.9.3)': + dependencies: + '@vue/compiler-sfc': 3.5.44 + '@x18n/core': 0.1.14(typescript@5.9.3) + json5: 2.2.3 + jsonc-parser: 3.3.1 + oxc-parser: 0.155.0 + svelte: 5.57.3 + yaml: 2.9.1 + transitivePeerDependencies: + - '@typescript-eslint/types' + - typescript + + '@x18n/cli@0.1.14(@devframes/agentic@1.2.5(crossws@0.4.17(srvx@1.0.8))(devframe@1.2.6))(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(typescript@5.9.3)': + dependencies: + '@x18n/builtins': 0.1.14(typescript@5.9.3) + '@x18n/core': 0.1.14(typescript@5.9.3) + '@x18n/node': 0.1.14(typescript@5.9.3) + '@x18n/ui': 0.1.14(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(typescript@5.9.3) + cac: 7.1.0 + devframe: 1.2.6(@devframes/agentic@1.2.5(crossws@0.4.17(srvx@1.0.8))(devframe@1.2.6))(cac@7.1.0)(srvx@1.0.8) + nostics: 1.3.0 + yaml: 2.9.1 + transitivePeerDependencies: + - '@devframes/agentic' + - '@typescript-eslint/types' + - crossws + - ocache + - srvx + - typescript + + '@x18n/core@0.1.14(typescript@5.9.3)': + dependencies: + nostics: 1.3.0 + valibot: 1.5.0(typescript@5.9.3) + transitivePeerDependencies: + - typescript + + '@x18n/node@0.1.14(typescript@5.9.3)': + dependencies: + '@x18n/builtins': 0.1.14(typescript@5.9.3) + '@x18n/core': 0.1.14(typescript@5.9.3) + chokidar: 6.0.0 + ignore: 7.0.14 + jiti: 2.7.0 + jsonc-parser: 3.3.1 + tinyglobby: 0.2.17 + yaml: 2.9.1 + transitivePeerDependencies: + - '@typescript-eslint/types' + - typescript + + '@x18n/ui@0.1.14(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(typescript@5.9.3)': + dependencies: + '@devframes/agentic': 1.2.5(crossws@0.4.17(srvx@1.0.8))(devframe@1.2.6) + '@valibot/to-json-schema': 1.8.0(valibot@1.5.0(typescript@5.9.3)) + '@x18n/builtins': 0.1.14(typescript@5.9.3) + '@x18n/core': 0.1.14(typescript@5.9.3) + devframe: 1.2.6(@devframes/agentic@1.2.5(crossws@0.4.17(srvx@1.0.8))(devframe@1.2.6))(cac@7.1.0)(srvx@1.0.8) + valibot: 1.5.0(typescript@5.9.3) + transitivePeerDependencies: + - '@typescript-eslint/types' + - cac + - crossws + - ocache + - srvx + - typescript + '@xtuc/ieee754@1.2.0': {} '@xtuc/long@4.2.2': {} @@ -12137,6 +12604,8 @@ snapshots: argparse@2.0.1: {} + aria-query@5.3.1: {} + arr-diff@4.0.0: {} arr-flatten@1.1.0: {} @@ -12218,6 +12687,8 @@ snapshots: aws4@1.13.2: {} + axobject-query@4.1.0: {} + babel-jest@25.5.1(@babel/core@7.29.7(supports-color@8.1.1))(supports-color@8.1.1): dependencies: '@babel/core': 7.29.7(supports-color@8.1.1) @@ -12679,6 +13150,10 @@ snapshots: dependencies: readdirp: 5.1.1 + chokidar@6.0.0: + dependencies: + readdirp: 5.1.1 + chownr@1.1.4: {} chrome-simple-launcher@0.1.3: {} @@ -12749,6 +13224,8 @@ snapshots: clone@1.0.4: {} + clsx@2.1.1: {} + co-body@5.2.0: dependencies: inflation: 2.1.0 @@ -12999,6 +13476,10 @@ snapshots: shebang-command: 2.0.0 which: 2.0.2 + crossws@0.4.17(srvx@1.0.8): + optionalDependencies: + srvx: 1.0.8 + crypt@0.0.2: {} crypto-browserify@3.12.1: @@ -13283,6 +13764,21 @@ snapshots: detect-node@2.1.0: {} + devalue@5.9.4: {} + + devframe@1.2.6(@devframes/agentic@1.2.5(crossws@0.4.17(srvx@1.0.8))(devframe@1.2.6))(cac@7.1.0)(srvx@1.0.8): + dependencies: + crossws: 0.4.17(srvx@1.0.8) + h3: 2.0.8(crossws@0.4.17(srvx@1.0.8)) + nostics: 1.3.0 + pathe: 2.0.3 + optionalDependencies: + '@devframes/agentic': 1.2.5(crossws@0.4.17(srvx@1.0.8))(devframe@1.2.6) + cac: 7.1.0 + transitivePeerDependencies: + - ocache + - srvx + diff-sequences@25.2.6: {} diffie-hellman@5.0.3: @@ -13524,8 +14020,14 @@ snapshots: esrecurse: 4.3.0 estraverse: 4.3.0 + esm-env@1.2.2: {} + esprima@4.0.1: {} + esrap@2.4.0: + dependencies: + '@jridgewell/sourcemap-codec': 1.6.0 + esrecurse@4.3.0: dependencies: estraverse: 5.3.0 @@ -13783,6 +14285,10 @@ snapshots: dependencies: pend: 1.2.0 + fdir@6.5.0(picomatch@4.0.7): + optionalDependencies: + picomatch: 4.0.7 + figgy-pudding@3.5.2: {} figures@2.0.0: @@ -14083,6 +14589,13 @@ snapshots: dependencies: duplexer: 0.1.2 + h3@2.0.8(crossws@0.4.17(srvx@1.0.8)): + dependencies: + rou3: 1.0.0 + srvx: 1.0.8 + optionalDependencies: + crossws: 0.4.17(srvx@1.0.8) + handle-thing@2.0.1: {} har-schema@2.0.0: {} @@ -14307,6 +14820,10 @@ snapshots: transitivePeerDependencies: - supports-color + i18next@26.5.11(typescript@5.9.3): + optionalDependencies: + typescript: 5.9.3 + iconv-lite@0.4.24: dependencies: safer-buffer: 2.1.2 @@ -14331,6 +14848,8 @@ snapshots: ignore@5.3.2: {} + ignore@7.0.14: {} + immediate@3.0.6: {} immutable@5.1.9: {} @@ -14482,6 +15001,10 @@ snapshots: is-promise@4.0.0: {} + is-reference@3.0.3: + dependencies: + '@types/estree': 1.0.9 + is-regex@1.2.1: dependencies: call-bound: 1.0.4 @@ -15244,6 +15767,8 @@ snapshots: pkg-types: 2.3.3 quansync: 0.2.11 + locate-character@3.0.0: {} + locate-path@3.0.0: dependencies: p-locate: 3.0.0 @@ -15673,6 +16198,8 @@ snapshots: normalize-url@6.1.0: {} + nostics@1.3.0: {} + npm-run-path@2.0.2: dependencies: path-key: 2.0.1 @@ -15821,6 +16348,30 @@ snapshots: '@oxc-parser/binding-win32-ia32-msvc': 0.154.0 '@oxc-parser/binding-win32-x64-msvc': 0.154.0 + oxc-parser@0.155.0: + dependencies: + '@oxc-project/types': 0.155.0 + optionalDependencies: + '@oxc-parser/binding-android-arm-eabi': 0.155.0 + '@oxc-parser/binding-android-arm64': 0.155.0 + '@oxc-parser/binding-darwin-arm64': 0.155.0 + '@oxc-parser/binding-darwin-x64': 0.155.0 + '@oxc-parser/binding-freebsd-x64': 0.155.0 + '@oxc-parser/binding-linux-arm-gnueabihf': 0.155.0 + '@oxc-parser/binding-linux-arm-musleabihf': 0.155.0 + '@oxc-parser/binding-linux-arm64-gnu': 0.155.0 + '@oxc-parser/binding-linux-arm64-musl': 0.155.0 + '@oxc-parser/binding-linux-ppc64-gnu': 0.155.0 + '@oxc-parser/binding-linux-riscv64-gnu': 0.155.0 + '@oxc-parser/binding-linux-riscv64-musl': 0.155.0 + '@oxc-parser/binding-linux-s390x-gnu': 0.155.0 + '@oxc-parser/binding-linux-x64-gnu': 0.155.0 + '@oxc-parser/binding-linux-x64-musl': 0.155.0 + '@oxc-parser/binding-openharmony-arm64': 0.155.0 + '@oxc-parser/binding-win32-arm64-msvc': 0.155.0 + '@oxc-parser/binding-win32-ia32-msvc': 0.155.0 + '@oxc-parser/binding-win32-x64-msvc': 0.155.0 + oxc-walker@1.1.1(@oxc-project/types@0.154.0)(oxc-parser@0.154.0): optionalDependencies: '@oxc-project/types': 0.154.0 @@ -16936,6 +17487,8 @@ snapshots: hash-base: 3.1.2 inherits: 2.0.4 + rou3@1.0.0: {} + router@2.2.0(supports-color@8.1.1): dependencies: debug: 4.4.3(supports-color@8.1.1) @@ -17414,6 +17967,8 @@ snapshots: sprintf-js@1.0.3: {} + srvx@1.0.8: {} + sshpk@1.18.0: dependencies: asn1: 0.2.6 @@ -17553,6 +18108,26 @@ snapshots: supports-preserve-symlinks-flag@1.0.0: {} + svelte@5.57.3: + dependencies: + '@jridgewell/remapping': 2.3.5 + '@jridgewell/sourcemap-codec': 1.6.0 + '@sveltejs/acorn-typescript': 1.0.13(acorn@8.19.0) + '@types/estree': 1.0.9 + acorn: 8.19.0 + aria-query: 5.3.1 + axobject-query: 4.1.0 + clsx: 2.1.1 + devalue: 5.9.4 + esm-env: 1.2.2 + esrap: 2.4.0 + is-reference: 3.0.3 + locate-character: 3.0.0 + magic-string: 0.30.21 + zimmerframe: 1.1.5 + transitivePeerDependencies: + - '@typescript-eslint/types' + svg-tags@1.0.0: {} svgo@2.8.4: @@ -17695,6 +18270,11 @@ snapshots: tinyexec@1.3.1: {} + tinyglobby@0.2.17: + dependencies: + fdir: 6.5.0(picomatch@4.0.7) + picomatch: 4.0.7 + tmpl@1.0.5: {} to-array@0.1.4: {} @@ -17921,6 +18501,10 @@ snapshots: convert-source-map: 1.9.0 source-map: 0.7.6 + valibot@1.5.0(typescript@5.9.3): + optionalDependencies: + typescript: 5.9.3 + validate-npm-package-license@3.0.4: dependencies: spdx-correct: 3.2.0 @@ -18555,6 +19139,8 @@ snapshots: yoctocolors@2.2.0: {} + zimmerframe@1.1.5: {} + zod-to-json-schema@3.25.2(zod@4.6.7): dependencies: zod: 4.6.7 diff --git a/ruoyi-fastapi-frontend/vue2/mobile/scripts/check-i18n.mjs b/ruoyi-fastapi-frontend/vue2/mobile/scripts/check-i18n.mjs new file mode 100644 index 000000000..a2d103847 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/scripts/check-i18n.mjs @@ -0,0 +1,18 @@ +// 此处仅校验项目的语言注册约定,词条、占位符和翻译诊断交由 x18n。 +import { readFile, readdir } from 'node:fs/promises' +import { createLocaleRegistry } from '../src/i18n/runtime.mjs' + +const meta = JSON.parse(await readFile(new URL('../src/i18n/locale-meta.json', import.meta.url))) +const resources = {} +for (const entry of meta.locales.filter((item) => item.enabled)) { + const directory = new URL(`../src/i18n/locales/${entry.code}/`, import.meta.url) + const files = (await readdir(directory)).filter((name) => name.endsWith('.json')) + if (!files.length) throw new Error(`No resources: ${entry.code}`) + resources[entry.code] = {} + for (const file of files) + resources[entry.code][file.slice(0, -5)] = JSON.parse(await readFile(new URL(file, directory))) + if (!Object.keys(resources[entry.code].common || {}).length) + throw new Error(`Empty common namespace: ${entry.code}`) +} +createLocaleRegistry(meta, resources) +console.log(`Locale registration valid: ${Object.keys(resources).join(', ')}`) diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/App.vue b/ruoyi-fastapi-frontend/vue2/mobile/src/App.vue index abee11e07..88747ba43 100644 --- a/ruoyi-fastapi-frontend/vue2/mobile/src/App.vue +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/App.vue @@ -1,14 +1,17 @@ diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/adapter.js b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/adapter.js new file mode 100644 index 000000000..37b83b549 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/adapter.js @@ -0,0 +1,23 @@ +import Vue from 'vue' +import { i18n } from './index' + +export const localeState = Vue.observable({ + locale: i18n.locale, + preference: i18n.preference, +}) +i18n.engine.on('languageChanged', (locale) => { + localeState.locale = locale +}) +i18n.engine.on('preferenceChanged', (preference) => { + localeState.preference = preference +}) +export const t = (key, options) => { + void localeState.locale + return i18n.t(key, options) +} +export const useI18n = () => ({ state: localeState, t, i18n }) +export default { + install(Vue) { + Vue.prototype.$t = t + }, +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/index.js b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/index.js new file mode 100644 index 000000000..6e7d5b5c8 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/index.js @@ -0,0 +1,31 @@ +import '@/utils/time' // 原生端须先加载 Intl 兼容实现,再初始化 i18next。 +import '@formatjs/intl-pluralrules/locale-data/zh.js' +import '@formatjs/intl-numberformat/locale-data/zh.js' +import '@formatjs/intl-datetimeformat/locale-data/zh.js' +import { setMessageTranslator } from './message.mjs' +import appManifest from '../../package.json' +import { createLocaleRuntime } from './runtime.mjs' +import { meta, resources } from './registry' +import dayjs from 'dayjs' +import 'dayjs/locale/zh-cn' +import 'dayjs/locale/en' +import config from '@/config' + +export const i18n = createLocaleRuntime({ + appVersion: appManifest.version, + meta, + resources, + storage: { + get: (key) => uni.getStorageSync(key), + set: (key, value) => uni.setStorageSync(key, value), + }, + scope: 'ruoyi-vue2-mobile:' + (config.baseUrl || ''), + deviceLocales: () => [uni.getSystemInfoSync().language], + onChange(code, entry) { + dayjs.locale(entry.dayjs || 'en') + if (typeof uni.setLocale === 'function') uni.setLocale(code) + }, +}) +setMessageTranslator(i18n.t) +export const t = i18n.t +export const refreshDeviceLocale = () => i18n.refreshDeviceLocale() diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locale-meta.json b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locale-meta.json new file mode 100644 index 000000000..23564cac0 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locale-meta.json @@ -0,0 +1,27 @@ +{ + "sourceLocale": "zh-CN", + "defaultLocale": "zh-CN", + "locales": [ + { + "code": "zh-CN", + "nativeName": "简体中文", + "enabled": true, + "direction": "ltr", + "aliases": ["zh", "zh-Hans"], + "fallback": [], + "dayjs": "zh-cn" + }, + { + "code": "en-US", + "nativeName": "English", + "enabled": true, + "direction": "ltr", + "aliases": ["en"], + "fallback": ["zh-CN"], + "dayjs": "en" + } + ], + "languageFallbacks": { + "en": "en-US" + } +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/auth.json b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/auth.json new file mode 100644 index 000000000..c398ad863 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/auth.json @@ -0,0 +1,41 @@ +{ + "login": { + "code": "Verification code", + "submit": "Sign in", + "signingIn": "Signing in, please wait...", + "usernameRequired": "Enter your username", + "passwordRequired": "Enter your password", + "codeRequired": "Enter the verification code", + "title": "Sign in to RuoYi-FastAPI Mobile", + "noAccount": "No account yet?", + "acceptTerms": "By signing in, you agree to the", + "agreementLink": "User Agreement", + "and": "and", + "privacyLink": "Privacy Policy" + }, + "register": { + "link": "Sign up", + "usernameRequired": "Enter your username", + "passwordRequired": "Enter your password", + "confirmRequired": "Enter your password again", + "submitting": "Creating account, please wait...", + "confirmPlaceholder": "Enter your password again", + "submit": "Sign up", + "signIn": "Sign in with an existing account", + "success": "Your account {{username}} has been created successfully!", + "title": "Create a RuoYi-FastAPI Mobile account" + }, + "password": { + "oldRequired": "Enter your current password", + "newRequired": "Enter a new password", + "length": "Use 6 to 20 characters", + "confirmRequired": "Confirm your password", + "mismatch": "The passwords do not match", + "old": "Current password", + "oldPlaceholder": "Enter your current password", + "new": "New password", + "newPlaceholder": "Enter a new password", + "confirm": "Confirm password", + "confirmPlaceholder": "Confirm your new password" + } +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/common.json b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/common.json new file mode 100644 index 000000000..502c7d732 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/common.json @@ -0,0 +1,34 @@ +{ + "translationUnavailable": "Text unavailable", + "language": "Language", + "followDevice": "Follow device", + "save": "Save", + "cancel": "Cancel", + "confirm": "OK", + "loading": "Loading…", + "retry": "Retry", + "languageSaved": "Language preference saved", + "languageFailed": "Could not save the language preference. Please try again.", + "network": { + "error": "Could not connect to the server", + "timeout": "The request timed out", + "unauthorized": "Authentication failed. You cannot access this resource.", + "forbidden": "You do not have permission to perform this action.", + "notFound": "The requested resource was not found.", + "unknown": "An unexpected error occurred. Contact your administrator." + }, + "session": { + "expired": "Your session has expired. Stay on this page or sign in again?", + "signIn": "Sign in again", + "stay": "Stay on this page", + "invalid": "Your session is invalid or has expired. Please sign in again." + }, + "notice": "Notice", + "submitSuccess": "Submitted successfully", + "updateSuccess": "Updated successfully", + "submit": "Submit", + "createdDate": "Created on", + "saveFailed": "Could not save. Please try again.", + "more": "More", + "tip": "Tip" +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/file.json b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/file.json new file mode 100644 index 000000000..a57b92e7e --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/file.json @@ -0,0 +1,6 @@ +{ + "upload": { + "invalidResponse": "Invalid upload response", + "failed": "Upload failed" + } +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/mobile.json b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/mobile.json new file mode 100644 index 000000000..61a3b67c2 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/mobile.json @@ -0,0 +1,145 @@ +{ + "agreement": { + "title": "User Agreement", + "acceptanceTitle": "1. Acceptance of the terms of service", + "acceptance": "Welcome to the RuoYi-FastAPI mobile framework (the “Product”). RuoYi-FastAPI owns and operates the Product. Please read this agreement carefully before using the Product. By clicking “Agree” or using its services, you acknowledge that you have read and accepted all terms of this agreement.", + "accountTitle": "2. User accounts and security", + "account": "When registering an account, provide true, accurate, current and complete personal information. You are responsible for keeping your account and password secure and are legally responsible for all activities under your account. Notify us immediately if you discover unauthorized use.", + "conductTitle": "3. User conduct", + "conduct": "You must comply with applicable national laws and regulations when using the Product. You must not use it for unlawful activities, including publishing false information, infringing intellectual property rights, distributing obscene or pornographic material, or conducting cyberattacks.", + "serviceTitle": "4. Changes, interruptions or termination of service", + "service": "Due to the nature of online services, we reserve the right to change, interrupt or terminate some or all services at any time. We will try to announce interruptions caused by server maintenance or network failures in advance, but accept no liability for resulting losses.", + "ownershipTitle": "5. Intellectual property", + "ownership": "All content in the Product, including text, images, audio, video and software code, is the intellectual property of RuoYi-FastAPI or the relevant rights holders. Unauthorized use, copying, modification or distribution is prohibited.", + "disclaimerTitle": "6. Disclaimer", + "disclaimer": "The Product is provided “as is” without any express or implied warranties. We accept no liability for service interruptions or data loss caused by force majeure, cyberattacks or system instability.", + "updated": "Updated: January 1, 2024" + }, + "privacy": { + "title": "Privacy Policy", + "introduction": "RuoYi-FastAPI takes your privacy seriously. This policy explains how we collect, use, store and protect your personal information. Please read it carefully before using the Product.", + "collectionTitle": "1. How we collect and use your personal information", + "collection": "To provide better services, we may collect the following information:", + "account": "• Account information: When you register or sign in, we collect information such as your username, password and phone number.", + "device": "• Device information: To keep your account secure and improve our services, we collect your device model, operating system version and unique device identifier.", + "logs": "• Log information: When you use the Product, we automatically collect activity logs, IP addresses and access times.", + "sharingTitle": "2. How we share, transfer or disclose your personal information", + "sharing": "We do not share, transfer or publicly disclose your personal information to third parties, except:", + "consent": "• With your explicit authorization or consent;", + "law": "• As required by law, regulation or judicial authorities;", + "publicInterest": "• To protect national security, public safety or significant public interests.", + "securityTitle": "3. How we protect your personal information", + "security": "We use security measures including data encryption, access controls and security audits to protect your personal information. We work to prevent unauthorized access, alteration or disclosure.", + "rightsTitle": "4. Your rights", + "rights": "You have the right to access, correct or delete your personal information. You may also close your account at any time. To exercise these rights, contact us using the details in the Contact us section.", + "updatesTitle": "5. Updates to this policy", + "updates": "We may update this policy as laws, regulations or our business change. Updated policies will be published in the Product, and we will notify you appropriately before they take effect.", + "contactTitle": "6. Contact us", + "contact": "If you have questions or suggestions about this policy, contact us at:", + "email": "Email: xxx@xxx.com", + "updated": "Updated: January 1, 2024" + }, + "brand": "RuoYi-FastAPI Mobile", + "search": "Search...", + "dashboard": { + "healthy": "All systems operational", + "justUpdated": "Just updated", + "efficiency": "Productivity", + "notifications": "New notifications", + "tasks": "Pending tasks", + "quickLinks": "Quick links", + "apply": "Requests", + "news": "News", + "statistics": "Statistics", + "plans": "Plans", + "recent": "Recent updates", + "viewAll": "View all", + "leaveRequest": "Leave request", + "awaitingApproval": "Awaiting manager approval", + "pending": "Pending", + "weeklyReport": "Weekly report", + "completed": "Completed" + }, + "about": { + "version": "Version", + "email": "Email", + "phone": "Support phone", + "website": "Website", + "title": "About us" + }, + "avatar": { + "generating": "Generating image...", + "select": "Choose avatar" + }, + "help": { + "product": "About RuoYi-FastAPI", + "openSourceQuestion": "Is RuoYi-FastAPI open source?", + "openSourceAnswer": "Yes, it is open source.", + "commercialQuestion": "Can I use RuoYi-FastAPI commercially?", + "commercialAnswer": "Yes, commercial use is allowed.", + "websiteQuestion": "What is the RuoYi-FastAPI website?", + "docsQuestion": "Where is the RuoYi-FastAPI documentation?", + "other": "Other questions", + "logoutQuestion": "How do I sign out?", + "logoutAnswer": "Go to Me → App settings → Sign out.", + "avatarQuestion": "How do I change my avatar?", + "avatarAnswer": "Go to Me → Choose avatar, then tap Submit.", + "passwordQuestion": "How do I change my password?", + "passwordAnswer": "Go to Me → App settings → Change password.", + "title": "Help" + }, + "comingSoon": "Coming soon", + "profile": { + "view": "View profile", + "signIn": "Tap to sign in", + "group": "Community chat", + "support": "Online support", + "feedback": "Feedback community", + "like": "Like us", + "edit": "Edit profile" + }, + "settings": { + "title": "App settings", + "logoutConfirm": "Are you sure you want to sign out?", + "password": "Change password", + "timezone": "Time zone settings", + "checkUpdate": "Check for updates", + "clearCache": "Clear cache", + "logout": "Sign out" + }, + "timezone": { + "readFailed": "Could not load account settings. Try saving again or reopen this page.", + "saved": "Time zone saved", + "auto": "Follow device automatically", + "display": "Display time zone", + "searchPlaceholder": "Search time zones, e.g. Asia/Shanghai", + "search": "Search time zones", + "choose": "Choose a display time zone", + "noResults": "No matching time zones. Try a different search.", + "loadFailed": "Could not load the time zone list. You can still use the current time zone.", + "preview": "Time preview", + "previewZone": "Preview time zone:", + "previewTime": "Preview time:", + "deviceUnsupported": "The device time zone could not be detected. The system time zone is used; you can also choose one manually.", + "description": "Used for time display, date filters and exports. Scheduled tasks and business statistics use their own configured time zones.", + "save": "Save time zone" + }, + "work": { + "ai": "AI productivity", + "chat": "AI chat", + "assistant": "AI assistant", + "image": "Image generation", + "creative": "Creative studio" + }, + "nav": { + "home": "Home", + "work": "Workspace", + "mine": "Me", + "login": "Sign in", + "register": "Sign up", + "avatar": "Change avatar", + "profile": "Profile", + "webview": "Web page", + "textview": "Text viewer" + } +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/monitor.json b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/monitor.json new file mode 100644 index 000000000..611e87ab5 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/monitor.json @@ -0,0 +1,5 @@ +{ + "log": { + "title": "Logs" + } +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/system.json b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/system.json new file mode 100644 index 000000000..f725c3e34 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/system.json @@ -0,0 +1,38 @@ +{ + "user": { + "male": "Male", + "female": "Female", + "nicknameRequired": "Enter a nickname", + "phoneRequired": "Enter a phone number", + "phoneInvalid": "Enter a valid phone number", + "emailRequired": "Enter an email address", + "emailInvalid": "Enter a valid email address", + "nickname": "Nickname", + "nicknamePlaceholder": "Enter a nickname", + "phone": "Phone number", + "phonePlaceholder": "Enter a phone number", + "email": "Email", + "emailPlaceholder": "Enter an email address", + "sex": "Gender", + "nicknameShort": "Nickname", + "post": "Post", + "role": "Role", + "title": "Users" + }, + "management": "System management", + "role": { + "title": "Roles" + }, + "dept": { + "title": "Departments" + }, + "config": { + "title": "Configuration" + }, + "dict": { + "title": "Dictionaries" + }, + "notice": { + "title": "Announcements" + } +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/utility.json b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/utility.json new file mode 100644 index 000000000..3b818e4de --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/en-US/utility.json @@ -0,0 +1,21 @@ +{ + "crypto": { + "randomFormat": "Unsupported random value format: tag={{arg0}}, keys={{arg1}}", + "randomUnavailable": "Secure random numbers are unavailable in this environment", + "publicKeyFailed": "Could not retrieve the transport public key", + "keyProtocol": "Unsupported transport public key protocol version", + "keyAlgorithm": "Unsupported transport public key algorithm", + "responseProtocol": "Unsupported transport response protocol version", + "responseAlgorithm": "Unsupported transport response algorithm", + "keyVersion": "Transport response key version mismatch", + "headerVersion": "Transport response header and body key versions do not match", + "aad": "Invalid transport response AAD", + "requestMismatch": "The transport response method/path does not match the request", + "direction": "Invalid transport response direction", + "queryLength": "Encrypted GET/DELETE parameters are too long. Use POST or reduce the query parameters.", + "missingContext": "Missing response decryption context", + "envelope": "Invalid transport response envelope", + "randomPool": "The secure random pool is exhausted and this environment cannot refill it synchronously" + }, + "httpStatus": "The API request failed with status {{status}}" +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/auth.json b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/auth.json new file mode 100644 index 000000000..b47c18f59 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/auth.json @@ -0,0 +1,41 @@ +{ + "login": { + "code": "验证码", + "submit": "登 录", + "signingIn": "登录中,请耐心等待...", + "usernameRequired": "请输入账号", + "passwordRequired": "请输入密码", + "codeRequired": "请输入验证码", + "title": "RuoYi-FastAPI移动端登录", + "noAccount": "没有账号?", + "acceptTerms": "登录即代表同意", + "agreementLink": "《用户协议》", + "and": "和", + "privacyLink": "《隐私协议》" + }, + "register": { + "link": "立即注册", + "usernameRequired": "请输入您的账号", + "passwordRequired": "请输入您的密码", + "confirmRequired": "请再次输入您的密码", + "submitting": "注册中,请耐心等待...", + "confirmPlaceholder": "请输入重复密码", + "submit": "注 册", + "signIn": "使用已有账号登录", + "success": "恭喜你,您的账号 {{username}} 注册成功!", + "title": "RuoYi-FastAPI移动端注册" + }, + "password": { + "oldRequired": "旧密码不能为空", + "newRequired": "新密码不能为空", + "length": "长度在 6 到 20 个字符", + "confirmRequired": "确认密码不能为空", + "mismatch": "两次输入的密码不一致", + "old": "旧密码", + "oldPlaceholder": "请输入旧密码", + "new": "新密码", + "newPlaceholder": "请输入新密码", + "confirm": "确认密码", + "confirmPlaceholder": "请确认新密码" + } +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/common.json b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/common.json new file mode 100644 index 000000000..c85251054 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/common.json @@ -0,0 +1,34 @@ +{ + "translationUnavailable": "暂无可用文本", + "language": "语言", + "followDevice": "跟随设备", + "save": "保存", + "cancel": "取消", + "confirm": "确定", + "loading": "加载中…", + "retry": "重试", + "languageSaved": "语言设置已保存", + "languageFailed": "语言设置保存失败,请重试", + "network": { + "error": "后端接口连接异常", + "timeout": "系统接口请求超时", + "unauthorized": "认证失败,无法访问系统资源", + "forbidden": "当前操作没有权限", + "notFound": "访问资源不存在", + "unknown": "系统未知错误,请反馈给管理员" + }, + "session": { + "expired": "登录状态已过期,您可以继续留在该页面,或者重新登录?", + "signIn": "重新登录", + "stay": "留在此页", + "invalid": "无效的会话,或者会话已过期,请重新登录。" + }, + "notice": "系统提示", + "submitSuccess": "提交成功", + "updateSuccess": "修改成功", + "submit": "提交", + "createdDate": "创建日期", + "saveFailed": "保存失败,请重试", + "more": "更多", + "tip": "提示" +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/file.json b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/file.json new file mode 100644 index 000000000..8581ea291 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/file.json @@ -0,0 +1,6 @@ +{ + "upload": { + "invalidResponse": "上传响应格式不正确", + "failed": "上传失败" + } +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/mobile.json b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/mobile.json new file mode 100644 index 000000000..85a0b5b8b --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/mobile.json @@ -0,0 +1,145 @@ +{ + "agreement": { + "title": "用户协议", + "acceptanceTitle": "1. 服务条款的确认和接纳", + "acceptance": "欢迎使用RuoYi-FastAPI移动端框架(以下简称“本产品”)。本产品的服务所有权和运作权归RuoYi-FastAPI所有。用户在使用本产品前,请仔细阅读本协议。当您点击“同意”或实际使用本产品服务时,即视为您已阅读并完全同意本协议的所有条款。", + "accountTitle": "2. 用户账号与安全", + "account": "您在注册账号时,应提供真实、准确、最新和完整的个人资料。您有责任维护账号和密码的安全,并对以您账号进行的所有活动承担法律责任。如发现账号被非法使用,请立即通知我们。", + "conductTitle": "3. 用户行为规范", + "conduct": "用户在使用本产品过程中,必须遵守国家法律法规,不得利用本产品从事违法违规活动,包括但不限于:发布虚假信息、侵犯他人知识产权、传播淫秽色情信息、进行网络攻击等。", + "serviceTitle": "4. 服务内容的变更、中断或终止", + "service": "鉴于网络服务的特殊性,我们有权随时变更、中断或终止部分或全部网络服务。对于因服务器维护、网络故障等原因导致的服务中断,我们将尽量提前公告,但不对因此产生的损失承担责任。", + "ownershipTitle": "5. 知识产权声明", + "ownership": "本产品包含的所有内容(包括但不限于文字、图片、音频、视频、软件代码等)的知识产权归RuoYi-FastAPI或相关权利人所有。未经授权,任何人不得擅自使用、复制、修改或传播。", + "disclaimerTitle": "6. 免责声明", + "disclaimer": "本产品按“现状”提供,不包含任何明示或暗示的保证。我们不对因不可抗力、黑客攻击、系统不稳定等原因导致的服务中断或数据丢失承担责任。", + "updated": "更新日期:2024年01月01日" + }, + "privacy": { + "title": "隐私协议", + "introduction": "RuoYi-FastAPI非常重视您的隐私保护。本隐私政策旨在向您说明我们如何收集、使用、存储和保护您的个人信息。请您在使用本产品前仔细阅读本政策。", + "collectionTitle": "1. 我们如何收集和使用您的个人信息", + "collection": "为了向您提供更好的服务,我们可能会收集您的以下信息:", + "account": "• 账号信息:当您注册或登录时,我们需要收集您的用户名、密码、手机号码等信息。", + "device": "• 设备信息:为了保障账户安全和优化服务,我们会收集您的设备型号、操作系统版本、唯一设备标识符等信息。", + "logs": "• 日志信息:当您使用本产品时,我们会自动收集您的操作日志、IP地址、访问时间等信息。", + "sharingTitle": "2. 我们如何共享、转让、公开披露您的个人信息", + "sharing": "我们不会向任何第三方共享、转让或公开披露您的个人信息,但以下情况除外:", + "consent": "• 获得您的明确授权或同意;", + "law": "• 根据法律法规或司法机关的要求;", + "publicInterest": "• 为了维护国家安全、公共安全或重大公共利益。", + "securityTitle": "3. 我们如何保护您的个人信息", + "security": "我们采取了多种安全措施来保护您的个人信息,包括数据加密、访问控制、安全审计等。我们会尽力防止您的信息被未经授权的访问、篡改或泄露。", + "rightsTitle": "4. 您的权利", + "rights": "您有权访问、更正或删除您的个人信息。您也可以随时注销账号。如您需要行使这些权利,请通过“联系我们”章节中的方式与我们联系。", + "updatesTitle": "5. 本政策如何更新", + "updates": "随着法律法规的变化或业务的发展,我们可能会不时更新本隐私政策。更新后的政策将在本产品中发布,并在生效前通过适当方式通知您。", + "contactTitle": "6. 联系我们", + "contact": "如果您对本隐私政策有任何疑问或建议,请通过以下方式联系我们:", + "email": "邮箱:xxx@xxx.com", + "updated": "更新日期:2024年01月01日" + }, + "brand": "RuoYi-FastAPI移动端", + "search": "搜索...", + "dashboard": { + "healthy": "系统运行正常", + "justUpdated": "刚刚更新", + "efficiency": "工作效率", + "notifications": "新通知", + "tasks": "待办任务", + "quickLinks": "快捷入口", + "apply": "申请", + "news": "新闻", + "statistics": "统计", + "plans": "计划", + "recent": "最近更新", + "viewAll": "查看全部", + "leaveRequest": "请假申请", + "awaitingApproval": "等待经理审批", + "pending": "待处理", + "weeklyReport": "周报", + "completed": "已完成" + }, + "about": { + "version": "版本信息", + "email": "官方邮箱", + "phone": "服务热线", + "website": "公司网站", + "title": "关于我们" + }, + "avatar": { + "generating": "图片生成中...", + "select": "选择头像" + }, + "help": { + "product": "RuoYi-FastAPI问题", + "openSourceQuestion": "RuoYi-FastAPI开源吗?", + "openSourceAnswer": "开源", + "commercialQuestion": "RuoYi-FastAPI可以商用吗?", + "commercialAnswer": "可以", + "websiteQuestion": "RuoYi-FastAPI官网地址多少?", + "docsQuestion": "RuoYi-FastAPI文档地址多少?", + "other": "其他问题", + "logoutQuestion": "如何退出登录?", + "logoutAnswer": "请点击[我的] - [应用设置] - [退出登录]即可退出登录", + "avatarQuestion": "如何修改用户头像?", + "avatarAnswer": "请点击[我的] - [选择头像] - [点击提交]即可更换用户头像", + "passwordQuestion": "如何修改登录密码?", + "passwordAnswer": "请点击[我的] - [应用设置] - [修改密码]即可修改登录密码", + "title": "常见问题" + }, + "comingSoon": "模块建设中~", + "profile": { + "view": "查看个人信息", + "signIn": "点击登录", + "group": "交流群", + "support": "在线客服", + "feedback": "反馈社区", + "like": "点赞我们", + "edit": "编辑资料" + }, + "settings": { + "title": "应用设置", + "logoutConfirm": "确定注销并退出系统吗?", + "password": "修改密码", + "timezone": "时区设置", + "checkUpdate": "检查更新", + "clearCache": "清理缓存", + "logout": "退出登录" + }, + "timezone": { + "readFailed": "账号设置读取失败,请重试保存或重新进入页面", + "saved": "时区设置已保存", + "auto": "自动跟随设备", + "display": "显示时区", + "searchPlaceholder": "搜索时区,例如 Asia/Shanghai", + "search": "搜索时区", + "choose": "选择显示时区", + "noResults": "没有匹配的时区,请修改搜索词。", + "loadFailed": "时区列表加载失败,仍可使用当前时区。", + "preview": "时间预览", + "previewZone": "预览时区:", + "previewTime": "时间预览:", + "deviceUnsupported": "当前设备无法识别时区,已使用系统时区;你也可以手动选择。", + "description": "用于时间显示、日期筛选和导出。定时任务和业务统计使用各自配置的时区。", + "save": "保存时区" + }, + "work": { + "ai": "AI 生产力", + "chat": "智能对话", + "assistant": "智能助手", + "image": "图像生成", + "creative": "创意工坊" + }, + "nav": { + "home": "首页", + "work": "工作台", + "mine": "我的", + "login": "登录", + "register": "注册", + "avatar": "修改头像", + "profile": "个人信息", + "webview": "浏览网页", + "textview": "浏览文本" + } +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/monitor.json b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/monitor.json new file mode 100644 index 000000000..b132e4592 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/monitor.json @@ -0,0 +1,5 @@ +{ + "log": { + "title": "日志管理" + } +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/system.json b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/system.json new file mode 100644 index 000000000..def2a0d8a --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/system.json @@ -0,0 +1,38 @@ +{ + "user": { + "male": "男", + "female": "女", + "nicknameRequired": "用户昵称不能为空", + "phoneRequired": "手机号码不能为空", + "phoneInvalid": "请输入正确的手机号码", + "emailRequired": "邮箱不能为空", + "emailInvalid": "请输入正确的邮箱", + "nickname": "用户昵称", + "nicknamePlaceholder": "请输入昵称", + "phone": "手机号码", + "phonePlaceholder": "请输入手机号码", + "email": "邮箱", + "emailPlaceholder": "请输入邮箱", + "sex": "性别", + "nicknameShort": "昵称", + "post": "岗位", + "role": "角色", + "title": "用户管理" + }, + "management": "系统管理", + "role": { + "title": "角色管理" + }, + "dept": { + "title": "部门管理" + }, + "config": { + "title": "配置管理" + }, + "dict": { + "title": "字典管理" + }, + "notice": { + "title": "通知公告" + } +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/utility.json b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/utility.json new file mode 100644 index 000000000..5ffcf13b3 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/locales/zh-CN/utility.json @@ -0,0 +1,21 @@ +{ + "crypto": { + "randomFormat": "平台随机数返回结果格式不受支持: tag={{arg0}}, keys={{arg1}}", + "randomUnavailable": "当前运行环境缺少安全随机数能力", + "publicKeyFailed": "获取传输层公钥失败", + "keyProtocol": "传输层公钥协议版本不受支持", + "keyAlgorithm": "传输层公钥算法不受支持", + "responseProtocol": "传输层响应协议版本不受支持", + "responseAlgorithm": "传输层响应算法不受支持", + "keyVersion": "传输层响应密钥版本不匹配", + "headerVersion": "传输层响应头与响应体密钥版本不一致", + "aad": "传输层响应AAD不合法", + "requestMismatch": "传输层响应的method/path与当前请求不匹配", + "direction": "传输层响应方向标识不合法", + "queryLength": "当前GET/DELETE请求参数加密后长度超限,请改用POST请求或精简查询条件", + "missingContext": "缺少响应解密上下文", + "envelope": "传输层响应信封格式不合法", + "randomPool": "传输加密随机数池不足,且当前运行环境无法同步补充安全随机数" + }, + "httpStatus": "系统接口{{status}}异常" +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/message.mjs b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/message.mjs new file mode 100644 index 000000000..8f293acfa --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/message.mjs @@ -0,0 +1,10 @@ +let translator + +/** 构建配置和协议工具可独立运行,界面启动后由调用方注入翻译器。 */ +export function setMessageTranslator(value) { + translator = value +} + +export function translateMessage(key, fallback, options) { + return translator ? translator(key, options) : fallback +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/navigation.js b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/navigation.js new file mode 100644 index 000000000..aadff7cbe --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/navigation.js @@ -0,0 +1,45 @@ +import { t } from './adapter' +import { i18n } from './index' + +const pageTitles = { + 'pages/login': () => t('mobile:nav.login'), + 'pages/register': () => t('mobile:nav.register'), + 'pages/index': () => t('mobile:brand'), + 'pages/work/index': () => t('mobile:nav.work'), + 'pages/mine/index': () => t('mobile:nav.mine'), + 'pages/mine/avatar/index': () => t('mobile:nav.avatar'), + 'pages/mine/info/index': () => t('mobile:nav.profile'), + 'pages/mine/info/edit': () => t('mobile:profile.edit'), + 'pages/mine/pwd/index': () => t('mobile:settings.password'), + 'pages/mine/setting/index': () => t('mobile:settings.title'), + 'pages/mine/setting/timezone': () => t('mobile:settings.timezone'), + 'pages/mine/help/index': () => t('mobile:help.title'), + 'pages/mine/about/index': () => t('mobile:about.title'), + 'pages/common/agreement/index': () => t('mobile:agreement.title'), + 'pages/common/privacy/index': () => t('mobile:privacy.title'), + 'pages/common/webview/index': () => t('mobile:nav.webview'), +} + +export function refreshNavigation() { + const pages = getCurrentPages() + const current = pages[pages.length - 1] + const title = current && pageTitles[current.route] + if (title && !current.options?.title && !current.$page?.options?.title) { + uni.setNavigationBarTitle({ title: title() }) + } + const labels = [t('mobile:nav.home'), t('mobile:nav.work'), t('mobile:nav.mine')] + labels.forEach((text, index) => { + uni.setTabBarItem({ index, text, fail() {} }) + }) +} + +export default { + install(Vue) { + i18n.engine.on('languageChanged', () => Vue.nextTick(refreshNavigation)) + Vue.mixin({ + onShow() { + this.$nextTick(refreshNavigation) + }, + }) + }, +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/preference.js b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/preference.js new file mode 100644 index 000000000..058742cf9 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/preference.js @@ -0,0 +1,20 @@ +import request from '@/utils/request' +import { getInfo } from '@/api/login' +import { i18n } from './index' + +/** + * 保存当前账号或访客的语言偏好。 + * + * @param {string} preference 语言标识或 auto + * @returns {Promise} 偏好保存与界面切换结果 + */ +export function saveLocale(preference) { + return i18n.setPreference(preference, { + save: async (locale) => + (await request({ url: '/system/user/profile/locale', method: 'put', data: { locale } })).data, + readBack: async () => { + const user = (await getInfo()).user + return { locale: user?.locale, revision: user?.localeRevision } + }, + }) +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/registry.js b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/registry.js new file mode 100644 index 000000000..52ff9dc44 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/registry.js @@ -0,0 +1,11 @@ +import meta from './locale-meta.json' + +export { meta } +const messages = require.context('./locales', true, /\.json$/) +export const resources = {} +messages.keys().forEach((path) => { + const [, locale, namespace] = path.match(/^\.\/([^/]+)\/([^/]+)\.json$/) || [] + if (!locale || !namespace) return + if (!resources[locale]) resources[locale] = {} + resources[locale][namespace] = messages(path) +}) diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/runtime.mjs b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/runtime.mjs new file mode 100644 index 000000000..cd897d606 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/i18n/runtime.mjs @@ -0,0 +1,348 @@ +import { createInstance } from 'i18next' + +// 菜单和字典原字段由后端数据协议固定为简体中文。 +export const DATA_SOURCE_LOCALE = 'zh-CN' + +function normalizeRevision(value) { + return typeof value === 'string' && + /^(0|[1-9]\d{0,18})$/.test(value) && + (value.length < 19 || value <= '9223372036854775807') + ? value + : null +} + +function compareRevision(left, right) { + if (left === right) return 0 + if (right === null) return 1 + return left.length !== right.length ? left.length - right.length : left > right ? 1 : -1 +} + +/** + * 规范化语言标识,兼容使用下划线的设备语言。 + * + * @param {string} value 原始语言标识 + * @returns {string|null} 规范化后的语言标识,无效时返回 null + */ +export function normalizeLocale(value) { + if (typeof value !== 'string' || value.length > 63) return null + value = value.trim().replace(/_/g, '-') + if (/^x(?:-[a-z0-9]{1,8})+$/i.test(value)) return value.toLowerCase() + try { + return Intl.getCanonicalLocales(value.trim().replace(/_/g, '-'))[0] || null + } catch { + return null + } +} + +/** + * 校验当前应用的语言注册表、资源和回退链。 + * + * @param {Object} meta 当前应用的语言元数据 + * @param {Object} resources 按语言和命名空间组织的词库 + * @returns {Object} 语言匹配与回退查询接口 + */ +export function createLocaleRegistry(meta, resources) { + const entries = meta.locales.filter((item) => item.enabled) + const byCode = new Map(entries.map((item) => [item.code, item])) + for (const key of [meta.sourceLocale, meta.defaultLocale]) { + if (!byCode.has(key)) throw new Error(`Unregistered locale: ${key}`) + } + const aliases = new Map() + const visit = (code, path = []) => { + if (path.includes(code)) throw new Error(`Locale fallback cycle: ${code}`) + const entry = byCode.get(code) + if (!entry || !resources[code]) throw new Error(`Missing locale resources: ${code}`) + for (const fallback of entry.fallback || []) visit(fallback, [...path, code]) + } + for (const entry of entries) { + if (normalizeLocale(entry.code) !== entry.code) + throw new Error(`Noncanonical locale: ${entry.code}`) + visit(entry.code) + for (const alias of entry.aliases || []) { + const code = normalizeLocale(alias) + if (!code || aliases.has(code)) throw new Error(`Conflicting locale alias: ${alias}`) + aliases.set(code, entry.code) + } + } + const languageFallbacks = meta.languageFallbacks || {} + for (const [language, target] of Object.entries(languageFallbacks)) { + if (!/^[a-z]{2,8}$/.test(language) || !byCode.has(target)) + throw new Error(`Invalid language fallback: ${language}`) + } + function match(value) { + const code = normalizeLocale(value) + return byCode.has(code) ? code : aliases.get(code) || languageFallbacks[code?.split('-')[0]] + } + return { + entries, + resolve(value, devices = []) { + const candidates = value === 'auto' ? devices : [value] + for (const candidate of candidates) { + const code = match(candidate) + if (code) return code + } + return meta.defaultLocale + }, + /** + * 按目标语言、配置的回退语言和指定的原文语言生成查找顺序。 + * + * @param {string} code 目标语言标识 + * @param {string} [sourceLocale] 原文语言,默认取当前应用的词库基准 + * @returns {string[]} 去重后的语言标识列表 + */ + chain(code, sourceLocale = meta.sourceLocale) { + const result = [] + const append = (value) => { + if (result.includes(value)) return + result.push(value) + for (const fallback of byCode.get(value)?.fallback || []) append(fallback) + } + append(code) + append(sourceLocale) + return result + }, + get: (code) => byCode.get(code), + } +} + +/** + * 创建当前应用独立的国际化实例,管理登录页和当前账号的语言偏好。 + * + * @param {Object} options 当前应用的语言、存储和设备适配配置 + * @param {string} [options.appVersion] 记录缺词诊断时使用的应用版本 + * @returns {Object} 翻译、语言切换与偏好管理接口 + */ +export function createLocaleRuntime({ + meta, + resources, + storage, + scope, + appVersion, + deviceLocales = () => [], + onChange = () => {}, +}) { + const registry = createLocaleRegistry(meta, resources) + const engine = createInstance() + let account = null + let revision = null + let generation = 0 + let preference = meta.defaultLocale + let queue = Promise.resolve() + const accountKey = `${scope}:locale:account` + const loginKey = `${scope}:locale:login` + const snapshotKey = (id = account) => `${scope}:locale:v2:user:${id}` + let loginPreference = null + const validPreference = (value) => (value === 'auto' ? value : normalizeLocale(value)) + function parseSnapshot(value) { + const locale = validPreference(value?.locale) + const version = normalizeRevision(value?.revision) + return locale && version !== null ? { locale, revision: version } : null + } + function readSnapshot(raw) { + try { + return parseSnapshot(JSON.parse(raw)) + } catch { + return null + } + } + function requireSnapshot(value) { + const snapshot = parseSnapshot(value) + if (!snapshot) throw new Error('Invalid locale snapshot') + return snapshot + } + const reportedMissingKeys = new Set() + engine.init({ + resources, + lng: meta.defaultLocale, + initAsync: false, + defaultNS: 'common', + ns: Object.keys(resources[meta.sourceLocale]), + load: 'currentOnly', + supportedLngs: registry.entries.map((item) => item.code), + fallbackLng: (code) => registry.chain(code).slice(1), + interpolation: { escapeValue: false }, + returnNull: false, + returnEmptyString: false, + appendNamespaceToMissingKey: true, + parseMissingKeyHandler(qualifiedKey, defaultValue, options) { + const locale = options.lng || engine.language + const warningKey = `${locale}:${qualifiedKey}` + if (!reportedMissingKeys.has(warningKey)) { + reportedMissingKeys.add(warningKey) + const [namespace, key] = qualifiedKey.split(':') + // 插值参数可能包含业务数据,诊断只记录词条位置和版本。 + console.warn('Missing translation', { namespace, key, locale, version: appVersion }) + } + return ( + defaultValue ?? + engine.t('common:translationUnavailable', { lng: locale, defaultValue: '—' }) + ) + }, + }) + function applyLanguage(code) { + engine.changeLanguage(code) + onChange(code, registry.get(code)) + } + function applyPreference(value) { + preference = value + applyLanguage(registry.resolve(value, deviceLocales())) + engine.emit('preferenceChanged', value) + } + function restore() { + // 登录页默认沿用最近账号的语言,只有用户主动选择才在下次登录时提交。 + const previous = account ?? storage.get(accountKey) + const snapshot = previous ? readSnapshot(storage.get(snapshotKey(previous))) : null + revision = account === null ? null : (snapshot?.revision ?? null) + applyPreference((account === null && loginPreference) || snapshot?.locale || meta.defaultLocale) + } + function acceptSnapshot(snapshot, persist = true) { + // 先读取其他标签页可能已提交的更新,再比较本次回包的 revision。 + const stored = readSnapshot(storage.get(snapshotKey())) + if (stored && compareRevision(stored.revision, revision) > 0) { + revision = stored.revision + applyPreference(stored.locale) + } + if (compareRevision(snapshot.revision, revision) <= 0) return + revision = snapshot.revision + if (persist) storage.set(snapshotKey(), JSON.stringify(snapshot)) + applyPreference(snapshot.locale) + } + const runtime = { + engine, + registry, + t: (key, options) => engine.t(key, options), + get locale() { + return engine.language + }, + get preference() { + return preference + }, + get accountId() { + return account + }, + get preferenceRevision() { + return revision + }, + get headers() { + return { 'Accept-Language': engine.language } + }, + get loginPreference() { + return account === null ? loginPreference : null + }, + confirmLoginPreference(value) { + if (!value || loginPreference !== value) return + loginPreference = null + if (storage.get(loginKey) === value) storage.set(loginKey, '') + }, + initialize(hasSession = false) { + generation++ + loginPreference = validPreference(storage.get(loginKey)) + const previous = hasSession ? storage.get(accountKey) : null + account = + previous === null || previous === undefined || previous === '' ? null : String(previous) + restore() + }, + /** + * 切换账号并使旧账号尚未完成的语言切换失效。 + * + * @param {string|number|null} id 当前账号标识,null 表示访客 + * @param {string} [value] 账号快照中的语言偏好 + * @param {string} [serverRevision] 账号快照的十进制版本号 + */ + setAccount(id, value, serverRevision) { + if (id === undefined || id === '') throw new Error('Missing locale account') + const next = id === null ? null : String(id) + const snapshot = + next === null ? null : requireSnapshot({ locale: value, revision: serverRevision }) + if (next !== account) { + generation++ + revision = null + } + account = next + if (snapshot) { + storage.set(accountKey, account) + acceptSnapshot(snapshot) + } else if (loginPreference) { + applyPreference(loginPreference) + } + }, + /** + * 串行保存语言偏好,确认保存成功后再更新界面。 + * + * @param {string} value 语言标识或 auto + * @param {Object} callbacks 保存偏好与失败后回读的接口 + * @returns {Promise} 语言切换结果 + */ + setPreference(value, { save, readBack } = {}) { + const canonical = validPreference(value) + if (!canonical) return Promise.reject(new Error('Invalid locale preference')) + const epoch = generation + const run = async () => { + if (generation !== epoch) throw new Error('Locale account changed') + // 保存账号偏好前,先确认有效语言的资源已经加载。 + const code = registry.resolve(canonical, deviceLocales()) + if (!engine.hasResourceBundle(code, 'common')) throw new Error('Missing locale resources') + if (account === null) { + loginPreference = canonical + storage.set(loginKey, canonical) + applyPreference(canonical) + return + } + if (!save) throw new Error('A preference save callback is required') + let saved + let saveError + try { + saved = await save(canonical) + } catch (error) { + if (generation !== epoch || !readBack) throw error + saveError = error + saved = await readBack() + } + if (generation !== epoch) throw new Error('Locale account changed') + const snapshot = requireSnapshot(saved) + acceptSnapshot(snapshot) + if (saveError && snapshot.locale !== canonical) throw saveError + } + const result = queue.then(run) + queue = result.catch(() => {}) + return result + }, + refreshDeviceLocale() { + if (preference !== 'auto') return + const code = registry.resolve(preference, deviceLocales()) + if (code !== engine.language) applyLanguage(code) + }, + acceptStorageEvent(key, value) { + if (key === loginKey) { + loginPreference = validPreference(value) + if (account === null) restore() + return + } + if (account === null || key !== snapshotKey()) return + const snapshot = readSnapshot(value) + if (!snapshot) return + acceptSnapshot(snapshot, false) + // 跨标签的并发写入可能乱序,离线快照始终保留已知的最新版本。 + const stored = readSnapshot(storage.get(snapshotKey())) + if (!stored || compareRevision(revision, stored.revision) > 0) { + storage.set(snapshotKey(), JSON.stringify({ locale: preference, revision })) + } + }, + /** + * 根据当前语言选择菜单或字典译名,回退到数据库原字段。 + * + * @param {string} original 数据库原名 + * @param {Object} [translations] 按语言标识保存的译名 + * @returns {string} 当前界面使用的名称 + */ + resolveText(original, translations = {}) { + for (const code of registry.chain(engine.language, DATA_SOURCE_LOCALE)) { + if (code === DATA_SOURCE_LOCALE) return original + if (typeof translations?.[code] === 'string' && translations[code]) + return translations[code] + } + return original + }, + } + return runtime +} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/main.ts b/ruoyi-fastapi-frontend/vue2/mobile/src/main.ts index 06e0151cd..47ef26ee5 100644 --- a/ruoyi-fastapi-frontend/vue2/mobile/src/main.ts +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/main.ts @@ -1,3 +1,6 @@ +import LocalePlugin from '@/i18n/adapter' +import NavigationPlugin from '@/i18n/navigation' +import LanguageSelect from '@/components/LanguageSelect/index.vue' // @ts-nocheck import Vue from 'vue' import App from './App.vue' @@ -8,6 +11,9 @@ import './permission' import { getDicts } from '@/api/system/dict/data' Vue.use(plugins) +Vue.use(LocalePlugin) +Vue.use(NavigationPlugin) +Vue.component('LanguageSelect', LanguageSelect) Vue.config.productionTip = false Vue.prototype.$store = store Vue.prototype.getDicts = getDicts diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/pages/common/agreement/index.vue b/ruoyi-fastapi-frontend/vue2/mobile/src/pages/common/agreement/index.vue index e66b647ed..298874e9a 100644 --- a/ruoyi-fastapi-frontend/vue2/mobile/src/pages/common/agreement/index.vue +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/pages/common/agreement/index.vue @@ -1,55 +1,55 @@ diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/pages/common/privacy/index.vue b/ruoyi-fastapi-frontend/vue2/mobile/src/pages/common/privacy/index.vue index 13c634bdd..a5e2a3bbc 100644 --- a/ruoyi-fastapi-frontend/vue2/mobile/src/pages/common/privacy/index.vue +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/pages/common/privacy/index.vue @@ -1,71 +1,66 @@ diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/pages/index.vue b/ruoyi-fastapi-frontend/vue2/mobile/src/pages/index.vue index 3b3b5abc9..31761af1c 100644 --- a/ruoyi-fastapi-frontend/vue2/mobile/src/pages/index.vue +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/pages/index.vue @@ -4,7 +4,7 @@ - RuoYi-FastAPI移动端 + {{ $t('mobile:brand') }} @@ -17,7 +17,7 @@ @@ -54,15 +54,15 @@ - 系统运行正常 - 刚刚更新 + {{ + $t('mobile:dashboard.healthy') + }} + {{ $t('mobile:dashboard.justUpdated') }} 85% - 工作效率 + {{ $t('mobile:dashboard.efficiency') }} @@ -83,7 +83,9 @@ class="rounded-2xl bg-white p-4 shadow-xs border border-gray-100 flex items-center justify-between" > - 新通知 + {{ + $t('mobile:dashboard.notifications') + }} 12 - 待办任务 + {{ $t('mobile:dashboard.tasks') }} 5 - 快捷入口 + {{ + $t('mobile:dashboard.quickLinks') + }} @@ -119,7 +123,9 @@ > - 申请 + {{ + $t('mobile:dashboard.apply') + }} - 新闻 + {{ + $t('mobile:dashboard.news') + }} - 统计 + {{ + $t('mobile:dashboard.statistics') + }} - 计划 + {{ + $t('mobile:dashboard.plans') + }} @@ -151,8 +163,10 @@ - 最近更新 - 查看全部 + {{ + $t('mobile:dashboard.recent') + }} + {{ $t('mobile:dashboard.viewAll') }} - 请假申请 - 等待经理审批 + {{ + $t('mobile:dashboard.leaveRequest') + }} + {{ + $t('mobile:dashboard.awaitingApproval') + }} - 待处理{{ $t('mobile:dashboard.pending') }} - 周报 - 提交成功 + {{ + $t('mobile:dashboard.weeklyReport') + }} + {{ $t('common:submitSuccess') }} - 已完成 + {{ + $t('mobile:dashboard.completed') + }} diff --git a/ruoyi-fastapi-frontend/vue2/mobile/src/pages/login.vue b/ruoyi-fastapi-frontend/vue2/mobile/src/pages/login.vue index e9dc414d2..7f3a164ac 100644 --- a/ruoyi-fastapi-frontend/vue2/mobile/src/pages/login.vue +++ b/ruoyi-fastapi-frontend/vue2/mobile/src/pages/login.vue @@ -1,9 +1,12 @@ - - + + + diff --git a/ruoyi-fastapi-frontend/vue2/web/src/components/ExcelImportDialog/index.vue b/ruoyi-fastapi-frontend/vue2/web/src/components/ExcelImportDialog/index.vue index 983269af2..f272f483f 100644 --- a/ruoyi-fastapi-frontend/vue2/web/src/components/ExcelImportDialog/index.vue +++ b/ruoyi-fastapi-frontend/vue2/web/src/components/ExcelImportDialog/index.vue @@ -1,6 +1,6 @@ + + diff --git a/ruoyi-fastapi-frontend/vue2/web/src/components/FileUpload/index.vue b/ruoyi-fastapi-frontend/vue2/web/src/components/FileUpload/index.vue index 197186d10..727f41661 100644 --- a/ruoyi-fastapi-frontend/vue2/web/src/components/FileUpload/index.vue +++ b/ruoyi-fastapi-frontend/vue2/web/src/components/FileUpload/index.vue @@ -20,7 +20,7 @@ 选取文件{{ $t('file:upload.select') }}
- 请上传 - - - 的文件 + {{ $t('file:upload.maxSize', { size: fileSize }) }} + {{ + $t('file:upload.acceptedFormats', { formats: fileType.join('/') }) + }}
@@ -65,7 +61,7 @@ @click="handleDelete(index)" type="danger" v-if="!disabled" - >删除{{ $t('common:delete') }}
@@ -74,6 +70,9 @@ + + diff --git a/ruoyi-fastapi-frontend/vue2/web/src/components/LocaleTextFields/index.vue b/ruoyi-fastapi-frontend/vue2/web/src/components/LocaleTextFields/index.vue new file mode 100644 index 000000000..5211b5b67 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue2/web/src/components/LocaleTextFields/index.vue @@ -0,0 +1,96 @@ + + + + + diff --git a/ruoyi-fastapi-frontend/vue2/web/src/components/OAuthWorkspace/AccessMap.vue b/ruoyi-fastapi-frontend/vue2/web/src/components/OAuthWorkspace/AccessMap.vue index b5f143356..65d1c1f01 100644 --- a/ruoyi-fastapi-frontend/vue2/web/src/components/OAuthWorkspace/AccessMap.vue +++ b/ruoyi-fastapi-frontend/vue2/web/src/components/OAuthWorkspace/AccessMap.vue @@ -1,22 +1,22 @@ diff --git a/ruoyi-fastapi-frontend/vue2/web/src/components/OAuthWorkspace/FieldLabel.vue b/ruoyi-fastapi-frontend/vue2/web/src/components/OAuthWorkspace/FieldLabel.vue index ca02b72ec..3626e8c5a 100644 --- a/ruoyi-fastapi-frontend/vue2/web/src/components/OAuthWorkspace/FieldLabel.vue +++ b/ruoyi-fastapi-frontend/vue2/web/src/components/OAuthWorkspace/FieldLabel.vue @@ -9,7 +9,7 @@ diff --git a/ruoyi-fastapi-frontend/vue2/web/src/components/OAuthWorkspace/PageFrame.vue b/ruoyi-fastapi-frontend/vue2/web/src/components/OAuthWorkspace/PageFrame.vue index 4a98a88d1..ebaca8a32 100644 --- a/ruoyi-fastapi-frontend/vue2/web/src/components/OAuthWorkspace/PageFrame.vue +++ b/ruoyi-fastapi-frontend/vue2/web/src/components/OAuthWorkspace/PageFrame.vue @@ -3,7 +3,7 @@

{{ title }}

- {{ section }} + {{ section || $t('layout:routes.authLogin') }}

{{ description }}

@@ -25,11 +25,11 @@
- 筛选条件 + {{ $t('oauth:workspace.filters') }} @@ -161,16 +170,18 @@ const form = reactive({ confirmPassword: '', }) -const applicationName = computed(() => interaction.value.client?.clientName || '发起登录的应用') +const applicationName = computed( + () => interaction.value.client?.clientName || t('authCenter:shared.appRequestingSignIn') +) const policyDescription = computed( () => ({ - 0: "需要 6–20 个字符,不能包含 < > “ ” ' \\ |", - 1: '需要 6–20 位数字', - 2: '需要 6–20 个英文字母', - 3: '需要 6–20 个字符,并同时包含字母和数字', - 4: '需要 6–20 个字符,并同时包含字母、数字和特殊字符', - })[pwdChrType.value] || '需要 6–20 个字符' + 0: t('authCenter:password.forbiddenCharacters'), + 1: t('authCenter:password.use620Digits'), + 2: t('authCenter:password.use620LatinLetters'), + 3: t('authCenter:password.use620CharactersIncludingBothLettersAndNumbers'), + 4: t('authCenter:password.use620CharactersIncludingLettersNumbersAndSymbols'), + })[pwdChrType.value] || t('auth:interface.use620Characters') ) const strengthLevel = computed(() => { @@ -190,25 +201,41 @@ const strengthLevel = computed(() => { } return Math.min(3, level) }) -const strengthLabel = computed(() => ['尚未达到要求', '基础', '良好', '较强'][strengthLevel.value]) +const strengthLabel = computed( + () => + [ + t('authCenter:password.requirementsNotMet'), + t('authCenter:password.basic'), + t('common:good'), + t('authCenter:password.strong'), + ][strengthLevel.value] +) const validateNewPassword = (_rule, value, callback) => { if (value && value === form.oldPassword) { - return callback(new Error('新密码不能与当前密码相同')) + return callback( + new Error(t('authCenter:password.theNewPasswordMustDifferFromTheCurrentPassword')) + ) } callback() } const validateConfirmation = (_rule, value, callback) => { if (!value) { - return callback(new Error('请再次输入新密码')) + return callback(new Error(t('authCenter:password.enterTheNewPasswordAgain'))) } if (value !== form.newPassword) { - return callback(new Error('两次输入的新密码不一致')) + return callback(new Error(t('authCenter:password.theNewPasswordsDoNotMatch'))) } callback() } const rules = computed(() => ({ - oldPassword: [{ required: true, message: '请输入当前密码', trigger: 'blur' }], + oldPassword: [ + { + required: true, + message: () => t('authCenter:password.enterYourCurrentPassword'), + trigger: 'blur', + }, + ], newPassword: [...infoPwdValidator.value, { validator: validateNewPassword, trigger: 'blur' }], confirmPassword: [{ validator: validateConfirmation, trigger: 'blur' }], })) @@ -216,7 +243,7 @@ const rules = computed(() => ({ /** 读取认证交互状态并检查是否需要修改密码 */ async function initialize() { if (!interactionId.value || !csrfToken()) { - return fatal('认证请求不完整,请返回应用重新登录') + return fatal(t('authCenter:shared.theAuthenticationRequestIsIncompleteReturnToTheAppAndSignIn')) } try { const response = await getInteraction(interactionId.value, csrfToken()) @@ -225,7 +252,10 @@ async function initialize() { await goToAction(interaction.value.nextAction) } } catch (error) { - fatal(error?.message || '认证请求已失效,请返回应用重新登录') + fatal( + error?.message || + t('authCenter:shared.theAuthenticationRequestHasExpiredReturnToTheAppAndSignIn') + ) } finally { initializing.value = false } @@ -234,7 +264,7 @@ async function initialize() { /** 校验并提交密码修改 */ async function submit() { if (!interactionId.value || !csrfToken()) { - return fatal('认证请求不完整,请返回应用重新登录') + return fatal(t('authCenter:shared.theAuthenticationRequestIsIncompleteReturnToTheAppAndSignIn')) } if (!(await passwordRef.value?.validate().catch(() => false))) { return @@ -256,7 +286,8 @@ async function submit() { await goToAction(response.data?.nextAction) } catch (error) { form.oldPassword = '' - errorMessage.value = error?.message || '密码更新失败,请根据页面提示检查后重试' + errorMessage.value = + error?.message || t('auth:interface.passwordUpdateFailedCheckTheFormAndTryAgain') } finally { submitting.value = false } diff --git a/ruoyi-fastapi-frontend/vue2/web/src/views/auth-center/consent.vue b/ruoyi-fastapi-frontend/vue2/web/src/views/auth-center/consent.vue index 6e2f47a4d..a7762a0d8 100644 --- a/ruoyi-fastapi-frontend/vue2/web/src/views/auth-center/consent.vue +++ b/ruoyi-fastapi-frontend/vue2/web/src/views/auth-center/consent.vue @@ -9,11 +9,15 @@ v-loading="initializing" class="auth-flow" > -

确认权限

-

确认要分享的信息

+

{{ $t('authCenter:shared.confirmPermissions') }}

+

{{ $t('authCenter:consent.confirmWhatToShare') }}

{{ applicationName }} - 正在请求以下信息。必需信息用于完成本次访问,可选信息由你决定。 + {{ + $t( + 'authCenter:consent.isRequestingTheInformationBelowRequiredInformationIsNeededForAccessOptional' + ) + }}

-

完成访问所需

-

拒绝这些权限将无法继续进入应用

+

{{ $t('authCenter:consent.requiredForAccess') }}

+

{{ $t('authCenter:consent.decliningThesePermissionsPreventsAccessToTheApp') }}

- {{ requiredScopes.length }} 项 + {{ requiredScopes.length }} {{ $t('common:items') }}
@@ -84,10 +91,15 @@ >
-

由你选择

-

不勾选也可以继续使用应用

+

{{ $t('authCenter:consent.yourChoice') }}

+

{{ $t('authCenter:consent.youCanUseTheAppWithoutSelectingThese') }}

- 已选 {{ selectedOptionalCount }}/{{ optionalScopes.length }} + {{ + $t('authCenter:consent.selectedCount', { + selected: selectedOptionalCount, + total: optionalScopes.length, + }) + }}
@@ -127,11 +142,15 @@ @@ -140,14 +159,15 @@ size="medium" :disabled="submitting" @click="submit(false)" - >不允许并返回{{ $t('authCenter:consent.declineAndReturn') }} 允许 {{ selectedScopes.length }} 项并继续{{ $t('common:allow') }} {{ selectedScopes.length }} + {{ $t('authCenter:consent.andContinue') }}
查看该应用的隐私说明{{ $t('authCenter:consent.viewThisAppSPrivacyPolicy') }}
@@ -167,6 +187,8 @@ @@ -185,7 +207,9 @@ const initializing = ref(true) const submitting = ref(false) const errorMessage = ref('') -const applicationName = computed(() => interaction.value.client?.clientName || '发起登录的应用') +const applicationName = computed( + () => interaction.value.client?.clientName || t('authCenter:shared.appRequestingSignIn') +) const requiredScopes = computed(() => (interaction.value.requestedScopes || []).filter((item) => item.required) ) @@ -213,7 +237,7 @@ function safeExternalUrl(value) { /** 读取授权请求并初始化必选权限 */ async function initialize() { if (!interactionId.value || !csrfToken()) { - return fatal('认证请求不完整,请返回应用重新登录') + return fatal(t('authCenter:shared.theAuthenticationRequestIsIncompleteReturnToTheAppAndSignIn')) } try { const response = await getInteraction(interactionId.value, csrfToken()) @@ -223,7 +247,7 @@ async function initialize() { } selectedScopes.value = requiredScopes.value.map((item) => item.scope) } catch (error) { - fatal(error?.message || '授权请求已失效') + fatal(error?.message || t('authCenter:consent.theAuthorizationRequestHasExpired')) } finally { initializing.value = false } @@ -243,7 +267,8 @@ async function submit(approved) { }) await followServerRedirect(response.data?.redirectUrl) } catch (error) { - errorMessage.value = error?.message || '未能保存本次权限选择,请重试' + errorMessage.value = + error?.message || t('authCenter:consent.couldNotSaveYourPermissionChoicesTryAgain') } finally { submitting.value = false } diff --git a/ruoyi-fastapi-frontend/vue2/web/src/views/auth-center/error.vue b/ruoyi-fastapi-frontend/vue2/web/src/views/auth-center/error.vue index bf7db3553..f8931b45a 100644 --- a/ruoyi-fastapi-frontend/vue2/web/src/views/auth-center/error.vue +++ b/ruoyi-fastapi-frontend/vue2/web/src/views/auth-center/error.vue @@ -9,7 +9,13 @@ aria-hidden="true" > -

{{ serviceUnavailable ? '服务不可用' : '认证未完成' }}

+

+ {{ + serviceUnavailable + ? $t('authCenter:error.serviceUnavailable') + : $t('layout:route.authError') + }} +

{{ errorTitle }}

- 你可以这样处理 + {{ $t('authCenter:error.whatYouCanDo') }}
    -
  1. 返回刚才的应用,或关闭当前页面。
  2. -
  3. 联系管理员确认服务状态。
  4. +
  5. {{ $t('authCenter:error.returnToTheAppOrCloseThisPage') }}
  6. +
  7. {{ $t('authCenter:error.askYourAdministratorToCheckTheServiceStatus') }}
    -
  1. 返回刚才的应用,重新发起登录。
  2. -
  3. 如果仍然失败,把出现问题的时间和应用名称告诉管理员。
  4. +
  5. {{ $t('authCenter:error.returnToTheAppAndStartSignInAgain') }}
  6. +
  7. + {{ $t('authCenter:error.ifItStillFailsTellYourAdministratorTheAppNameAndWhen') }} +
@@ -37,7 +45,7 @@ class="return-action" @click="returnBack" > - 返回上一页 + {{ $t('authCenter:error.goBack') }}

{{ serviceUnavailable - ? '可以安全关闭此页面,返回原应用。' - : '可以安全关闭此页面,再回到应用重新登录。' + ? $t('authCenter:error.youCanSafelyCloseThisPageAndReturnToTheApplication') + : $t('authCenter:error.youCanSafelyCloseThisPageAndRestartSignInFromThe') }}

@@ -54,6 +62,8 @@ @@ -68,19 +78,24 @@ const canGoBack = typeof window !== 'undefined' && window.history.length > 1 const serviceReason = computed(() => route.value.query.reason) const serviceUnavailable = computed(() => ['disabled', 'unavailable'].includes(serviceReason.value)) const errorTitle = computed(() => { - if (serviceReason.value === 'disabled') return '统一认证服务未启用' - if (serviceReason.value === 'unavailable') return '统一认证服务暂不可用' - return '这次访问无法继续' + if (serviceReason.value === 'disabled') + return t('authCenter:error.authenticationServiceIsDisabled') + if (serviceReason.value === 'unavailable') + return t('authCenter:error.authenticationServiceIsUnavailable') + return t('authCenter:error.unableToContinue') }) const safeMessage = computed(() => { if (serviceReason.value === 'disabled') { - return '当前未开放统一认证服务,请返回原应用或联系管理员。' + return t('authCenter:error.authenticationIsNotEnabledReturnToTheAppOrContactYourAdministrator') } if (serviceReason.value === 'unavailable') { - return '暂时无法连接认证服务,请稍后从原应用重试。' + return t('authCenter:error.theAuthenticationServiceCannotBeReachedTryAgainLaterFromTheApp') } const message = typeof route.value.query.message === 'string' ? route.value.query.message : '' - return message.slice(0, 240) || '认证请求可能已经过期、内容不完整,或应用的接入配置已经变更。' + return ( + message.slice(0, 240) || + t('authCenter:error.theAuthenticationRequestMayHaveExpiredBeIncompleteOrReferToAn') + ) }) /** 返回浏览器历史中的上一页 */ diff --git a/ruoyi-fastapi-frontend/vue2/web/src/views/auth-center/login.vue b/ruoyi-fastapi-frontend/vue2/web/src/views/auth-center/login.vue index 03ec8815e..de8cdbbdc 100644 --- a/ruoyi-fastapi-frontend/vue2/web/src/views/auth-center/login.vue +++ b/ruoyi-fastapi-frontend/vue2/web/src/views/auth-center/login.vue @@ -9,12 +9,12 @@ v-loading="initializing" class="auth-flow" > -

验证身份

-

使用你的账户继续

+

{{ $t('authCenter:shared.verifyIdentity') }}

+

{{ $t('authCenter:login.continueWithYourAccount') }}

- 登录成功后,你将返回 + {{ $t('authCenter:login.afterSigningInYouWillReturnTo') }} {{ applicationName }} - 完成访问。本次登录不会改变管理后台的登录状态。 + {{ $t('authCenter:login.toContinueThisSignInDoesNotChangeYourSessionInThe') }}

@@ -381,46 +410,192 @@ const detailOpen = ref(false) const eventGroups = [ { - label: '登录与授权', + get label() { + return t('monitor:messages.signInAndAuthorization') + }, options: [ - { label: '收到登录授权请求', value: 'authorize_requested' }, - { label: '登录授权已完成', value: 'authorize_succeeded' }, - { label: '登录授权被拒绝', value: 'authorize_denied' }, - { label: '用户登录成功', value: 'login_succeeded' }, - { label: '用户登录失败', value: 'login_failed' }, - { label: '用户同意授权', value: 'consent_granted' }, - { label: '用户撤销授权', value: 'consent_revoked' }, + { + get label() { + return t('monitor:messages.signInAuthorizationRequested') + }, + value: 'authorize_requested', + }, + { + get label() { + return t('monitor:messages.signInAuthorizationCompleted') + }, + value: 'authorize_succeeded', + }, + { + get label() { + return t('monitor:messages.signInAuthorizationDeclined') + }, + value: 'authorize_denied', + }, + { + get label() { + return t('monitor:messages.userSignedIn') + }, + value: 'login_succeeded', + }, + { + get label() { + return t('monitor:messages.userSignInFailed') + }, + value: 'login_failed', + }, + { + get label() { + return t('monitor:messages.userGrantedAuthorization') + }, + value: 'consent_granted', + }, + { + get label() { + return t('monitor:messages.userWithdrewAuthorization') + }, + value: 'consent_revoked', + }, ], }, { - label: '凭据与会话', + get label() { + return t('monitor:messages.credentialsAndSessions') + }, options: [ - { label: '访问凭据已签发', value: 'token_issued' }, - { label: '访问凭据处理失败', value: 'token_failed' }, - { label: '刷新凭据已更新', value: 'refresh_rotated' }, - { label: '发现刷新凭据被重复使用', value: 'refresh_reuse_detected' }, - { label: '访问凭据已撤销', value: 'token_revoked' }, - { label: '登录会话已下线', value: 'session_revoked' }, - { label: '用户授权已撤销', value: 'grant_revoked' }, - { label: '用户应用访问已禁止', value: 'client_access_blocked' }, - { label: '用户应用访问已允许', value: 'client_access_allowed' }, - { label: '应用退出通知成功', value: 'backchannel_logout_succeeded' }, - { label: '应用退出通知失败', value: 'backchannel_logout_failed' }, + { + get label() { + return t('monitor:messages.accessTokenIssued') + }, + value: 'token_issued', + }, + { + get label() { + return t('monitor:messages.accessTokenProcessingFailed') + }, + value: 'token_failed', + }, + { + get label() { + return t('monitor:messages.refreshTokenRenewed') + }, + value: 'refresh_rotated', + }, + { + get label() { + return t('monitor:messages.refreshTokenReuseDetected') + }, + value: 'refresh_reuse_detected', + }, + { + get label() { + return t('monitor:messages.accessTokenRevoked') + }, + value: 'token_revoked', + }, + { + get label() { + return t('monitor:messages.sessionEnded') + }, + value: 'session_revoked', + }, + { + get label() { + return t('monitor:messages.userAuthorizationRevoked') + }, + value: 'grant_revoked', + }, + { + get label() { + return t('monitor:messages.userAccessToAppBlocked') + }, + value: 'client_access_blocked', + }, + { + get label() { + return t('monitor:messages.userAccessToAppAllowed') + }, + value: 'client_access_allowed', + }, + { + get label() { + return t('monitor:messages.appSignOutNotificationDelivered') + }, + value: 'backchannel_logout_succeeded', + }, + { + get label() { + return t('monitor:messages.appSignOutNotificationFailed') + }, + value: 'backchannel_logout_failed', + }, ], }, { - label: '配置与安全', + get label() { + return t('monitor:messages.configurationAndSecurity') + }, options: [ - { label: '应用已注册', value: 'client_created' }, - { label: '应用已停用', value: 'client_disabled' }, - { label: '应用密钥已更新', value: 'client_secret_rotated' }, - { label: '签名密钥已轮换', value: 'signing_key_rotated' }, - { label: '服务访问策略已变更', value: 'resource_policy_changed' }, - { label: '权限策略已变更', value: 'scope_policy_changed' }, - { label: '发现授权码被重复使用', value: 'authorization_code_reused' }, - { label: '应用身份验证失败', value: 'invalid_client' }, - { label: '用户身份标识缺失', value: 'identity_subject_missing' }, - { label: '账户安全版本已变更', value: 'security_version_changed' }, + { + get label() { + return t('monitor:messages.appRegistered') + }, + value: 'client_created', + }, + { + get label() { + return t('monitor:messages.appDisabled') + }, + value: 'client_disabled', + }, + { + get label() { + return t('monitor:messages.appSecretUpdated') + }, + value: 'client_secret_rotated', + }, + { + get label() { + return t('monitor:messages.signingKeyRotated') + }, + value: 'signing_key_rotated', + }, + { + get label() { + return t('monitor:messages.serviceAccessPolicyChanged') + }, + value: 'resource_policy_changed', + }, + { + get label() { + return t('monitor:messages.permissionPolicyChanged') + }, + value: 'scope_policy_changed', + }, + { + get label() { + return t('monitor:messages.authorizationCodeReuseDetected') + }, + value: 'authorization_code_reused', + }, + { + get label() { + return t('monitor:messages.appAuthenticationFailed') + }, + value: 'invalid_client', + }, + { + get label() { + return t('monitor:messages.userIdentityMissing') + }, + value: 'identity_subject_missing', + }, + { + get label() { + return t('monitor:messages.accountSecurityVersionChanged') + }, + value: 'security_version_changed', + }, ], }, ] @@ -440,42 +615,63 @@ const queryParams = reactive({ /** 获取安全事件名称 */ function eventLabel(value) { - return eventLabels[value] || value || '未知安全操作' + return eventLabels[value] || value || t('monitor:messages.unknownSecurityOperation') } /** 获取安全事件的业务说明 */ function eventSummary(row = {}) { const labels = { - authorize_requested: '应用发起了用户登录或权限授权请求', - authorize_succeeded: '用户身份确认和应用授权流程已经完成', - authorize_denied: '登录或权限授权请求没有继续执行', - login_succeeded: '用户已经通过身份验证', - login_failed: '用户身份验证没有通过', - consent_granted: '用户允许应用访问所请求的信息', - consent_revoked: '用户取消了应用的持续访问权限', - token_issued: '系统为应用签发了新的短期访问凭据', - token_failed: '系统没有为应用签发访问凭据', - refresh_rotated: '应用用于续期的凭据已经安全更新', - refresh_reuse_detected: '同一份旧续期凭据被再次使用,可能存在泄露', - token_revoked: '一份访问凭据已经作废', - session_revoked: '一个外部登录会话已经被强制结束', - grant_revoked: '一项用户对应用的访问授权已经撤销', - client_access_blocked: '管理员已禁止用户访问指定应用,并撤销现有授权', - client_access_allowed: '管理员已解除用户对指定应用的访问禁止,仍需重新授权', - backchannel_logout_succeeded: '系统已经通知关联应用结束本地登录会话', - backchannel_logout_failed: '关联应用没有成功接收退出通知', - client_created: '一个新应用已接入统一认证', - client_disabled: '一个应用已被禁止继续使用统一认证', - client_secret_rotated: '应用用于证明身份的密钥已经更新', - signing_key_rotated: '系统用于签署身份凭据的密钥已经更新', - resource_policy_changed: '一个服务允许访问的凭据或用户信息配置已变更', - scope_policy_changed: '一个权限的适用范围或用户确认要求已变更', - authorization_code_reused: '一次性登录授权码被再次使用,可能存在攻击', - invalid_client: '应用无法证明自己的身份', - identity_subject_missing: '用户缺少统一认证所需的稳定身份标识', - security_version_changed: '账户安全信息变更,旧登录状态将逐步失效', + authorize_requested: t('monitor:messages.anAppRequestedUserSignInOrPermissionAuthorization'), + authorize_succeeded: t('monitor:messages.identityVerificationAndAppAuthorizationCompleted'), + authorize_denied: t('monitor:messages.theSignInOrAuthorizationRequestWasNotContinued'), + login_succeeded: t('monitor:messages.theUserPassedAuthentication'), + login_failed: t('monitor:messages.theUserDidNotPassAuthentication'), + consent_granted: t('monitor:messages.theUserAllowedTheAppToAccessTheRequestedInformation'), + consent_revoked: t('monitor:messages.theUserWithdrewTheAppSOngoingAccess'), + token_issued: t('monitor:messages.theSystemIssuedANewShortLivedAccessTokenToTheApp'), + token_failed: t('monitor:messages.theSystemDidNotIssueAnAccessTokenToTheApp'), + refresh_rotated: t('monitor:messages.theAppSRefreshTokenWasSecurelyRenewed'), + refresh_reuse_detected: t( + 'monitor:messages.anOldRefreshTokenWasReusedAndMayHaveBeenCompromised' + ), + token_revoked: t('monitor:messages.anAccessTokenWasInvalidated'), + session_revoked: t('monitor:messages.anExternalSignInSessionWasForciblyEnded'), + grant_revoked: t('monitor:messages.aUserSAuthorizationForAnAppWasRevoked'), + client_access_blocked: t( + 'monitor:messages.anAdministratorBlockedTheUserSAccessToTheAppAndRevoked' + ), + client_access_allowed: t( + 'monitor:messages.anAdministratorUnblockedTheUserSAccessToTheAppNewAuthorization' + ), + backchannel_logout_succeeded: t( + 'monitor:messages.theSystemNotifiedRelatedAppsToEndTheirLocalSessions' + ), + backchannel_logout_failed: t('monitor:messages.aRelatedAppDidNotReceiveTheSignOutNotification'), + client_created: t('monitor:messages.aNewAppRegisteredWithTheAuthenticationService'), + client_disabled: t('monitor:messages.anAppWasBlockedFromUsingTheAuthenticationService'), + client_secret_rotated: t('monitor:messages.theSecretUsedToAuthenticateTheAppWasUpdated'), + signing_key_rotated: t('monitor:messages.theKeyUsedToSignIdentityCredentialsWasUpdated'), + resource_policy_changed: t( + 'monitor:messages.aServiceSAllowedCredentialsOrUserInformationSettingsChanged' + ), + scope_policy_changed: t( + 'monitor:messages.aPermissionSScopeOrUserConfirmationRequirementsChanged' + ), + authorization_code_reused: t( + 'monitor:messages.aOneTimeAuthorizationCodeWasReusedIndicatingAPossibleAttack' + ), + invalid_client: t('monitor:messages.theAppCouldNotAuthenticateItself'), + identity_subject_missing: t( + 'monitor:messages.theUserLacksTheStableIdentityRequiredForAuthentication' + ), + security_version_changed: t( + 'monitor:messages.accountSecurityInformationChangedExistingSessionsWillGraduallyExpire' + ), } - return labels[row.eventType] || '系统记录了一次认证安全操作' + return ( + labels[row.eventType] || + t('monitor:messages.theSystemRecordedAnAuthenticationSecurityOperation') + ) } /** 根据处理结果和风险等级显示事件颜色 */ @@ -494,33 +690,47 @@ function sourceText(row = {}) { if (row.userAgent) { return row.userAgent.length > 26 ? `${row.userAgent.slice(0, 26)}…` : row.userAgent } - return row.ipAddress ? '外部请求' : '后台操作' + return row.ipAddress + ? t('monitor:messages.externalRequest') + : t('monitor:messages.administrativeAction') } /** 将协议失败代码转换为处理说明 */ function failureText(code, result) { if (result !== 'failure' && !code) { - return '无需处理' + return t('monitor:messages.noActionRequired') } const labels = { - invalid_request: '请求信息不完整或格式不正确', - invalid_client: '应用身份验证失败,请检查应用凭据', - invalid_grant: '登录或授权凭据已经失效', - unauthorized_client: '应用未获准使用当前登录方式', - unsupported_grant_type: '系统不支持当前登录方式', - invalid_scope: '应用请求了尚未开放的权限', - access_denied: '用户或安全策略拒绝了本次操作', - login_required: '用户需要重新登录', - consent_required: '需要用户确认应用所需权限', - server_error: '认证服务暂时无法完成请求', - temporarily_unavailable: '认证服务暂时不可用', + invalid_request: t('monitor:messages.theRequestIsIncompleteOrIncorrectlyFormatted'), + invalid_client: t('monitor:messages.appAuthenticationFailedCheckTheAppCredentials'), + invalid_grant: t('monitor:messages.theSignInOrAuthorizationCredentialsHaveExpired'), + unauthorized_client: t('monitor:messages.theAppIsNotAllowedToUseThisSignInMethod'), + unsupported_grant_type: t('monitor:messages.thisSignInMethodIsNotSupported'), + invalid_scope: t('monitor:messages.theAppRequestedAPermissionThatIsNotAvailable'), + access_denied: t('monitor:messages.theUserOrASecurityPolicyDeniedThisOperation'), + login_required: t('monitor:messages.theUserNeedsToSignInAgain'), + consent_required: t('monitor:messages.theUserMustConfirmTheAppSRequestedPermissions'), + server_error: t('monitor:messages.theAuthenticationServiceCannotCompleteTheRequestRightNow'), + temporarily_unavailable: t('monitor:messages.theAuthenticationServiceIsTemporarilyUnavailable'), } - return labels[code] || (code ? `操作未完成(${code})` : '操作未完成,详情中暂无具体原因') + return ( + labels[code] || + (code + ? t('monitor:messages.operationIncomplete', { code }) + : t('monitor:messages.theOperationDidNotCompleteNoSpecificReasonIsAvailable')) + ) } /** 获取风险等级名称 */ function riskText(value) { - return { normal: '常规', medium: '需关注', high: '高风险', critical: '严重' }[value] || '常规' + return ( + { + normal: t('monitor:oauthAudit.general'), + medium: t('monitor:messages.needsAttention'), + high: t('monitor:messages.highRisk'), + critical: t('monitor:oauthAudit.critical'), + }[value] || t('monitor:oauthAudit.general') + ) } /** 获取风险等级标签类型 */ function riskType(value) { @@ -565,7 +775,11 @@ function showDetail(row) { } /** 导出当前筛选条件下的安全日志 */ function exportRows() { - proxy.download('monitor/oauth/audit/export', params(), `oauth_audit_${Date.now()}.xlsx`) + proxy.download( + 'monitor/oauth/audit/export', + params(), + `${t('common:exportFiles.oauthAudit')}_${Date.now()}.xlsx` + ) } getList() diff --git a/ruoyi-fastapi-frontend/vue2/web/src/views/monitor/online/index.vue b/ruoyi-fastapi-frontend/vue2/web/src/views/monitor/online/index.vue index 06f80b073..7954687e5 100644 --- a/ruoyi-fastapi-frontend/vue2/web/src/views/monitor/online/index.vue +++ b/ruoyi-fastapi-frontend/vue2/web/src/views/monitor/online/index.vue @@ -1,6 +1,7 @@ @@ -120,7 +121,7 @@ icon="el-icon-delete" @click="handleForceLogout(scope.row)" v-hasPermi="['monitor:online:forceLogout']" - >强退{{ $t('monitor:messages.forceSignOut') }} @@ -136,6 +137,8 @@ @@ -716,14 +825,28 @@ const selectedScopeOptions = computed(() => { return form.scopeCodes.map((code) => known.get(code) || { scopeCode: code, scopeName: code }) }) const rules = { - clientName: [{ required: true, message: '请输入应用名称', trigger: 'blur' }], - clientType: [{ required: true, message: '请选择应用类型', trigger: 'change' }], + clientName: [ + { + required: true, + message: () => t('oauth:client.enterAnApplicationName'), + trigger: 'blur', + }, + ], + clientType: [ + { + required: true, + get message() { + return t('oauth:client.selectAnApplicationType') + }, + trigger: 'change', + }, + ], grantTypes: [ { required: true, type: 'array', min: 1, - message: '至少选择一种登录或调用方式', + message: () => t('oauth:client.selectAtLeastOneSignInOrServiceAccessMethod'), trigger: 'change', }, ], @@ -732,7 +855,7 @@ const rules = { required: true, type: 'array', min: 1, - message: '至少添加一项可申请权限', + message: () => t('oauth:client.addAtLeastOneAvailablePermission'), trigger: 'change', }, ], @@ -913,11 +1036,11 @@ async function handleUpdate(row) { /** 获取授权类型名称 */ function grantTypeText(types = []) { const labels = { - authorization_code: '用户登录', - refresh_token: '保持登录', - client_credentials: '服务间调用', + authorization_code: t('oauth:client.userSignIn'), + refresh_token: t('oauth:client.staySignedIn'), + client_credentials: t('oauth:client.serviceToServiceCalls'), } - return types.map((item) => labels[item] || item).join(' · ') || '尚未配置' + return types.map((item) => labels[item] || item).join(' · ') || t('oauth:client.notConfigured') } /** 处理客户端行操作 */ @@ -956,7 +1079,7 @@ async function submit() { try { const action = form.clientId ? updateOAuthClient : addOAuthClient await action(payload()) - proxy.$modal.msgSuccess('应用配置已保存') + proxy.$modal.msgSuccess(t('oauth:client.applicationSettingsSaved')) editorOpen.value = false await getList() } finally { @@ -966,11 +1089,13 @@ async function submit() { /** 修改客户端状态 */ async function changeStatus(row, status) { - const verb = status === '0' ? '启用' : '停用' + const verb = status === '0' ? t('system:oauth.enable') : t('system:oauth.disabled') try { - await proxy.$modal.confirm(`${verb}应用“${row.clientName}”?`) + await proxy.$modal.confirm( + t('oauth:client.valueApplicationValue', { value0: verb, value1: row.clientName }) + ) await changeOAuthClientStatus({ clientId: row.clientId, status }) - proxy.$modal.msgSuccess(`${verb}成功`) + proxy.$modal.msgSuccess(t('oauth:client.valueSucceeded', { value0: verb })) await getList() } catch { // 用户取消或请求失败时刷新事实状态,避免保留乐观 UI @@ -980,15 +1105,23 @@ async function changeStatus(row, status) { /** 删除按钮操作 */ async function handleDelete(row) { - await proxy.$modal.confirm(`停用“${row.clientName}”将同时撤销该应用的授权与刷新凭据,是否继续?`) + await proxy.$modal.confirm( + t('oauth:client.disablingValueAlsoRevokesItsGrantsAndRefreshCredentialsContinue', { + value0: row.clientName, + }) + ) await deleteOAuthClients(row.clientId) - proxy.$modal.msgSuccess('应用已停用') + proxy.$modal.msgSuccess(t('monitor:messages.appDisabled')) await getList() } /** 轮换客户端密钥并显示一次性明文 */ async function rotateSecret(row) { - await proxy.$modal.confirm(`为“${row.clientName}”生成新密钥?旧密钥将进入有界退役窗口。`) + await proxy.$modal.confirm( + t('oauth:client.generateANewSecretForValueTheOldSecretWillEnterALimitedRetirement', { + value0: row.clientName, + }) + ) const response = await rotateOAuthClientSecret(row.clientId) secret.value = response.data secretOpen.value = true diff --git a/ruoyi-fastapi-frontend/vue2/web/src/views/system/oauth/client/secret.vue b/ruoyi-fastapi-frontend/vue2/web/src/views/system/oauth/client/secret.vue index acf62817b..506aea3cd 100644 --- a/ruoyi-fastapi-frontend/vue2/web/src/views/system/oauth/client/secret.vue +++ b/ruoyi-fastapi-frontend/vue2/web/src/views/system/oauth/client/secret.vue @@ -2,20 +2,25 @@ 复制{{ $t('common:copy') }} - 我已将密钥保存到安全位置 + {{ + $t('oauth:client.iHaveStoredTheSecretSecurely') + }} @@ -284,12 +308,26 @@ const accessRules = { { required: true, pattern: /^[1-9]\d{0,18}$/, - message: '请输入有效的用户编号', + message: () => t('oauth:grant.enterAValidUserID'), + trigger: 'blur', + }, + ], + clientId: [ + { + required: true, + whitespace: true, + message: () => t('oauth:grant.enterAClientID'), + trigger: 'blur', + }, + ], + reason: [ + { + required: true, + whitespace: true, + message: () => t('oauth:grant.enterAReasonForThisOperation'), trigger: 'blur', }, ], - clientId: [{ required: true, whitespace: true, message: '请输入 Client ID', trigger: 'blur' }], - reason: [{ required: true, whitespace: true, message: '请填写操作原因', trigger: 'blur' }], } /** 查询已配置的独立访问策略 */ @@ -340,7 +378,11 @@ async function saveAccess() { blocked: accessBlocked.value, reason: accessForm.reason.trim(), }) - proxy.$modal.msgSuccess(accessBlocked.value ? '已禁止用户访问应用' : '已解除访问禁止') + proxy.$modal.msgSuccess( + accessBlocked.value + ? t('oauth:grant.theUserHasBeenBlockedFromThisApplication') + : t('oauth:grant.accessRestrictionRemoved') + ) accessOpen.value = false emit('changed') await getList() diff --git a/ruoyi-fastapi-frontend/vue2/web/src/views/system/oauth/grant/index.vue b/ruoyi-fastapi-frontend/vue2/web/src/views/system/oauth/grant/index.vue index b51b89355..3d40c61af 100644 --- a/ruoyi-fastapi-frontend/vue2/web/src/views/system/oauth/grant/index.vue +++ b/ruoyi-fastapi-frontend/vue2/web/src/views/system/oauth/grant/index.vue @@ -1,10 +1,16 @@ @@ -501,7 +549,13 @@ function short(value) { /** 获取授权状态名称 */ function statusText(value) { - return { active: '仍然有效', revoked: '已撤销', expired: '已过期' }[value] || '未知状态' + return ( + { + active: t('oauth:grant.stillValid'), + revoked: t('oauth:grant.revoked'), + expired: t('common:expired'), + }[value] || t('oauth:shared.unknownStatus') + ) } /** 获取授权状态标签类型 */ @@ -550,7 +604,7 @@ async function revoke() { await revokeOAuthGrants(revokeIds.value.join(','), { reason: reason.value.trim(), }) - proxy.$modal.msgSuccess('授权已撤销') + proxy.$modal.msgSuccess(t('oauth:grant.grantRevoked')) revokeOpen.value = false await getList() } finally { @@ -574,7 +628,11 @@ async function saveAccess() { blocked: accessBlocked.value, reason: accessReason.value.trim(), }) - proxy.$modal.msgSuccess(accessBlocked.value ? '已禁止访问该应用' : '已解除禁止,请重新授权') + proxy.$modal.msgSuccess( + accessBlocked.value + ? t('oauth:grant.accessToThisApplicationHasBeenBlocked') + : t('oauth:grant.restrictionRemovedGrantConsentAgain') + ) accessOpen.value = false await getList() } finally { diff --git a/ruoyi-fastapi-frontend/vue2/web/src/views/system/oauth/key/index.vue b/ruoyi-fastapi-frontend/vue2/web/src/views/system/oauth/key/index.vue index 0a60dae36..50a29b7be 100644 --- a/ruoyi-fastapi-frontend/vue2/web/src/views/system/oauth/key/index.vue +++ b/ruoyi-fastapi-frontend/vue2/web/src/views/system/oauth/key/index.vue @@ -1,9 +1,11 @@ @@ -401,19 +438,21 @@ const activeKey = computed(() => rows.value.find((item) => item.status === 'acti const serviceStatus = computed(() => { if (!enabled.value) { return { - title: '尚未启用', - description: '可以先准备密钥,启用服务后再对外签发凭据。', + title: t('oauth:key.notEnabled'), + description: t('oauth:key.youCanPrepareKeysFirstAndStartIssuingCredentialsWhenTheService'), } } if (!ready.value) { return { - title: '等待初始化签名密钥', - description: '管理后台可以正常使用,认证接口会暂时拒绝请求。', + title: t('oauth:key.waitingForSigningKeyInitialization'), + description: t( + 'oauth:key.theAdminConsoleRemainsAvailableAuthenticationEndpointsWillTemporarilyRejectRequests' + ), } } return { - title: '已启用并可以提供认证', - description: '身份凭据会使用当前签名密钥签署。', + title: t('oauth:key.enabledAndReadyForAuthentication'), + description: t('oauth:key.identityCredentialsAreSignedWithTheCurrentSigningKey'), } }) const nextKey = computed( @@ -427,21 +466,31 @@ const nextKey = computed( const validateActivationTime = (_rule, value, callback) => { if (!value) { - return callback(new Error('请选择开始签名时间')) + return callback(new Error(t('oauth:key.chooseASigningStartTime'))) } callback() } const rules = { kid: [ - { required: true, message: '请输入便于识别的密钥编号', trigger: 'blur' }, + { + required: true, + message: () => t('oauth:key.enterAnIdentifiableKeyID'), + trigger: 'blur', + }, { pattern: /^[A-Za-z0-9._-]+$/, - message: '只能使用字母、数字、点、横线和下划线', + message: () => t('oauth:key.useOnlyLettersDigitsPeriodsHyphensAndUnderscores'), trigger: 'blur', }, ], - publishAt: [{ required: true, message: '请选择公开公钥时间', trigger: 'change' }], + publishAt: [ + { + required: true, + message: () => t('oauth:key.chooseAPublicKeyPublicationTime'), + trigger: 'change', + }, + ], activateAt: [{ validator: validateActivationTime, trigger: 'change' }], } @@ -449,11 +498,11 @@ const rules = { function statusText(value) { return ( { - pending: '等待接管', - active: '正在签名', - retiring: '验证旧凭据', - retired: '已退出', - compromised: '疑似泄露', + pending: t('oauth:key.awaitingActivation'), + active: t('oauth:key.signing'), + retiring: t('oauth:key.verifyingOldCredentials'), + retired: t('oauth:key.retired'), + compromised: t('oauth:key.possiblyCompromised'), }[value] || value ) } @@ -475,60 +524,62 @@ function statusType(value) { function roleText(value) { return ( { - pending: '公钥已发布,尚未签发新凭据', - active: '正在用于签发新的身份和访问凭据', - retiring: '不再签发新凭据,只验证尚未到期的旧凭据', - retired: '已从公开密钥列表移出', - compromised: '已标记为不可信,请尽快完成应急轮换', - }[value] || '状态信息未知' + pending: t('oauth:key.publicKeyPublishedNotYetIssuingNewCredentials'), + active: t('oauth:key.usedToIssueNewIdentityAndAccessCredentials'), + retiring: t('oauth:key.noLongerIssuingNewCredentialsOnlyVerifyingUnexpiredOldCredentials'), + retired: t('oauth:key.removedFromThePublicKeyList'), + compromised: t('oauth:key.markedAsUntrustedCompleteEmergencyRotationAsSoonAsPossible'), + }[value] || t('oauth:key.unknownStatusInformation') ) } /** 缩略显示RSA公钥模数 */ function publicFingerprint(jwk) { if (!jwk?.n) { - return '公开指纹尚未提供' + return t('oauth:key.publicFingerprintUnavailable') } - return `公开指纹 RSA · ${jwk.n.slice(0, 18)}…` + return t('oauth:key.publicFingerprintRSAValue', { value0: jwk.n.slice(0, 18) }) } /** 获取密钥后续处理计划 */ function nextActionText(row) { return ( { - pending: '等待开始使用', - active: '在下一把密钥接管后停止签名', - retiring: '等待旧凭据全部到期', - retired: '可以清理元数据', - compromised: '立即安排应急轮换', - }[row.status] || '暂无计划' + pending: t('oauth:key.waitingToStart'), + active: t('oauth:key.stopSigningWhenTheNextKeyTakesOver'), + retiring: t('oauth:key.waitingForAllOldCredentialsToExpire'), + retired: t('oauth:key.metadataCanBeRemoved'), + compromised: t('oauth:key.scheduleEmergencyRotationNow'), + }[row.status] || t('oauth:key.noPlan') ) } /** 显示密钥后续操作的时间条件 */ function nextActionTime(row) { if (row.status === 'pending') { - return parseTime(row.signingStartAt) || '需要手动开始使用' + return parseTime(row.signingStartAt) || t('oauth:key.manualActivationRequired') } if (['retiring', 'retired'].includes(row.status)) { return row.removeFromJwksAt - ? `最早清理:${parseTime(row.removeFromJwksAt)}` - : '等待安全验证窗口结束' + ? t('oauth:key.earliestCleanupValue', { value0: parseTime(row.removeFromJwksAt) }) + : t('oauth:key.waitingForTheSafeVerificationWindowToEnd') } if (row.status === 'active') { - return '当前没有自动停止时间' + return t('oauth:key.noAutomaticStopTimeIsSet') } - return '请查看安全日志' + return t('oauth:key.checkTheSecurityLogs') } /** 检查密钥是否已到允许启用的公开时间 */ function activationDisabledReason(row) { const publishAt = new Date(row.publishAt).getTime() if (!Number.isFinite(publishAt)) { - return '公钥公开时间无效,请刷新列表后重试' + return t('oauth:key.invalidPublicKeyPublicationTimeRefreshTheListAndTryAgain') } if (publishAt > Date.now()) { - return `公钥将在 ${parseTime(row.publishAt)} 公开,之后才能开始使用` + return t('oauth:key.thePublicKeyWillBePublishedAtValueItCanBeActivatedAfterThat', { + value0: parseTime(row.publishAt), + }) } return '' } @@ -568,13 +619,15 @@ async function rotate() { return } if (payload.activateAt && new Date(payload.activateAt) < new Date(payload.publishAt)) { - proxy.$modal.msgError('开始签名时间不能早于公开公钥时间') + proxy.$modal.msgError(t('oauth:key.signingCannotStartBeforePublicKeyPublication')) return } saving.value = true try { await rotateOidcKey(payload) - proxy.$modal.msgSuccess('轮换计划已创建,新公钥会按计划先行公开') + proxy.$modal.msgSuccess( + t('oauth:key.rotationScheduledTheNewPublicKeyWillBePublishedFirstAsPlanned') + ) open.value = false await getList() } finally { @@ -592,31 +645,42 @@ async function activate(row) { const signingStartAt = new Date(row.signingStartAt).getTime() const scheduleNotice = Number.isFinite(signingStartAt) && signingStartAt > Date.now() - ? `该密钥原计划在 ${parseTime(row.signingStartAt)} 开始签名,本次操作将提前生效。` - : '它将立即接管新凭据的签发。' + ? t('oauth:key.thisKeyWasScheduledToStartSigningAtValueThisActionActivatesItEarly', { + value0: parseTime(row.signingStartAt), + }) + : t('oauth:key.itWillImmediatelyTakeOverIssuanceOfNewCredentials') await proxy.$modal.confirm( - `开始使用密钥 ${row.kid}?${scheduleNotice}当前签名密钥会进入旧凭据验证期。` + t( + 'oauth:key.activateKeyValueValueTheCurrentSigningKeyWillEnterTheOldCredentialVerificationPeriod', + { value0: row.kid, value1: scheduleNotice } + ) ) await activateOidcKey(row.kid) - proxy.$modal.msgSuccess('新的签名密钥已开始使用') + proxy.$modal.msgSuccess(t('oauth:key.theNewSigningKeyIsActive')) await getList() } /** 停止使用密钥签发新令牌 */ async function retire(row) { await proxy.$modal.confirm( - `停止使用密钥 ${row.kid} 签发新凭据?它的公钥仍会保留一段时间,用于验证尚未到期的旧凭据。` + t('oauth:key.stopIssuingNewCredentialsWithKeyValueItsPublicKeyWillRemainAvailableFor', { + value0: row.kid, + }) ) await retireOidcKey(row.kid) - proxy.$modal.msgSuccess('密钥已停止签名,当前仅用于验证旧凭据') + proxy.$modal.msgSuccess(t('oauth:key.theKeyHasStoppedSigningAndIsNowUsedOnlyToVerify')) await getList() } /** 删除按钮操作 */ async function handleDelete(row) { - await proxy.$modal.confirm(`删除密钥 ${row.kid} 的记录?请确认所有由它签署的凭据都已到期。`) + await proxy.$modal.confirm( + t('oauth:key.deleteTheRecordForKeyValueConfirmThatEveryCredentialItSignedHasExpired', { + value0: row.kid, + }) + ) await deleteOidcKey(row.kid) - proxy.$modal.msgSuccess('密钥记录已删除') + proxy.$modal.msgSuccess(t('oauth:key.keyRecordDeleted')) await getList() } diff --git a/ruoyi-fastapi-frontend/vue2/web/src/views/system/oauth/resource/index.vue b/ruoyi-fastapi-frontend/vue2/web/src/views/system/oauth/resource/index.vue index 8a70acce7..741f57c6f 100644 --- a/ruoyi-fastapi-frontend/vue2/web/src/views/system/oauth/resource/index.vue +++ b/ruoyi-fastapi-frontend/vue2/web/src/views/system/oauth/resource/index.vue @@ -1,10 +1,14 @@ diff --git a/ruoyi-fastapi-frontend/vue3/mobile/src/pages/mine/info/edit.vue b/ruoyi-fastapi-frontend/vue3/mobile/src/pages/mine/info/edit.vue index bd20b5625..1a77d14c8 100644 --- a/ruoyi-fastapi-frontend/vue3/mobile/src/pages/mine/info/edit.vue +++ b/ruoyi-fastapi-frontend/vue3/mobile/src/pages/mine/info/edit.vue @@ -3,41 +3,49 @@ - 用户昵称 + {{ + $t('mobile:profile.nickname') + }} - 手机号码 + {{ + $t('mobile:profile.phone') + }} - 邮箱 + {{ + $t('mobile:profile.email') + }} - 性别 + {{ + $t('mobile:profile.sex') + }} - 提 交 + {{ $t('mobile:actions.submit') }} @@ -69,8 +77,9 @@ diff --git a/ruoyi-fastapi-frontend/vue3/mobile/src/plugins/modal.js b/ruoyi-fastapi-frontend/vue3/mobile/src/plugins/modal.js index dd718f972..50263bdb1 100644 --- a/ruoyi-fastapi-frontend/vue3/mobile/src/plugins/modal.js +++ b/ruoyi-fastapi-frontend/vue3/mobile/src/plugins/modal.js @@ -1,3 +1,4 @@ +import { t } from '@/i18n' export default { // 消息提示 msg(content) { @@ -27,19 +28,20 @@ export default { // 弹出提示 alert(content, title) { uni.showModal({ - title: title || '系统提示', + title: title || t('mobile:app.systemNotice'), content: content, showCancel: false, + confirmText: t('common:confirm'), }) }, // 确认窗体 confirm(content, title) { return new Promise((resolve, reject) => { uni.showModal({ - title: title || '系统提示', + title: title || t('mobile:app.systemNotice'), content: content, - cancelText: '取消', - confirmText: '确定', + cancelText: t('common:cancel'), + confirmText: t('common:confirm'), success: function (res) { if (res.confirm) { resolve(res.confirm) diff --git a/ruoyi-fastapi-frontend/vue3/mobile/src/store/modules/user.js b/ruoyi-fastapi-frontend/vue3/mobile/src/store/modules/user.js index 8ccc71af2..30453568b 100644 --- a/ruoyi-fastapi-frontend/vue3/mobile/src/store/modules/user.js +++ b/ruoyi-fastapi-frontend/vue3/mobile/src/store/modules/user.js @@ -1,3 +1,4 @@ +import { i18n } from '@/i18n' import { defineStore } from 'pinia' import { ref } from 'vue' import config from '@/config' @@ -11,6 +12,9 @@ import defAva from '@/static/images/profile.jpg' const baseUrl = config.baseUrl +const sessionChangedError = () => + Object.assign(new Error('User session changed'), { code: 'USER_SESSION_CHANGED' }) + export const useUserStore = defineStore('user', () => { const token = ref(getToken()) const id = ref(storage.get(constant.id)) @@ -86,10 +90,15 @@ export const useUserStore = defineStore('user', () => { // 获取用户信息 const getInfoAction = () => { + const requestedToken = getToken() + const isCurrentSession = () => + requestedToken && requestedToken === getToken() && requestedToken === token.value return new Promise((resolve, reject) => { getInfo() .then((res) => { + if (!isCurrentSession()) throw sessionChangedError() const user = res.user + i18n.setAccount(user?.userId, user?.locale, user?.localeRevision) appTimezone.value = res.appTimezone setBusinessTimezone(res.appTimezone) applyTimezone(user.timeZone) @@ -111,7 +120,7 @@ export const useUserStore = defineStore('user', () => { resolve(res) }) .catch((error) => { - reject(error) + reject(isCurrentSession() ? error : sessionChangedError()) }) }) } @@ -131,6 +140,7 @@ export const useUserStore = defineStore('user', () => { SET_ROLES([]) SET_PERMISSIONS([]) removeToken() + i18n.setAccount(null) storage.clean() } } diff --git a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/common.js b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/common.js index cb99fbf6b..e8284a5fb 100644 --- a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/common.js +++ b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/common.js @@ -1,3 +1,4 @@ +import { t } from '@/i18n' /** * 显示消息提示框 * @param content 提示的标题 @@ -16,10 +17,10 @@ export function toast(content) { export function showConfirm(content) { return new Promise((resolve, reject) => { uni.showModal({ - title: '提示', + title: t('common:notice'), content: content, - cancelText: '取消', - confirmText: '确定', + cancelText: t('common:cancel'), + confirmText: t('common:confirm'), success: function (res) { resolve(res) }, diff --git a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/dict.js b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/dict.js index 8f093a75f..dd69d7d38 100644 --- a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/dict.js +++ b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/dict.js @@ -1,30 +1,35 @@ +import { localizeDictionary } from '@/i18n/names.mjs' +import { getToken } from '@/utils/auth' import useDictStore from '@/store/modules/dict' import { getDicts } from '@/api/system/dict/data' -import { ref, toRefs } from 'vue' +import { computed, ref } from 'vue' +import { resolveText } from '@/i18n/adapter' /** - * 获取字典数据 + * 获取字典数据,缓存原始名称及译文,显示标签随语言切换。 */ -export function useDict(...args) { - const res = ref({}) - return (() => { - args.forEach((dictType, index) => { - res.value[dictType] = [] - const dicts = useDictStore().getDict(dictType) - if (dicts) { - res.value[dictType] = dicts - } else { - getDicts(dictType).then((resp) => { - res.value[dictType] = resp.data.map((p) => ({ - label: p.dictLabel, - value: p.dictValue, - elTagType: p.listClass, - elTagClass: p.cssClass, - })) - useDictStore().setDict(dictType, res.value[dictType]) - }) - } - }) - return toRefs(res.value) - })() +export function useDict(...types) { + const result = {} + types.forEach((type) => { + const cached = useDictStore().getDict(type) + const raw = ref(cached || []) + result[type] = computed(() => localizeDictionary(raw.value, resolveText)) + if (!cached) { + const token = getToken() + getDicts(type).then((response) => { + if (getToken() !== token) return + raw.value = response.data.map((item) => ({ + originalLabel: item.dictLabel, + label: item.dictLabel, + labelI18n: item.dictLabelI18n || {}, + value: item.dictValue, + elTagType: item.listClass, + elTagClass: item.cssClass, + })) + useDictStore().removeDict(type) + useDictStore().setDict(type, raw.value) + }) + } + }) + return result } diff --git a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/errorCode.js b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/errorCode.js index 0eef5eb6d..f5d85bc44 100644 --- a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/errorCode.js +++ b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/errorCode.js @@ -1,6 +1,15 @@ +import { t } from '@/i18n' export default { - 401: '认证失败,无法访问系统资源', - 403: '当前操作没有权限', - 404: '访问资源不存在', - default: '系统未知错误,请反馈给管理员', + get 401() { + return t('mobile:errors.unauthorized') + }, + get 403() { + return t('mobile:errors.forbidden') + }, + get 404() { + return t('mobile:errors.notFound') + }, + get default() { + return t('mobile:errors.unknown') + }, } diff --git a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/request.js b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/request.js index ff5c510f2..aca5ed4d4 100644 --- a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/request.js +++ b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/request.js @@ -1,3 +1,4 @@ +import { i18n, t } from '@/i18n' import { handleSessionExpired } from '@/utils/session' import config from '@/config' import { getToken } from '@/utils/auth' @@ -19,7 +20,7 @@ const baseUrl = config.baseUrl const request = async (config) => { // 是否需要设置 token const isToken = (config.headers || {}).isToken === false - config.header = config.header || {} + config.header = { ...i18n.headers, ...config.header } config.headers = config.headers || {} config.header['X-Timezone'] = config.header['X-Timezone'] || getDisplayTimezone() const token = getToken() @@ -61,7 +62,7 @@ const request = async (config) => { const { code, msg } = getResponseStatus(res, res.data) if (code === 401) { handleSessionExpired(isToken ? null : token) - const error = new Error('无效的会话,或者会话已过期,请重新登录。') + const error = new Error(t('mobile:errors.sessionInvalid')) error.response = res reject(error) } else if (code === 500) { @@ -107,11 +108,11 @@ const request = async (config) => { let { message } = error if (message === 'Network Error') { - message = '后端接口连接异常' + message = t('common:network.error') } else if (message && message.includes('timeout')) { - message = '系统接口请求超时' + message = t('common:network.timeout') } else if (message && message.includes('Request failed with status code')) { - message = '系统接口' + message.substr(message.length - 3) + '异常' + message = t('mobile:errors.httpStatus', { status: message.substr(message.length - 3) }) } if (message) { toast(message) diff --git a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/session.js b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/session.js index 1c6344ba1..a4aa01328 100644 --- a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/session.js +++ b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/session.js @@ -1,3 +1,4 @@ +import { t } from '@/i18n' import { useUserStore } from '@/store/modules/user' import { getToken } from '@/utils/auth' import { showConfirm } from '@/utils/common' @@ -14,7 +15,7 @@ export function handleSessionExpired(token) { if (!token || token !== getToken()) return Promise.resolve(false) if (sessionExpiredPromise) return sessionExpiredPromise sessionExpiredPromise = Promise.resolve() - .then(() => showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?')) + .then(() => showConfirm(t('common:session.expired'))) .then(async (result) => { if (!result.confirm || token !== getToken()) return false await useUserStore().logOut() diff --git a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/time.js b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/time.js index d6e69115d..d3c38b94f 100644 --- a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/time.js +++ b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/time.js @@ -1,3 +1,4 @@ +import { translateMessage } from '../i18n/message.mjs' // 补齐小程序运行时可能缺失的 Intl 能力和 IANA 时区数据。 // 同步加载,保证业务时区初始化和首屏渲染时已具备完整能力。 import '@formatjs/intl-getcanonicallocales/polyfill.js' @@ -20,12 +21,21 @@ const DATE_ONLY_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/ const WALL_TIME_PATTERN = /^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?$/ const RFC3339_PATTERN = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(\.\d+)?(Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/ -const WEEKDAYS = ['日', '一', '二', '三', '四', '五', '六'] +const WEEKDAYS = [ + () => translateMessage('utility:weekday.sunday', '日'), + () => translateMessage('utility:weekday.monday', '一'), + () => translateMessage('utility:weekday.tuesday', '二'), + () => translateMessage('utility:weekday.wednesday', '三'), + () => translateMessage('utility:weekday.thursday', '四'), + () => translateMessage('utility:weekday.friday', '五'), + () => translateMessage('utility:weekday.saturday', '六'), +] const MILLISECONDS_PER_SECOND = 1000 const MILLISECONDS_PER_MINUTE = 60 * MILLISECONDS_PER_SECOND const MILLISECONDS_PER_HOUR = 60 * MILLISECONDS_PER_MINUTE const ORIGINAL_TIME_FIELDS = Symbol('originalTimeFields') const timezoneFormatters = new Map() +const displayFormatters = new Map() const businessTimezone = ref('Asia/Shanghai') const userTimezone = ref('auto') @@ -55,7 +65,11 @@ export class TimeInputError extends Error { */ function getFormatter(timezoneName) { if (typeof timezoneName !== 'string' || !timezoneName.trim() || /^[+-]/.test(timezoneName)) { - throw new Error(`无效的 IANA 时区: ${timezoneName}`) + throw new Error( + translateMessage('utility:timezone.invalid', `无效的 IANA 时区: ${timezoneName}`, { + timezoneName, + }) + ) } const name = timezoneName.trim() @@ -75,7 +89,11 @@ function getFormatter(timezoneName) { }) timezoneFormatters.set(name, formatter) } catch { - throw new Error(`无效的 IANA 时区: ${timezoneName}`) + throw new Error( + translateMessage('utility:timezone.invalid', `无效的 IANA 时区: ${timezoneName}`, { + timezoneName, + }) + ) } } return timezoneFormatters.get(name) @@ -295,10 +313,38 @@ function formatEpoch(epoch, pattern, timezoneName) { .replaceAll('{h}', 'HH') .replaceAll('{i}', 'mm') .replaceAll('{s}', 'ss') - .replaceAll('{a}', `[${WEEKDAYS[value.day()]}]`) + .replaceAll('{a}', `[${WEEKDAYS[value.day()]()}]`) return value.format(format) } +/** + * 按指定语言和时区生成日期时间的展示文本。 + * + * @param {string|Date} value RFC 3339 字符串或 Date 对象 + * @param {string} locale 展示语言 + * @param {string} timezoneName 目标时区,默认使用当前用户展示时区 + * @returns {string|null} 日期时间文本,非法输入返回 null + */ +export function formatDisplayTime(value, locale, timezoneName = getDisplayTimezone()) { + const epoch = parseInstantMilliseconds(value) + if (epoch === null) { + return null + } + + const cacheKey = `${locale}:${timezoneName}` + if (!displayFormatters.has(cacheKey)) { + displayFormatters.set( + cacheKey, + new Intl.DateTimeFormat(locale, { + dateStyle: 'medium', + timeStyle: 'medium', + timeZone: timezoneName, + }) + ) + } + return displayFormatters.get(cacheKey).format(epoch) +} + /** * 将真实时刻格式化为业务时间。 * @@ -363,7 +409,10 @@ export function formatEpochSeconds(value, pattern, timezoneName) { export function getWallTimeCandidates(value, timezoneName = getDisplayTimezone()) { const wallMilliseconds = parseWallTimeMilliseconds(value) if (wallMilliseconds === null) { - throw new TimeInputError(`无效的日期时间: ${value}`, 'INVALID_TIME') + throw new TimeInputError( + translateMessage('utility:timezone.invalidDateTime', `无效的日期时间: ${value}`, { value }), + 'INVALID_TIME' + ) } const offsets = new Set() @@ -414,7 +463,11 @@ export function toRfc3339(value, { timezoneName = getDisplayTimezone(), offset } const candidates = getWallTimeCandidates(value, timezoneName) if (!candidates.length) { throw new TimeInputError( - `${value} 在 ${timezoneName} 不存在,请选择夏令时跳转后的有效时间`, + translateMessage( + 'utility:timezone.nonexistent', + `${value} 在 ${timezoneName} 不存在,请选择夏令时跳转后的有效时间`, + { value, timezoneName } + ), 'DST_GAP' ) } @@ -427,7 +480,11 @@ export function toRfc3339(value, { timezoneName = getDisplayTimezone(), offset } return selected.value } throw new TimeInputError( - `${value} 在 ${timezoneName} 出现两次,请选择 UTC 偏移`, + translateMessage( + 'utility:timezone.ambiguous', + `${value} 在 ${timezoneName} 出现两次,请选择 UTC 偏移`, + { value, timezoneName } + ), 'DST_FOLD', candidates ) @@ -456,7 +513,10 @@ export function normalizeRangeBoundary(value) { } if (typeof value === 'string' && DATE_ONLY_PATTERN.test(value)) { if (parseWallTimeMilliseconds(value, true) === null) { - throw new TimeInputError(`无效的日期: ${value}`, 'INVALID_DATE') + throw new TimeInputError( + translateMessage('utility:timezone.invalidDate', `无效的日期: ${value}`, { value }), + 'INVALID_DATE' + ) } return value } @@ -485,7 +545,14 @@ export function prepareTimeFields(record, fields, timezoneName = getDisplayTimez ? original : toBusinessDateTimeInput(original, timezoneName) if (input === null && original != null) { - throw new TimeInputError(`字段 ${field} 包含无效的 RFC 3339 时间`, 'INVALID_TIME') + throw new TimeInputError( + translateMessage( + 'utility:timezone.invalidField', + `字段 ${field} 包含无效的 RFC 3339 时间`, + { field } + ), + 'INVALID_TIME' + ) } result[field] = input originals[field] = { original, input } diff --git a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/transportCrypto.js b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/transportCrypto.js index e64b89a57..63cff4989 100644 --- a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/transportCrypto.js +++ b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/transportCrypto.js @@ -1,3 +1,5 @@ +import { localeRequestHeaders } from './transportLocale.mjs' +import { translateMessage } from '../i18n/message.mjs' import config from '@/config' import forge, { primeForgeRandomBytes } from '@/utils/transportForge' import { @@ -17,7 +19,6 @@ const DEFAULT_TRANSPORT_ENVELOPE_VERSION = '1' const KEY_REFRESH_BUFFER_MIN_SECONDS = 30 const KEY_REFRESH_BUFFER_MAX_SECONDS = 300 const TRANSPORT_KEY_META_CACHE_KEY = 'transportCryptoKeyMeta' -const TRANSPORT_RETRYABLE_ERROR_MESSAGES = new Set(['Decryption failed', '密钥版本不存在']) const AES_GCM_TAG_LENGTH_BYTES = 16 const FORGE_RANDOM_POOL_BYTES = 4096 @@ -292,9 +293,13 @@ function normalizeRandomBytesResult(randomValues, expectedLength) { return randomValues } throw new Error( - `平台随机数返回结果格式不受支持: tag=${getObjectTag(randomValues)}, keys=${Object.keys( - randomValues || {} - ).join(',')}` + translateMessage( + 'utility:crypto.randomFormat', + `平台随机数返回结果格式不受支持: tag=${getObjectTag(randomValues)}, keys=${Object.keys( + randomValues || {} + ).join(',')}`, + { arg0: getObjectTag(randomValues), arg1: Object.keys(randomValues || {}).join(',') } + ) ) } @@ -452,7 +457,9 @@ async function getRandomBytes(length) { if (appPlusRandomBytes !== null) { return appPlusRandomBytes } - throw new Error('当前运行环境缺少安全随机数能力') + throw new Error( + translateMessage('utility:crypto.randomUnavailable', '当前运行环境缺少安全随机数能力') + ) } /** @@ -661,7 +668,10 @@ function validateTransportPublicKeyResponse(responsePayload) { !responsePayload?.data || typeof responsePayload.data !== 'object' ) { - throw new Error(responsePayload?.msg || '获取传输层公钥失败') + throw new Error( + responsePayload?.msg || + translateMessage('utility:crypto.publicKeyFailed', '获取传输层公钥失败') + ) } } @@ -674,16 +684,16 @@ function validateTransportPublicKeyResponse(responsePayload) { */ function validateTransportPublicKeyPayload(payload, transportPolicy) { if (!payload?.publicKey || !payload?.kid) { - throw new Error('获取传输层公钥失败') + throw new Error(translateMessage('utility:crypto.publicKeyFailed', '获取传输层公钥失败')) } if ( String(payload.envelopeVersion || DEFAULT_TRANSPORT_ENVELOPE_VERSION) !== transportPolicy.envelopeVersion ) { - throw new Error('传输层公钥协议版本不受支持') + throw new Error(translateMessage('utility:crypto.keyProtocol', '传输层公钥协议版本不受支持')) } if (payload.alg !== transportPolicy.requestEnvelopeAlgorithm) { - throw new Error('传输层公钥算法不受支持') + throw new Error(translateMessage('utility:crypto.keyAlgorithm', '传输层公钥算法不受支持')) } } @@ -709,28 +719,34 @@ function validateResponseEnvelope( const aad = envelope.aad if (String(envelope.v || '') !== transportPolicy.envelopeVersion) { - throw new Error('传输层响应协议版本不受支持') + throw new Error( + translateMessage('utility:crypto.responseProtocol', '传输层响应协议版本不受支持') + ) } if (String(envelope.alg || '') !== transportPolicy.responseEnvelopeAlgorithm) { - throw new Error('传输层响应算法不受支持') + throw new Error(translateMessage('utility:crypto.responseAlgorithm', '传输层响应算法不受支持')) } if (String(envelope.kid || '') !== String(transportContext.kid)) { - throw new Error('传输层响应密钥版本不匹配') + throw new Error(translateMessage('utility:crypto.keyVersion', '传输层响应密钥版本不匹配')) } if (responseKid && String(envelope.kid) !== String(responseKid)) { - throw new Error('传输层响应头与响应体密钥版本不一致') + throw new Error( + translateMessage('utility:crypto.headerVersion', '传输层响应头与响应体密钥版本不一致') + ) } if (!aad || typeof aad !== 'object' || Array.isArray(aad)) { - throw new Error('传输层响应AAD不合法') + throw new Error(translateMessage('utility:crypto.aad', '传输层响应AAD不合法')) } if ( String(aad.method || '').toUpperCase() !== expectedAad.method || String(aad.path || '') !== expectedAad.path ) { - throw new Error('传输层响应的method/path与当前请求不匹配') + throw new Error( + translateMessage('utility:crypto.requestMismatch', '传输层响应的method/path与当前请求不匹配') + ) } if (String(aad.direction || '') !== expectedAad.direction) { - throw new Error('传输层响应方向标识不合法') + throw new Error(translateMessage('utility:crypto.direction', '传输层响应方向标识不合法')) } } @@ -807,11 +823,12 @@ function isUsableKeyMeta(keyMeta, nowTimestamp = getNowTimestamp()) { * @param {string} publicKeyUrl 公钥接口地址 * @returns {Promise} Uni 请求响应 */ -function requestPublicKey(publicKeyUrl) { +function requestPublicKey(publicKeyUrl, requestHeaders) { return new Promise((resolve, reject) => { uni.request({ url: `${TRANSPORT_BASE_URL}${publicKeyUrl}`, method: 'GET', + header: localeRequestHeaders(requestHeaders), timeout: 10000, success: resolve, fail: reject, @@ -825,8 +842,8 @@ function requestPublicKey(publicKeyUrl) { * @param {boolean} forceRefresh 是否强制刷新 * @returns {Promise} 公钥元信息 */ -async function getTransportKeyMeta(forceRefresh = false) { - const transportPolicy = await ensureTransportCryptoPolicyLoaded() +async function getTransportKeyMeta(forceRefresh = false, requestHeaders = {}) { + const transportPolicy = await ensureTransportCryptoPolicyLoaded(false, requestHeaders) const nowTimestamp = getNowTimestamp() if (!forceRefresh && !cachedKeyMeta) { const persistedKeyMeta = uni.getStorageSync(TRANSPORT_KEY_META_CACHE_KEY) @@ -851,7 +868,8 @@ async function getTransportKeyMeta(forceRefresh = false) { return inflightKeyMetaPromise } inflightKeyMetaPromise = requestPublicKey( - transportPolicy.publicKeyUrl || '/transport/crypto/public-key' + transportPolicy.publicKeyUrl || '/transport/crypto/public-key', + requestHeaders ) .then((response) => { const responsePayload = response.data || {} @@ -903,8 +921,8 @@ async function rsaEncryptAesKey(publicKeyPem, aesKeyBytes) { * * @returns {Promise} 请求级传输上下文 */ -async function buildTransportContext() { - const keyMeta = await getTransportKeyMeta() +async function buildTransportContext(requestHeaders) { + const keyMeta = await getTransportKeyMeta(false, requestHeaders) const aesKey = await getRandomBytes(32) const encryptedAesKey = await rsaEncryptAesKey(keyMeta.publicKeyPem, aesKey) return { @@ -990,7 +1008,7 @@ function getOrCreateTransportContext(requestConfig) { if (requestConfig.__transportCryptoContextPromise) { return requestConfig.__transportCryptoContextPromise } - requestConfig.__transportCryptoContextPromise = buildTransportContext() + requestConfig.__transportCryptoContextPromise = buildTransportContext(requestConfig.header) return requestConfig.__transportCryptoContextPromise } @@ -1001,7 +1019,7 @@ function getOrCreateTransportContext(requestConfig) { * @returns {Promise} 加密后的请求配置 */ export async function encryptTransportRequest(requestConfig) { - const transportPolicy = await ensureTransportCryptoPolicyLoaded() + const transportPolicy = await ensureTransportCryptoPolicyLoaded(false, requestConfig.header) if (!shouldEncryptRequest(requestConfig, transportPolicy)) { requestConfig.__transportCryptoEnabledForRequest = false return requestConfig @@ -1029,7 +1047,12 @@ export async function encryptTransportRequest(requestConfig) { buildQueryUrlLength(requestConfig.url, requestConfig.params) > Number(transportPolicy.maxEncryptedGetUrlLength || 4096) ) { - throw new Error('当前GET/DELETE请求参数加密后长度超限,请改用POST请求或精简查询条件') + throw new Error( + translateMessage( + 'utility:crypto.queryLength', + '当前GET/DELETE请求参数加密后长度超限,请改用POST请求或精简查询条件' + ) + ) } } @@ -1093,12 +1116,8 @@ export function resetTransportRequestConfig(requestConfig) { * @returns {boolean} 是否可刷新密钥重试 */ export function shouldRetryTransportWithFreshKey(responseOrError) { - const responseMsg = responseOrError?.data?.msg || responseOrError?.response?.data?.msg - const errorMessage = responseOrError?.message - return ( - TRANSPORT_RETRYABLE_ERROR_MESSAGES.has(responseMsg) || - TRANSPORT_RETRYABLE_ERROR_MESSAGES.has(errorMessage) - ) + const msgKey = responseOrError?.data?.msgKey ?? responseOrError?.response?.data?.msgKey + return msgKey === 'transport.decryptFailed' || msgKey === 'transport.keyExpired' } /** @@ -1121,10 +1140,13 @@ export async function decryptTransportResponse(response, requestConfig) { const transportPolicy = getTransportCryptoPolicy() const transportContext = requestConfig.__transportCryptoContext if (!transportContext) { - throw new Error('缺少响应解密上下文') + throw new Error(translateMessage('utility:crypto.missingContext', '缺少响应解密上下文')) } - const envelope = parseJsonObject(response.data, '传输层响应信封格式不合法') + const envelope = parseJsonObject( + response.data, + translateMessage('utility:crypto.envelope', '传输层响应信封格式不合法') + ) validateResponseEnvelope(envelope, response, requestConfig, transportContext, transportPolicy) const plaintext = await decryptEnvelope(envelope, transportContext) response.data = JSON.parse(plaintext) @@ -1160,7 +1182,10 @@ export async function decryptTransportErrorResponse(error, requestConfig) { } try { - const envelope = parseJsonObject(response.data, '传输层响应信封格式不合法') + const envelope = parseJsonObject( + response.data, + translateMessage('utility:crypto.envelope', '传输层响应信封格式不合法') + ) validateResponseEnvelope(envelope, response, requestConfig, transportContext, transportPolicy) const plaintext = await decryptEnvelope(envelope, transportContext) response.data = JSON.parse(plaintext) diff --git a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/transportCryptoPolicy.js b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/transportCryptoPolicy.js index a9eaaf1dd..8de867e0d 100644 --- a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/transportCryptoPolicy.js +++ b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/transportCryptoPolicy.js @@ -1,3 +1,4 @@ +import { localeRequestHeaders } from './transportLocale.mjs' import config from '@/config' const TRANSPORT_BASE_URL = config.baseUrl @@ -227,11 +228,12 @@ function loadPersistedTransportPolicy() { * * @returns {Promise} Uni 请求响应结果 */ -function requestFrontendConfig() { +function requestFrontendConfig(requestHeaders) { return new Promise((resolve, reject) => { uni.request({ url: `${TRANSPORT_BASE_URL}${TRANSPORT_FRONTEND_CONFIG_URL}`, method: 'GET', + header: localeRequestHeaders(requestHeaders), timeout: 10000, success: resolve, fail: reject, @@ -276,7 +278,7 @@ export function invalidateTransportCryptoPolicy() { * @param {boolean} forceRefresh 是否强制从后端刷新 * @returns {Promise} 当前可用策略 */ -export async function ensureTransportCryptoPolicyLoaded(forceRefresh = false) { +export async function ensureTransportCryptoPolicyLoaded(forceRefresh = false, requestHeaders = {}) { if (!forceRefresh && !cachedTransportPolicy) { const persistedTransportPolicy = loadPersistedTransportPolicy() if (isUsableTransportPolicy(persistedTransportPolicy)) { @@ -292,7 +294,7 @@ export async function ensureTransportCryptoPolicyLoaded(forceRefresh = false) { return inflightTransportPolicyPromise } - inflightTransportPolicyPromise = requestFrontendConfig() + inflightTransportPolicyPromise = requestFrontendConfig(requestHeaders) .then((response) => { const payload = normalizeTransportPolicy(response?.data?.data || {}) cachedTransportPolicy = payload diff --git a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/transportForge.js b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/transportForge.js index b4d6dacf3..7a54c2890 100644 --- a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/transportForge.js +++ b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/transportForge.js @@ -1,3 +1,4 @@ +import { translateMessage } from '../i18n/message.mjs' import forge from 'node-forge/lib/forge' import 'node-forge/lib/util' import 'node-forge/lib/asn1' @@ -178,7 +179,12 @@ function consumeRandomBytes(length) { refillRandomBytePool(length) } if (randomBytePool.length < length) { - throw new Error('传输加密随机数池不足,且当前运行环境无法同步补充安全随机数') + throw new Error( + translateMessage( + 'utility:crypto.randomPool', + '传输加密随机数池不足,且当前运行环境无法同步补充安全随机数' + ) + ) } const bytes = randomBytePool.slice(0, length) randomBytePool = randomBytePool.slice(length) diff --git a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/transportLocale.mjs b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/transportLocale.mjs new file mode 100644 index 000000000..21925a5cd --- /dev/null +++ b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/transportLocale.mjs @@ -0,0 +1,14 @@ +/** + * 为公开配置和公钥请求提取语言协商所需的请求头。 + * + * @param {Object} headers 发起请求时的请求头 + * @returns {Object} 使用标准字段名的语言请求头 + */ +export function localeRequestHeaders(headers = {}) { + for (const [name, value] of Object.entries(headers)) { + if (name.toLowerCase() === 'accept-language' && value !== undefined) { + return { 'Accept-Language': value } + } + } + return {} +} diff --git a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/upload.js b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/upload.js index db67d4c74..3d7014e4e 100644 --- a/ruoyi-fastapi-frontend/vue3/mobile/src/utils/upload.js +++ b/ruoyi-fastapi-frontend/vue3/mobile/src/utils/upload.js @@ -1,3 +1,4 @@ +import { i18n, t } from '@/i18n' import { handleSessionExpired } from '@/utils/session' import config from '@/config' import { getToken } from '@/utils/auth' @@ -10,7 +11,7 @@ const baseUrl = config.baseUrl export default function upload(config) { // 是否需要设置 token const isToken = (config.headers || {}).isToken === false - config.header = config.header || {} + config.header = { ...i18n.headers, ...config.header } const token = getToken() if (token && !isToken) { config.header['Authorization'] = 'Bearer ' + token @@ -33,14 +34,14 @@ export default function upload(config) { try { const result = typeof res.data === 'string' ? JSON.parse(res.data) : res.data if (!result || typeof result !== 'object') { - throw new Error('上传响应格式不正确') + throw new Error(t('mobile:errors.uploadResponse')) } const { code, msg } = getResponseStatus(res, result) if (code === 200) { resolve(result) } else if (code == 401) { handleSessionExpired(isToken ? null : token) - reject('无效的会话,或者会话已过期,请重新登录。') + reject(t('mobile:errors.sessionInvalid')) } else if (code === 500) { toast(msg) reject('500') @@ -49,18 +50,18 @@ export default function upload(config) { reject(code) } } catch (error) { - toast('上传响应格式不正确') + toast(t('mobile:errors.uploadResponse')) reject(error) } }, fail: (error) => { - let message = String(error?.message || error?.errMsg || '上传失败') + let message = String(error?.message || error?.errMsg || t('mobile:errors.upload')) if (message == 'Network Error') { - message = '后端接口连接异常' + message = t('common:network.error') } else if (message.includes('timeout')) { - message = '系统接口请求超时' + message = t('common:network.timeout') } else if (message.includes('Request failed with status code')) { - message = '系统接口' + message.substr(message.length - 3) + '异常' + message = t('mobile:errors.httpStatus', { status: message.substr(message.length - 3) }) } toast(message) const uploadError = error instanceof Error ? error : new Error(message) diff --git a/ruoyi-fastapi-frontend/vue3/mobile/tests/behavior.test.mjs b/ruoyi-fastapi-frontend/vue3/mobile/tests/behavior.test.mjs index fd7006fbe..5e3ead45f 100644 --- a/ruoyi-fastapi-frontend/vue3/mobile/tests/behavior.test.mjs +++ b/ruoyi-fastapi-frontend/vue3/mobile/tests/behavior.test.mjs @@ -1,3 +1,5 @@ import { testMobileBehavior } from '../../../../ruoyi-fastapi-test/frontend/mobile-behavior.mjs' +import { runUserInfoSessionTests } from '../../../../ruoyi-fastapi-test/frontend/logout-behavior.mjs' testMobileBehavior(new URL('../', import.meta.url), 'vue3') +runUserInfoSessionTests(new URL('../', import.meta.url), 'vue3-mobile') diff --git a/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/adapter.test.mjs b/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/adapter.test.mjs new file mode 100644 index 000000000..5d7700233 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/adapter.test.mjs @@ -0,0 +1,52 @@ +import assert from 'node:assert/strict' +import { test } from 'node:test' +import { fileURLToPath } from 'node:url' +import { createServer } from 'vite' +import { computed, createSSRApp, h } from 'vue' +import { renderToString } from 'vue/server-renderer' + +test('uni-app can change its app instance locale after the translation plugin is installed', async () => { + const server = await createServer({ + root: fileURLToPath(new URL('../../', import.meta.url)), + configFile: false, + resolve: { alias: { '@': fileURLToPath(new URL('../../src', import.meta.url)) } }, + css: { postcss: { plugins: [] } }, + server: { middlewareMode: true, hmr: false }, + optimizeDeps: { noDiscovery: true }, + }) + try { + const { + default: plugin, + localeState, + useI18n, + } = await server.ssrLoadModule('/src/i18n/adapter.js') + const app = createSSRApp({ + created() { + let locale = 'zh-CN' + // uni-app 在应用实例上定义此属性,uni.setLocale 通过 Vue 代理写入。 + Object.defineProperty(this, '$locale', { + get: () => locale, + set: (value) => { + locale = value + }, + }) + this.$locale = 'en-US' + }, + render() { + return h('span', this.$locale) + }, + }) + app.use(plugin) + assert.equal('$locale' in app.config.globalProperties, false) + assert.equal(await renderToString(app), 'en-US') + + const language = computed(() => [localeState.locale, localeState.preference]) + assert.deepEqual(language.value, ['zh-CN', 'zh-CN']) + const { engine } = useI18n().i18n + await engine.changeLanguage('en-US') + engine.emit('preferenceChanged', 'auto') + assert.deepEqual(language.value, ['en-US', 'auto']) + } finally { + await server.close() + } +}) diff --git a/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/bootstrap.test.mjs b/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/bootstrap.test.mjs new file mode 100644 index 000000000..22938c348 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/bootstrap.test.mjs @@ -0,0 +1,115 @@ +import assert from 'node:assert/strict' +import { readFileSync } from 'node:fs' +import { test } from 'node:test' +import { createInstance } from 'i18next' +import { localeRequestHeaders } from '../../src/utils/transportLocale.mjs' + +function loadSource(name, bindings, names) { + const source = readFileSync(new URL(`../../src/utils/${name}.js`, import.meta.url), 'utf8') + .replace(/^import[\s\S]*?from ['"][^'"]+['"]\r?\n/gm, '') + .replace(/\bexport (?=(?:async )?function)/g, '') + return new Function(...Object.keys(bindings), source + `\nreturn {${names.join(',')}}`)( + ...Object.values(bindings) + ) +} + +test('policy, public key and key retry keep the original language without forwarding credentials', async () => { + const values = new Map() + const calls = [] + let policyReply + const platform = { + getStorageSync: (key) => values.get(key), + setStorageSync: (key, value) => values.set(key, value), + removeStorageSync: (key) => values.delete(key), + request(options) { + calls.push(options) + if (options.url.endsWith('/frontend-config')) + policyReply = () => + options.success({ + data: { + code: 200, + data: { + transportCryptoActive: true, + configExpireAt: Math.floor(Date.now() / 1000) + 600, + }, + }, + }) + else queueMicrotask(() => options.success({ data: { code: 500 } })) + }, + } + const engine = createInstance() + await engine.init({ + lng: 'en-US', + resources: { + 'en-US': { + utility: JSON.parse( + readFileSync(new URL('../../src/i18n/locales/en-US/utility.json', import.meta.url)) + ), + }, + }, + }) + const bindings = { + localeRequestHeaders, + uni: platform, + Taro: platform, + config: { baseUrl: 'https://api.example.test' }, + getStorage: platform.getStorageSync, + setStorage: platform.setStorageSync, + removeStorage: platform.removeStorageSync, + translateMessage: (key, fallback, options) => + engine.t(key, { defaultValue: fallback, ...options }), + forge: {}, + primeForgeRandomBytes() {}, + } + const policy = loadSource('transportCryptoPolicy', bindings, [ + 'ensureTransportCryptoPolicyLoaded', + 'getTransportCryptoPolicy', + 'getTransportRequestPath', + 'shouldEncryptQuery', + 'shouldEncryptRequest', + 'shouldEncryptResponse', + ]) + const crypto = loadSource('transportCrypto', { ...bindings, ...policy }, [ + 'encryptTransportRequest', + 'resetTransportRequestConfig', + 'invalidateTransportKeyMeta', + 'shouldRetryTransportWithFreshKey', + ]) + const original = { + 'Accept-Language': 'en-US', + Authorization: 'Bearer secret', + } + const config = { + url: '/login', + method: 'post', + data: { username: 'example' }, + header: { ...original }, + } + const pending = crypto.encryptTransportRequest(config) + // A concurrent UI switch must not change the headers of this request's remaining bootstrap work. + original['Accept-Language'] = 'zh-CN' + policyReply() + await assert.rejects(pending, /Could not retrieve the transport public key/) + for (const msgKey of ['transport.decryptFailed', 'transport.keyExpired']) { + assert.equal(crypto.shouldRetryTransportWithFreshKey({ data: { msgKey } }), true) + assert.equal(crypto.shouldRetryTransportWithFreshKey({ response: { data: { msgKey } } }), true) + } + assert.equal( + crypto.shouldRetryTransportWithFreshKey({ data: { msg: 'Decryption failed' } }), + false + ) + crypto.invalidateTransportKeyMeta() + crypto.resetTransportRequestConfig(config) + await assert.rejects( + crypto.encryptTransportRequest(config), + /Could not retrieve the transport public key/ + ) + assert.equal(calls.length, 3) + assert.ok(calls[0].url.endsWith('/frontend-config')) + assert.ok(calls.slice(1).every((call) => call.url.endsWith('/public-key'))) + for (const call of calls) assert.deepEqual(call.header, { 'Accept-Language': 'en-US' }) + assert.equal(config.header.Authorization, 'Bearer secret') + assert.deepEqual(localeRequestHeaders({ 'accept-language': 'zh-CN', Cookie: 'secret' }), { + 'Accept-Language': 'zh-CN', + }) +}) diff --git a/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/names.test.mjs b/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/names.test.mjs new file mode 100644 index 000000000..160640c38 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/names.test.mjs @@ -0,0 +1,39 @@ +import assert from 'node:assert/strict' +import { test } from 'node:test' +import { localizeDictionary } from '../../src/i18n/names.mjs' +import { createLocaleRuntime } from '../../src/i18n/runtime.mjs' + +test('cached dictionaries switch through a third language without changing business values', async () => { + const locale = createLocaleRuntime({ + meta: { + sourceLocale: 'zh-CN', + defaultLocale: 'zh-CN', + locales: [ + { code: 'zh-CN', enabled: true, fallback: [] }, + { code: 'en-US', enabled: true, fallback: ['zh-CN'] }, + { code: 'ja-JP', enabled: true, fallback: ['en-US'] }, + ], + }, + resources: { 'zh-CN': { common: {} }, 'en-US': { common: {} }, 'ja-JP': { common: {} } }, + storage: { get() {}, set() {} }, + }) + const cache = [ + { originalLabel: '正常', value: '0', labelI18n: { 'en-US': 'Enabled', 'ja-JP': '有効' } }, + { originalLabel: '普通', value: 'basic' }, + ] + await locale.setPreference('en-US') + assert.deepEqual( + localizeDictionary(cache, locale.resolveText).map((item) => item.label), + ['Enabled', '普通'] + ) + await locale.setPreference('ja-JP') + assert.deepEqual( + localizeDictionary(cache, locale.resolveText).map((item) => item.label), + ['有効', '普通'] + ) + assert.equal(cache[0].originalLabel, '正常') + assert.deepEqual( + localizeDictionary(cache, locale.resolveText).map((item) => item.value), + ['0', 'basic'] + ) +}) diff --git a/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/protocol.test.mjs b/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/protocol.test.mjs new file mode 100644 index 000000000..dc9f7f9e1 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/protocol.test.mjs @@ -0,0 +1,226 @@ +import assert from 'node:assert/strict' +import { test } from 'node:test' +import { readFileSync } from 'node:fs' +import { createLocaleRuntime, createLocaleRegistry } from '../../src/i18n/runtime.mjs' + +const meta = JSON.parse(readFileSync(new URL('../../src/i18n/locale-meta.json', import.meta.url))) +const resources = { + 'zh-CN': { common: { sample: '中文' } }, + 'en-US': { common: { sample: 'English' } }, +} +function setup(storage = { get: () => null, set: () => {} }, extra = {}) { + return createLocaleRuntime({ meta, resources, scope: 'contract:api', storage, ...extra }) +} +const key = 'contract:api:locale:v2:user:7' + +test('declared language families preserve exact variants', () => { + const registry = createLocaleRegistry(meta, resources) + assert.equal(registry.resolve('auto', ['en-GB']), 'en-US') + assert.equal(registry.resolve('auto', ['en-AU']), 'en-US') + const expanded = { + ...meta, + defaultLocale: 'en-US', + locales: [...meta.locales, { code: 'en-GB', enabled: true, aliases: [], fallback: ['en-US'] }], + } + const precise = createLocaleRegistry(expanded, { ...resources, 'en-GB': {} }) + assert.equal(precise.resolve('en-GB'), 'en-GB') + assert.equal(precise.resolve('zh-TW'), 'en-US') + assert.throws( + () => createLocaleRegistry({ ...meta, languageFallbacks: { en: 'missing' } }, resources), + /Invalid language fallback/ + ) +}) + +test('source language supplies missing text independently of the negotiation default', async () => { + const expanded = { + ...meta, + defaultLocale: 'en-US', + locales: [...meta.locales, { code: 'ja-JP', enabled: true, aliases: [], fallback: [] }], + } + const runtime = setup(undefined, { + meta: expanded, + resources: { ...resources, 'ja-JP': { common: {} } }, + }) + assert.equal(runtime.registry.resolve('unknown'), 'en-US') + await runtime.setPreference('ja-JP') + assert.equal(runtime.t('common:sample'), '中文') + assert.equal(runtime.resolveText('原始名称', { 'en-US': 'English name' }), '原始名称') +}) + +test('delayed save responses cannot overwrite a newer server revision from another tab', async () => { + const data = new Map() + const events = [] + const storage = { + get: (k) => data.get(k), + set: (k, v) => { + data.set(k, v) + events.push([k, v]) + }, + } + const a = setup(storage), + b = setup(storage) + a.setAccount(7, 'zh-CN', '0') + b.setAccount(7, 'zh-CN', '0') + let release + let server = { locale: 'zh-CN', revision: '0' } + const delayed = a.setPreference('en-US', { + save: async () => { + server = { locale: 'en-US', revision: '1' } + const response = { ...server } + await new Promise((resolve) => { + release = resolve + }) + return response + }, + }) + await Promise.resolve() + await b.setPreference('auto', { save: async () => (server = { locale: 'auto', revision: '2' }) }) + a.acceptStorageEvent(key, data.get(key)) + const writes = events.length + release() + await delayed + assert.deepEqual(server, { locale: 'auto', revision: '2' }) + assert.equal(a.preference, 'auto') + assert.equal(b.preference, 'auto') + assert.equal(events.length, writes) + assert.deepEqual(JSON.parse(data.get(key)), server) +}) + +test('out-of-order storage and profile reads preserve the latest decimal revision', () => { + const data = new Map() + const storage = { get: (k) => data.get(k), set: (k, v) => data.set(k, v) } + const runtime = setup(storage) + runtime.setAccount(7, 'en-US', '9007199254740993') + const old = JSON.stringify({ locale: 'zh-CN', revision: '9007199254740992' }) + data.set(key, old) + runtime.acceptStorageEvent(key, old) + runtime.setAccount(7, 'zh-CN', '9007199254740992') + assert.equal(runtime.preference, 'en-US') + assert.equal(runtime.preferenceRevision, '9007199254740993') + assert.equal(JSON.parse(data.get(key)).revision, '9007199254740993') + const restored = setup(storage) + restored.initialize(true) + assert.equal(restored.preference, 'en-US') + assert.equal(restored.preferenceRevision, '9007199254740993') +}) + +test('timeout recovery uses the authoritative snapshot and rejects malformed snapshots', async () => { + const runtime = setup() + runtime.setAccount(7, 'zh-CN', '1') + await runtime.setPreference('en-US', { + save: async () => { + throw Error('timeout') + }, + readBack: async () => ({ locale: 'en-US', revision: '2' }), + }) + assert.equal(runtime.preferenceRevision, '2') + await assert.rejects( + runtime.setPreference('zh-CN', { save: async () => ({ locale: 'zh-CN' }) }), + /Invalid locale snapshot/ + ) + assert.equal(runtime.preference, 'en-US') +}) + +test('offline account snapshots and API instances are isolated', async () => { + const data = new Map() + const storage = { get: (k) => data.get(k), set: (k, v) => data.set(k, v) } + const runtime = setup(storage) + runtime.setAccount(7, 'en-US', '1') + const restored = setup(storage) + restored.initialize(true) + assert.equal(restored.preference, 'en-US') + assert.equal(restored.preferenceRevision, '1') + restored.setAccount(8, 'zh-CN', '0') + restored.acceptStorageEvent(key, JSON.stringify({ locale: 'auto', revision: '9' })) + assert.equal(restored.preference, 'zh-CN') + restored.setAccount(null) + assert.equal(restored.preference, 'zh-CN') + assert.equal(restored.loginPreference, null) + const other = setup(storage, { scope: 'other:api' }) + other.initialize(true) + assert.equal(other.accountId, null) + assert.equal(other.preference, 'zh-CN') +}) + +test('refreshing the same account does not cancel a pending save', async () => { + const runtime = setup() + runtime.setAccount(7, 'zh-CN', '0') + let finish + const pending = runtime.setPreference('en-US', { + save: () => + new Promise((resolve) => { + finish = resolve + }), + }) + await Promise.resolve() + runtime.setAccount(7, 'zh-CN', '0') + finish({ locale: 'en-US', revision: '1' }) + await pending + assert.equal(runtime.preference, 'en-US') + assert.equal(runtime.preferenceRevision, '1') +}) + +test('timeout read-back adopts a newer remote preference even when the requested change lost', async () => { + const runtime = setup() + runtime.setAccount(7, 'zh-CN', '1') + await assert.rejects( + runtime.setPreference('en-US', { + save: async () => { + throw Error('timeout') + }, + readBack: async () => ({ locale: 'auto', revision: '3' }), + }), + /timeout/ + ) + assert.equal(runtime.preference, 'auto') + assert.equal(runtime.preferenceRevision, '3') +}) + +test('invalid profile snapshots leave the current account and its revision intact', () => { + const runtime = setup() + runtime.setAccount(7, 'en-US', '4') + assert.throws(() => runtime.setAccount(undefined, 'zh-CN', '4'), /Missing locale account/) + assert.throws(() => runtime.setAccount(8, 'zh-CN', 4), /Invalid locale snapshot/) + assert.throws(() => runtime.setAccount(8, 'zh-CN'), /Invalid locale snapshot/) + assert.equal(runtime.accountId, '7') + assert.equal(runtime.preferenceRevision, '4') + assert.equal(runtime.preference, 'en-US') +}) + +test('dynamic names keep the database source when an application uses English source catalogs', async () => { + const expanded = { + ...meta, + sourceLocale: 'en-US', + locales: [...meta.locales, { code: 'ja-JP', enabled: true, fallback: [] }], + } + const runtime = setup(undefined, { + meta: expanded, + resources: { ...resources, 'ja-JP': { common: {} } }, + }) + const translations = { 'en-US': 'Users' } + await runtime.setPreference('en-US') + assert.equal(runtime.resolveText('用户管理', translations), 'Users') + await runtime.setPreference('ja-JP') + assert.equal(runtime.t('common:sample'), 'English') + assert.equal(runtime.resolveText('用户管理', translations), '用户管理') +}) + +test('a missing key keeps explicit fallback text or uses a safe label and reports only once', (ctx) => { + const warn = ctx.mock.method(console, 'warn', () => {}) + const runtime = setup(undefined, { + appVersion: '2.0.0', + resources: { + ...resources, + 'en-US': { common: { translationUnavailable: 'Text unavailable' } }, + }, + }) + const t = runtime.engine.getFixedT('en-US', 'layout') + const options = { name: 'Private name' } + assert.equal(t('missing', { ...options, defaultValue: 'Hello {{name}}' }), 'Hello Private name') + assert.equal(t('missing', options), 'Text unavailable') + assert.equal(warn.mock.callCount(), 1) + assert.deepEqual(warn.mock.calls[0].arguments, [ + 'Missing translation', + { namespace: 'layout', key: 'missing', locale: 'en-US', version: '2.0.0' }, + ]) +}) diff --git a/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/runtime.test.mjs b/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/runtime.test.mjs new file mode 100644 index 000000000..9b886ba4e --- /dev/null +++ b/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/runtime.test.mjs @@ -0,0 +1,195 @@ +import assert from 'node:assert/strict' +import { test } from 'node:test' +import { readdirSync, readFileSync } from 'node:fs' +import { fileURLToPath } from 'node:url' +import { createServer } from 'vite' +import { + createLocaleRuntime, + createLocaleRegistry, + normalizeLocale, +} from '../../src/i18n/runtime.mjs' +const meta = JSON.parse(readFileSync(new URL('../../src/i18n/locale-meta.json', import.meta.url))) + +test('the bundled registry includes every enabled locale and namespace', async () => { + const server = await createServer({ + root: fileURLToPath(new URL('../../', import.meta.url)), + configFile: false, + css: { postcss: { plugins: [] } }, + server: { middlewareMode: true, hmr: false }, + optimizeDeps: { noDiscovery: true }, + }) + try { + const { resources } = await server.ssrLoadModule('/src/i18n/registry.js') + for (const { code } of meta.locales.filter((entry) => entry.enabled)) { + const dir = new URL(`../../src/i18n/locales/${code}/`, import.meta.url) + const files = readdirSync(dir).filter((name) => name.endsWith('.json')) + const expected = Object.fromEntries( + files.map((name) => [name.slice(0, -5), JSON.parse(readFileSync(new URL(name, dir)))]) + ) + assert.deepEqual(resources[code], expected) + } + } finally { + await server.close() + } +}) + +const resources = Object.fromEntries( + meta.locales.map(({ code }) => [ + code, + { + common: JSON.parse( + readFileSync(new URL(`../../src/i18n/locales/${code}/common.json`, import.meta.url)) + ), + }, + ]) +) +function setup(extra = {}) { + const data = new Map() + return createLocaleRuntime({ + meta, + resources, + scope: 'test:api', + storage: { get: (k) => data.get(k), set: (k, v) => data.set(k, v) }, + ...extra, + }) +} +test('canonical locales, explicit aliases, and precise region fallback', () => { + const runtime = setup() + assert.equal(normalizeLocale('en_us'), 'en-US') + assert.equal(normalizeLocale('../en'), null) + assert.equal(normalizeLocale('x-acme'), 'x-acme') + assert.equal(runtime.registry.resolve('en'), 'en-US') + assert.equal(runtime.registry.resolve('zh-TW'), 'zh-CN') + assert.equal(runtime.registry.resolve('auto', ['ja-JP', 'en-US']), 'en-US') +}) +test('third language is configured, not a two-language branch', async () => { + const expanded = { + ...meta, + locales: [ + ...meta.locales, + { + code: 'ja-JP', + nativeName: '日本語', + enabled: true, + direction: 'ltr', + aliases: ['ja'], + fallback: ['en-US'], + }, + ], + } + const runtime = setup({ + meta: expanded, + resources: { ...resources, 'ja-JP': { common: { language: '言語' } } }, + }) + await runtime.setPreference('ja-JP') + assert.equal(runtime.locale, 'ja-JP') + assert.equal(runtime.t('common:language'), '言語') + assert.equal(runtime.headers['Accept-Language'], 'ja-JP') + assert.equal(runtime.resolveText('原名', { 'en-US': 'Fallback name' }), 'Fallback name') +}) +test('save failure leaves active language and preference intact', async () => { + const runtime = setup() + runtime.setAccount(1, 'zh-CN', '0') + await assert.rejects( + runtime.setPreference('en-US', { + save: async () => { + throw Error('network') + }, + }) + ) + assert.equal(runtime.locale, 'zh-CN') + assert.equal(runtime.preference, 'zh-CN') +}) +test('an old save cannot overwrite a new account', async () => { + const runtime = setup() + runtime.setAccount(1, 'zh-CN', '0') + let done + const pending = runtime.setPreference('en-US', { + save: () => + new Promise((resolve) => { + done = resolve + }), + }) + await Promise.resolve() + runtime.setAccount(2, 'zh-CN', '0') + done() + await assert.rejects(pending) + assert.equal(runtime.accountId, '2') + assert.equal(runtime.locale, 'zh-CN') +}) +test('an explicit login choice survives reload and is consumed only by a matching login', async () => { + const data = new Map() + const storage = { get: (key) => data.get(key), set: (key, value) => data.set(key, value) } + const runtime = setup({ storage }) + await runtime.setPreference('en-US') + const submitted = runtime.loginPreference + await runtime.setPreference('auto') + runtime.confirmLoginPreference(submitted) + assert.equal(runtime.loginPreference, 'auto') + + const reloaded = setup({ storage }) + reloaded.initialize(false) + assert.equal(reloaded.preference, 'auto') + assert.equal(reloaded.loginPreference, 'auto') + reloaded.confirmLoginPreference('auto') + reloaded.setAccount(1, 'auto', '1') + assert.equal(reloaded.loginPreference, null) + await reloaded.setPreference('en-US', { save: async (locale) => ({ locale, revision: '2' }) }) + reloaded.setAccount(null) + assert.equal(reloaded.preference, 'en-US') + assert.equal(reloaded.loginPreference, null) + + const next = setup({ storage }) + next.initialize(false) + assert.equal(next.preference, 'en-US') + assert.equal(next.loginPreference, null) + next.setAccount(2, 'fr-CA', '0') + assert.equal(next.preference, 'fr-CA') + assert.equal(next.locale, 'zh-CN') +}) +test('auto follows changed device locale without changing the preference', async () => { + let device = 'en-US' + const runtime = setup({ deviceLocales: () => [device] }) + const languages = [] + const preferences = [] + runtime.engine.on('languageChanged', (code) => languages.push(code)) + runtime.engine.on('preferenceChanged', (value) => preferences.push(value)) + await runtime.setPreference('auto') + const oldHeaders = runtime.headers + device = 'en-GB' + runtime.refreshDeviceLocale() + device = 'zh-CN' + runtime.refreshDeviceLocale() + runtime.refreshDeviceLocale() + assert.deepEqual(languages, ['en-US', 'zh-CN']) + assert.deepEqual(preferences, ['auto']) + assert.equal(runtime.preference, 'auto') + assert.equal(runtime.locale, 'zh-CN') + assert.equal(oldHeaders['Accept-Language'], 'en-US') +}) +test('preference switches are serialized and recover after failed requests', async () => { + const runtime = setup() + runtime.setAccount(1, 'zh-CN', '0') + const seen = [] + const save = async (value) => { + seen.push(value) + return { locale: value, revision: String(seen.length) } + } + await Promise.all([ + runtime.setPreference('en-US', { save }), + runtime.setPreference('zh-CN', { save }), + ]) + assert.deepEqual(seen, ['en-US', 'zh-CN']) + assert.equal(runtime.locale, 'zh-CN') +}) +test('fallback cycles and missing resources fail at registration', () => { + assert.throws( + () => + createLocaleRegistry( + { ...meta, locales: meta.locales.map((item) => ({ ...item, fallback: [item.code] })) }, + resources + ), + /cycle/ + ) + assert.throws(() => createLocaleRegistry(meta, {}), /Missing/) +}) diff --git a/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/x18n.test.mjs b/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/x18n.test.mjs new file mode 100644 index 000000000..c5a32834c --- /dev/null +++ b/ruoyi-fastapi-frontend/vue3/mobile/tests/i18n/x18n.test.mjs @@ -0,0 +1,70 @@ +import assert from 'node:assert/strict' +import { test } from 'node:test' +import { mkdtemp, writeFile, mkdir, rm } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import { join, dirname } from 'node:path' +import { createRequire } from 'node:module' +import { spawnSync } from 'node:child_process' +const require = createRequire(import.meta.url) +const cli = join(dirname(require.resolve('@x18n/cli/package.json')), 'bin.mjs') +test('the pinned x18n CLI scans framework calls and fails on broken catalogs', async () => { + const root = await mkdtemp(join(tmpdir(), 'ruoyi-x18n-')) + const source = { greeting: '你好,{{name}}', items_other: '{{count}} 项' } + const english = { + greeting: 'Hello, {{name}}', + items_one: '{{count}} item', + items_other: '{{count}} items', + } + async function catalog(code, values) { + const dir = join(root, 'locales', code) + await mkdir(dir, { recursive: true }) + await writeFile(join(dir, 'common.json'), JSON.stringify(values)) + } + function check() { + const result = spawnSync(process.execPath, [cli, '--root', root, 'check', '--json'], { + encoding: 'utf8', + }) + return { status: result.status, report: JSON.parse(result.stdout) } + } + try { + await writeFile( + join(root, 'x18n.config.json'), + JSON.stringify({ + sourceLocale: 'zh-CN', + presets: ['i18next'], + resources: [{ pattern: 'locales/{locale}/{namespace}.json' }], + namespace: { separator: ':', default: 'common' }, + usage: { include: ['src/**/*.{js,jsx,vue}'], calls: [{ callee: '$t' }] }, + checks: { 'missing-translation': 'error', 'empty-translation': 'error' }, + }) + ) + await mkdir(join(root, 'src')) + await writeFile( + join(root, 'src/usage.vue'), + "" + ) + await catalog('zh-CN', source) + await catalog('en-US', english) + await catalog('ja-JP', { greeting: 'こんにちは、{{name}}', items_other: '{{count}} 件' }) + let result = check() + assert.equal(result.status, 0, JSON.stringify(result.report.errors)) + assert.equal(result.report.data.projects[0].coverage.length, 3) + assert.ok( + result.report.data.projects[0].coverage.every((item) => item.total > 0 && item.missing === 0) + ) + assert.ok(!result.report.diagnostics.some((item) => item.code === 'unused-key')) + await catalog('en-US', { items_one: english.items_one, items_other: english.items_other }) + result = check() + assert.equal(result.status, 1) + assert.ok(result.report.diagnostics.some((item) => item.code === 'missing-translation')) + await catalog('en-US', { ...english, greeting: 'Hello' }) + result = check() + assert.equal(result.status, 1) + assert.ok(result.report.diagnostics.some((item) => item.code === 'placeholder-mismatch')) + await writeFile(join(root, 'src/missing.js'), "t('common:missing')") + result = check() + assert.ok(result.report.diagnostics.some((item) => item.code === 'missing-key')) + } finally { + await rm(root, { recursive: true, force: true }) + } +}) diff --git a/ruoyi-fastapi-frontend/vue3/mobile/x18n.config.mjs b/ruoyi-fastapi-frontend/vue3/mobile/x18n.config.mjs new file mode 100644 index 000000000..b2cfe2f33 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue3/mobile/x18n.config.mjs @@ -0,0 +1,33 @@ +// https://x18n.dev/raw/guide/configuration.md +import { readFileSync } from 'node:fs' + +const meta = JSON.parse( + readFileSync(new URL('./src/i18n/locale-meta.json', import.meta.url), 'utf8') +) +export default { + sourceLocale: meta.sourceLocale, + locales: [ + ...new Set([ + meta.sourceLocale, + ...meta.locales.filter((item) => item.enabled).map((item) => item.code), + ]), + ], + presets: ['i18next'], + resources: [{ pattern: 'src/i18n/locales/{locale}/{namespace}.json' }], + namespace: { separator: ':', default: 'common' }, + usage: { + include: ['src/**/*.{js,jsx,ts,tsx,vue,mjs}'], + exclude: ['src/vendor/**', 'src/uni_modules/**', 'src/i18n/locales/**'], + calls: [ + { callee: 'translateMessage' }, + { callee: '$t' }, + { callee: 'useI18n', factory: true, returns: ['t'] }, + ], + }, + checks: { + 'missing-translation': 'error', + 'empty-translation': 'error', + 'unused-key': 'warning', + 'hard-string': 'warning', + }, +} diff --git a/ruoyi-fastapi-frontend/vue3/web/index.html b/ruoyi-fastapi-frontend/vue3/web/index.html index 17457d30e..79bf39f44 100644 --- a/ruoyi-fastapi-frontend/vue3/web/index.html +++ b/ruoyi-fastapi-frontend/vue3/web/index.html @@ -206,9 +206,10 @@
-
正在加载系统资源,请耐心等待
+
正在加载系统资源,请耐心等待
+ diff --git a/ruoyi-fastapi-frontend/vue3/web/package.json b/ruoyi-fastapi-frontend/vue3/web/package.json index 8bc4c7a62..45df0aed5 100644 --- a/ruoyi-fastapi-frontend/vue3/web/package.json +++ b/ruoyi-fastapi-frontend/vue3/web/package.json @@ -20,7 +20,9 @@ "test:auth-center": "node tests/run-tests.js auth-center", "test:time": "node --test tests/time/time.test.js", "preview": "vite preview", - "test:session": "node --experimental-vm-modules --test tests/security/logout.test.mjs" + "test:session": "node --experimental-vm-modules --test tests/security/logout.test.mjs", + "i18n:check": "node scripts/check-i18n.mjs && x18n --root . check --json", + "test:i18n": "node --test tests/i18n/*.test.mjs" }, "repository": { "type": "git", @@ -43,6 +45,7 @@ "element-plus": "2.14.7", "file-saver": "2.0.5", "fuse.js": "7.5.0", + "i18next": "26.5.11", "js-beautify": "1.15.4", "js-cookie": "3.0.8", "jsencrypt": "3.5.4", @@ -64,6 +67,8 @@ "devDependencies": { "@vitejs/plugin-vue": "6.0.10", "@vue/compiler-sfc": "3.5.44", + "@x18n/builtins": "0.1.14", + "@x18n/cli": "0.1.14", "esbuild": "0.28.2", "less": "4.9.1", "prettier": "3.9.10", diff --git a/ruoyi-fastapi-frontend/vue3/web/plugins/ai/README.md b/ruoyi-fastapi-frontend/vue3/web/plugins/ai/README.md index bd20ebcf4..06106c583 100644 --- a/ruoyi-fastapi-frontend/vue3/web/plugins/ai/README.md +++ b/ruoyi-fastapi-frontend/vue3/web/plugins/ai/README.md @@ -84,3 +84,14 @@ pnpm run build:prod ``` 若只修改文档,不需要执行前端构建。 + +## 国际化 + +本插件通过 `i18n.js` 导出的 `t` / `useI18n` 读取独立 i18next 实例。 +`locale-meta.json` 声明本插件的语言集合、默认语言和回退链,词库位于 `locales/`。 +宿主切换语言时插件重新匹配;宿主新增语言不要求本插件同步新增,网络请求仍使用宿主语言。 + +应用的 `pnpm run i18n:check` 会发现本插件的 `x18n.config.mjs`,按插件声明的语言检查词库。 +也可以在应用目录运行 `pnpm exec x18n --root plugins/ai check` 单独检查插件。 +新增插件语言时同步更新本插件元数据、词库和 `i18n.js` 中的导入。 +会话内卸载时调用 `removePluginLocales()`,重新启用时调用 `registerPluginLocales()`;两者不修改宿主或其他插件资源。 diff --git a/ruoyi-fastapi-frontend/vue3/web/plugins/ai/i18n.js b/ruoyi-fastapi-frontend/vue3/web/plugins/ai/i18n.js new file mode 100644 index 000000000..a1070c29e --- /dev/null +++ b/ruoyi-fastapi-frontend/vue3/web/plugins/ai/i18n.js @@ -0,0 +1,9 @@ +import { createPluginI18n } from '@/i18n/adapter' +import meta from './locale-meta.json' +import zh from './locales/zh-CN.json' +import en from './locales/en-US.json' + +const namespace = 'plugin.ai' +const resources = { 'zh-CN': { [namespace]: zh }, 'en-US': { [namespace]: en } } +export const pluginI18n = createPluginI18n(meta, resources, namespace) +export const { t, useI18n, registerPluginLocales, removePluginLocales } = pluginI18n diff --git a/ruoyi-fastapi-frontend/vue3/web/plugins/ai/locale-meta.json b/ruoyi-fastapi-frontend/vue3/web/plugins/ai/locale-meta.json new file mode 100644 index 000000000..444e85b89 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue3/web/plugins/ai/locale-meta.json @@ -0,0 +1,25 @@ +{ + "sourceLocale": "zh-CN", + "defaultLocale": "zh-CN", + "locales": [ + { + "code": "zh-CN", + "nativeName": "简体中文", + "enabled": true, + "direction": "ltr", + "aliases": ["zh", "zh-Hans"], + "fallback": [] + }, + { + "code": "en-US", + "nativeName": "English", + "enabled": true, + "direction": "ltr", + "aliases": ["en"], + "fallback": ["zh-CN"] + } + ], + "languageFallbacks": { + "en": "en-US" + } +} diff --git a/ruoyi-fastapi-frontend/vue3/web/plugins/ai/locales/en-US.json b/ruoyi-fastapi-frontend/vue3/web/plugins/ai/locales/en-US.json new file mode 100644 index 000000000..feefb9deb --- /dev/null +++ b/ruoyi-fastapi-frontend/vue3/web/plugins/ai/locales/en-US.json @@ -0,0 +1,83 @@ +{ + "reasoningProcess": "Reasoning process", + "thinking": "Thinking…", + "settingsSaved": "Settings saved", + "deleteThisConversation": "Delete this conversation?", + "deletedSuccessfully": "Deleted successfully", + "chooseAModelFirst": "Choose a model first", + "copied": "Copied", + "copyFailed": "Copy failed", + "youCanUploadUpTo10Images": "You can upload up to 10 images", + "newConversation": "New conversation", + "noConversationHistory": "No conversation history", + "aIAssistant": "AI assistant", + "globalSettings": "Global settings", + "chooseAModel": "Choose a model", + "helloIAmYourAIAssistant": "Hello! I am your AI assistant", + "enterAQuestionBelowToStartAConversation": "Enter a question below to start a conversation…", + "copy": "Copy", + "duration": "Duration", + "input": "Input", + "output": "Output", + "total": "Total", + "reasoning": "Reasoning", + "enterYourQuestionEnterToSendShiftEnterForA": "Enter your question… (Enter to send, Shift + Enter for a new line)", + "uploadImages": "Upload images", + "deepReasoning": "Deep reasoning", + "globalUserSettings": "Global user settings", + "defaultTemperature": "Default temperature", + "includeConversationHistory": "Include conversation history", + "historyRounds": "History rounds", + "showMetricsByDefault": "Show metrics by default", + "enableVision": "Enable vision", + "maximumImageSize": "Maximum image size", + "imageSize": "Image size", + "systemPrompt": "System prompt", + "setTheGlobalSystemPrompt": "Set the global system prompt", + "cancel": "Cancel", + "save": "Save", + "modelCodeIsRequired": "Model code is required", + "providerIsRequired": "Provider is required", + "modelSortOrderIsRequired": "Model sort order is required", + "addModel": "Add model", + "editModel": "Edit model", + "modelCode": "Model code", + "enterAModelCode": "Enter a model code", + "provider": "Provider", + "chooseAProvider": "Choose a provider", + "status": "Status", + "modelStatus": "Model status", + "search": "Search", + "reset": "Reset", + "add": "Add", + "edit": "Edit", + "delete": "Delete", + "supportsReasoning": "Supports reasoning", + "supportsImages": "Supports images", + "createdAt": "Created at", + "actions": "Actions", + "modelName": "Model name", + "enterAModelName": "Enter a model name", + "modelSortOrder": "Model sort order", + "enterAnAPIKey": "Enter an API Key", + "enterABaseURL": "Enter a Base URL", + "maximumOutput": "Maximum output", + "modelType": "Model type", + "enterAModelTypeOptional": "Enter a model type (optional)", + "remark": "Remark", + "enterContent": "Enter content", + "me": "Me", + "stop": "Stop", + "send": "Send", + "confirm": "Confirm", + "modelID": "Model ID", + "enterModelCodeEGDeepseekR1": "Enter model code (e.g. deepseek-r1)", + "requestFailed": "Request failed: {{message}}", + "emptyContent": "There is no content to copy", + "imageTooLarge": "Each image must not exceed {{size}} MB", + "uploadingImages": "Uploading images, please wait...", + "imageUploadFailed": "Image upload failed", + "updated": "Updated successfully", + "added": "Added successfully", + "deleteModels": "Delete models with IDs “{{ids}}”?" +} diff --git a/ruoyi-fastapi-frontend/vue3/web/plugins/ai/locales/zh-CN.json b/ruoyi-fastapi-frontend/vue3/web/plugins/ai/locales/zh-CN.json new file mode 100644 index 000000000..51001f225 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue3/web/plugins/ai/locales/zh-CN.json @@ -0,0 +1,83 @@ +{ + "reasoningProcess": "深度思考过程", + "thinking": "思考中...", + "settingsSaved": "配置保存成功", + "deleteThisConversation": "是否确认删除该会话?", + "deletedSuccessfully": "删除成功", + "chooseAModelFirst": "请先选择模型", + "copied": "复制成功", + "copyFailed": "复制失败", + "youCanUploadUpTo10Images": "最多只能上传 10 张图片", + "newConversation": "新对话", + "noConversationHistory": "暂无历史对话", + "aIAssistant": "AI 助手", + "globalSettings": "全局参数配置", + "chooseAModel": "选择模型", + "helloIAmYourAIAssistant": "你好!我是你的 AI 助手", + "enterAQuestionBelowToStartAConversation": "请在下方输入问题开始对话...", + "copy": "复制", + "duration": "耗时", + "input": "输入", + "output": "输出", + "total": "总", + "reasoning": "推理", + "enterYourQuestionEnterToSendShiftEnterForA": "请输入您的问题... (Enter 发送,Shift + Enter 换行)", + "uploadImages": "上传图片", + "deepReasoning": "深度思考", + "globalUserSettings": "用户全局配置", + "defaultTemperature": "默认温度", + "includeConversationHistory": "附带历史消息", + "historyRounds": "历史消息轮数", + "showMetricsByDefault": "默认显示指标", + "enableVision": "开启视觉功能", + "maximumImageSize": "图片最大大小", + "imageSize": "图片大小", + "systemPrompt": "系统提示词", + "setTheGlobalSystemPrompt": "设置全局系统提示词", + "cancel": "取 消", + "save": "保存", + "modelCodeIsRequired": "模型编码不能为空", + "providerIsRequired": "提供商不能为空", + "modelSortOrderIsRequired": "模型排序不能为空", + "addModel": "添加模型", + "editModel": "修改模型", + "modelCode": "模型编码", + "enterAModelCode": "请输入模型编码", + "provider": "提供商", + "chooseAProvider": "请选择提供商", + "status": "状态", + "modelStatus": "模型状态", + "search": "搜索", + "reset": "重置", + "add": "新增", + "edit": "修改", + "delete": "删除", + "supportsReasoning": "支持推理", + "supportsImages": "支持图片", + "createdAt": "创建时间", + "actions": "操作", + "modelName": "模型名称", + "enterAModelName": "请输入模型名称", + "modelSortOrder": "模型排序", + "enterAnAPIKey": "请输入API Key", + "enterABaseURL": "请输入Base URL", + "maximumOutput": "最大输出", + "modelType": "模型类型", + "enterAModelTypeOptional": "请输入模型类型 (可选)", + "remark": "备注", + "enterContent": "请输入内容", + "me": "我", + "stop": "停止", + "send": "发送", + "confirm": "确 定", + "modelID": "模型ID", + "enterModelCodeEGDeepseekR1": "请输入模型编码 (如 deepseek-r1)", + "requestFailed": "请求失败:{{message}}", + "emptyContent": "内容为空,无法复制", + "imageTooLarge": "单张图片大小不能超过 {{size}} MB", + "uploadingImages": "正在上传图片,请稍候...", + "imageUploadFailed": "上传图片失败", + "updated": "修改成功", + "added": "新增成功", + "deleteModels": "是否确认删除模型编号为“{{ids}}”的数据项?" +} diff --git a/ruoyi-fastapi-frontend/vue3/web/plugins/ai/views/chat/components/AiMessage.vue b/ruoyi-fastapi-frontend/vue3/web/plugins/ai/views/chat/components/AiMessage.vue index adf8b7bb8..12ea9d3b3 100644 --- a/ruoyi-fastapi-frontend/vue3/web/plugins/ai/views/chat/components/AiMessage.vue +++ b/ruoyi-fastapi-frontend/vue3/web/plugins/ai/views/chat/components/AiMessage.vue @@ -9,11 +9,11 @@ @click="toggleReasoning" > - 深度思考过程 + {{ t('plugin.ai:reasoningProcess') }} 思考中...{{ t('plugin.ai:thinking') }}
+ + diff --git a/ruoyi-fastapi-frontend/vue3/web/src/components/FileUpload/index.vue b/ruoyi-fastapi-frontend/vue3/web/src/components/FileUpload/index.vue index 8e4cd5ada..b4df0c423 100644 --- a/ruoyi-fastapi-frontend/vue3/web/src/components/FileUpload/index.vue +++ b/ruoyi-fastapi-frontend/vue3/web/src/components/FileUpload/index.vue @@ -17,21 +17,17 @@ v-if="!disabled" > - 选取文件 + {{ $t('components:chooseFiles') }}
- 请上传 - - - 的文件 + {{ $t('components:uploadHint.size', { size: fileSize }) }} + {{ + $t('components:uploadHint.formats', { formats: fileType.join('/') }) + }}
删除{{ $t('system:delete') }}
@@ -68,7 +64,8 @@ diff --git a/ruoyi-fastapi-frontend/vue3/web/src/components/LocaleNameInput/index.vue b/ruoyi-fastapi-frontend/vue3/web/src/components/LocaleNameInput/index.vue new file mode 100644 index 000000000..e8f1f3866 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue3/web/src/components/LocaleNameInput/index.vue @@ -0,0 +1,86 @@ + + + + + diff --git a/ruoyi-fastapi-frontend/vue3/web/src/components/LocalizedMessage/index.vue b/ruoyi-fastapi-frontend/vue3/web/src/components/LocalizedMessage/index.vue new file mode 100644 index 000000000..4465ddc14 --- /dev/null +++ b/ruoyi-fastapi-frontend/vue3/web/src/components/LocalizedMessage/index.vue @@ -0,0 +1,31 @@ + + + diff --git a/ruoyi-fastapi-frontend/vue3/web/src/components/OAuthWorkspace/AccessMap.vue b/ruoyi-fastapi-frontend/vue3/web/src/components/OAuthWorkspace/AccessMap.vue index d16b045dd..03be6a0e7 100644 --- a/ruoyi-fastapi-frontend/vue3/web/src/components/OAuthWorkspace/AccessMap.vue +++ b/ruoyi-fastapi-frontend/vue3/web/src/components/OAuthWorkspace/AccessMap.vue @@ -1,19 +1,19 @@ diff --git a/ruoyi-fastapi-frontend/vue3/web/src/components/OAuthWorkspace/FieldLabel.vue b/ruoyi-fastapi-frontend/vue3/web/src/components/OAuthWorkspace/FieldLabel.vue index 85bfa24f5..8e43406bc 100644 --- a/ruoyi-fastapi-frontend/vue3/web/src/components/OAuthWorkspace/FieldLabel.vue +++ b/ruoyi-fastapi-frontend/vue3/web/src/components/OAuthWorkspace/FieldLabel.vue @@ -9,7 +9,7 @@ diff --git a/ruoyi-fastapi-frontend/vue3/web/src/components/OAuthWorkspace/PageFrame.vue b/ruoyi-fastapi-frontend/vue3/web/src/components/OAuthWorkspace/PageFrame.vue index 1612dde9b..60f3d070f 100644 --- a/ruoyi-fastapi-frontend/vue3/web/src/components/OAuthWorkspace/PageFrame.vue +++ b/ruoyi-fastapi-frontend/vue3/web/src/components/OAuthWorkspace/PageFrame.vue @@ -17,7 +17,7 @@
@@ -25,11 +25,11 @@
- 筛选条件 + {{ $t('components:filters') }} - diff --git a/ruoyi-fastapi-frontend/vue3/web/src/views/monitor/cache/index.vue b/ruoyi-fastapi-frontend/vue3/web/src/views/monitor/cache/index.vue index bc4e40cf6..f5c503b1c 100644 --- a/ruoyi-fastapi-frontend/vue3/web/src/views/monitor/cache/index.vue +++ b/ruoyi-fastapi-frontend/vue3/web/src/views/monitor/cache/index.vue @@ -8,7 +8,9 @@ {{ + $t('system:basicInformation') + }}
- + - + - + - + - + - + - + - + - + - + - + - +
Redis版本
+
{{ $t('monitor:redisVersion') }}
+
运行模式
+
{{ $t('monitor:runMode') }}
+
- {{ cache.info.redis_mode == 'standalone' ? '单机' : '集群' }} + {{ + cache.info.redis_mode == 'standalone' + ? $t('monitor:standalone') + : $t('monitor:cluster') + }}
端口
+
{{ $t('monitor:port') }}
+
客户端数
+
{{ $t('monitor:clients') }}
+
运行时间(天)
+
{{ $t('monitor:uptimeDays') }}
+
使用内存
+
{{ $t('monitor:usedMemory') }}
+
使用CPU
+
{{ $t('monitor:cPUUsage') }}
+
内存配置
+
{{ $t('monitor:memoryConfiguration') }}
+
AOF是否开启
+
{{ $t('monitor:aOFEnabled') }}
+
- {{ cache.info.aof_enabled == '0' ? '否' : '是' }} + {{ cache.info.aof_enabled == '0' ? $t('system:no') : $t('system:yes') }}
RDB是否成功
+
{{ $t('monitor:rDBSuccessful') }}
+
Key数量
+
{{ $t('monitor:keyCount') }}
+
网络入口/出口
+
{{ $t('monitor:networkInOut') }}
+
{{ + $t('monitor:commandStatistics') + }}
{{ + $t('monitor:memoryInformation') + }}
diff --git a/ruoyi-fastapi-frontend/vue3/web/src/views/monitor/cache/list.vue b/ruoyi-fastapi-frontend/vue3/web/src/views/monitor/cache/list.vue index f27039cbc..4848f4cb5 100644 --- a/ruoyi-fastapi-frontend/vue3/web/src/views/monitor/cache/list.vue +++ b/ruoyi-fastapi-frontend/vue3/web/src/views/monitor/cache/list.vue @@ -5,7 +5,7 @@ @@ -250,7 +250,7 @@ icon="View" @click="handleDetail(scope.row, scope.index)" v-hasPermi="['monitor:operlog:query']" - >详细{{ $t('monitor:details') }} @@ -272,6 +272,7 @@