diff --git a/src/Jiaowu.Api/Infrastructure/Localization/AppCultures.cs b/src/Jiaowu.Api/Infrastructure/Localization/AppCultures.cs new file mode 100644 index 0000000..6044fcb --- /dev/null +++ b/src/Jiaowu.Api/Infrastructure/Localization/AppCultures.cs @@ -0,0 +1,29 @@ +using System.Globalization; + +namespace Jiaowu.Api.Infrastructure.Localization; + +public static class AppCultures +{ + public const string Default = "zh-CN"; + public const string English = "en-US"; + + public static IReadOnlyList Supported { get; } = + [ + CultureInfo.GetCultureInfo(Default), + CultureInfo.GetCultureInfo(English) + ]; + + public static string Normalize(string? value) + { + if (string.IsNullOrWhiteSpace(value)) return Default; + var normalized = value.Replace('_', '-').Trim(); + if (normalized.Equals("zh", StringComparison.OrdinalIgnoreCase) || + normalized.StartsWith("zh-CN", StringComparison.OrdinalIgnoreCase) || + normalized.StartsWith("zh-Hans", StringComparison.OrdinalIgnoreCase)) + return Default; + if (normalized.Equals("en", StringComparison.OrdinalIgnoreCase) || + normalized.StartsWith("en-", StringComparison.OrdinalIgnoreCase)) + return English; + return Default; + } +} diff --git a/src/Jiaowu.Api/Infrastructure/Localization/SharedResource.cs b/src/Jiaowu.Api/Infrastructure/Localization/SharedResource.cs new file mode 100644 index 0000000..84c20c0 --- /dev/null +++ b/src/Jiaowu.Api/Infrastructure/Localization/SharedResource.cs @@ -0,0 +1,6 @@ +namespace Jiaowu.Api.Infrastructure.Localization; + +/// +/// Marker type for application-wide localized server messages. +/// +public sealed class SharedResource; diff --git a/src/Jiaowu.Api/Program.cs b/src/Jiaowu.Api/Program.cs index 4390a1e..090f505 100644 --- a/src/Jiaowu.Api/Program.cs +++ b/src/Jiaowu.Api/Program.cs @@ -1,4 +1,5 @@ using System.Text; +using System.Globalization; using System.Net; using System.Net.Mail; using System.Security.Claims; @@ -17,6 +18,7 @@ using Jiaowu.Api.Infrastructure.Caching; using Jiaowu.Api.Infrastructure.Exams; using Jiaowu.Api.Infrastructure.Facilities; using Jiaowu.Api.Infrastructure.Middleware; +using Jiaowu.Api.Infrastructure.Localization; using Jiaowu.Api.Infrastructure.Observability; using Jiaowu.Api.Infrastructure.Notifications; using Jiaowu.Api.Infrastructure.OfficialDocuments; @@ -36,11 +38,13 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.RateLimiting; +using Microsoft.AspNetCore.Localization; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Distributed; using Microsoft.IdentityModel.Tokens; using Microsoft.OpenApi; +using Microsoft.Extensions.Localization; using Swashbuckle.AspNetCore.SwaggerUI; using System.Threading.RateLimiting; @@ -77,6 +81,17 @@ if (confirmProductionDemoData && !seedDemoData) } var builder = WebApplication.CreateBuilder(args); +builder.Services.AddLocalization(options => options.ResourcesPath = "Resources"); +builder.Services.Configure(options => +{ + options.DefaultRequestCulture = new RequestCulture(AppCultures.Default); + options.SupportedCultures = [.. AppCultures.Supported]; + options.SupportedUICultures = [.. AppCultures.Supported]; + options.RequestCultureProviders = + [ + new AcceptLanguageHeaderRequestCultureProvider() + ]; +}); var swaggerDocumentVersion = typeof(Program).Assembly .GetCustomAttributes( typeof(System.Reflection.AssemblyMetadataAttribute), @@ -768,7 +783,15 @@ builder.Services.AddCors(options => }); builder.Services.AddResponseCompression(options => options.EnableForHttps = true); -builder.Services.AddProblemDetails(); +builder.Services.AddProblemDetails(options => +{ + options.CustomizeProblemDetails = problemContext => + { + var problem = problemContext.ProblemDetails; + problem.Extensions.TryAdd("code", $"http.{problem.Status ?? 500}"); + problem.Extensions.TryAdd("traceId", problemContext.HttpContext.TraceIdentifier); + }; +}); builder.Services.AddExceptionHandler(options => { options.ExceptionHandler = async context => @@ -779,15 +802,26 @@ builder.Services.AddExceptionHandler(options => var statusCode = isConstraintConflict ? StatusCodes.Status409Conflict : StatusCodes.Status500InternalServerError; + var localizer = context.RequestServices.GetRequiredService>(); + var code = isConstraintConflict + ? "data.constraint_conflict" + : "server.unhandled_error"; context.Response.StatusCode = statusCode; await Results.Problem( - title: isConstraintConflict ? "数据约束冲突" : "服务器处理请求时发生错误", + title: localizer[isConstraintConflict + ? "Errors.ConstraintConflict.Title" + : "Errors.Unhandled.Title"], detail: isConstraintConflict - ? "编码可能已存在,或该数据正在被其他业务引用。" + ? localizer["Errors.ConstraintConflict.Detail"] : builder.Environment.IsDevelopment() ? exception?.Message - : "请稍后重试,并联系系统管理员查看日志。", - statusCode: statusCode) + : localizer["Errors.Unhandled.Detail"], + statusCode: statusCode, + extensions: new Dictionary + { + ["code"] = code, + ["traceId"] = context.TraceIdentifier + }) .ExecuteAsync(context); }; }); @@ -802,6 +836,7 @@ builder.Services.AddHostedService(); builder.Services.AddHostedService(); var mvcBuilder = builder.Services.AddControllers() + .AddDataAnnotationsLocalization() .AddJsonOptions(options => options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter())); pluginStartup.AddApplicationParts(mvcBuilder); @@ -832,6 +867,20 @@ builder.Services.AddSwaggerGen(options => var app = builder.Build(); app.UseForwardedHeaders(); +app.UseRequestLocalization(); +app.Use(async (context, next) => +{ + if (context.Request.Path.StartsWithSegments("/api")) + { + context.Response.OnStarting(() => + { + context.Response.Headers.ContentLanguage = CultureInfo.CurrentUICulture.Name; + return Task.CompletedTask; + }); + } + + await next(); +}); app.UseExceptionHandler(); app.UseResponseCompression(); app.Use(async (context, next) => diff --git a/src/Jiaowu.Api/Resources/Infrastructure/Localization/SharedResource.en-US.resx b/src/Jiaowu.Api/Resources/Infrastructure/Localization/SharedResource.en-US.resx new file mode 100644 index 0000000..0f84696 --- /dev/null +++ b/src/Jiaowu.Api/Resources/Infrastructure/Localization/SharedResource.en-US.resx @@ -0,0 +1,11 @@ + + + text/microsoft-resx + 2.0 + System.Resources.ResXResourceReader, System.Windows.Forms + System.Resources.ResXResourceWriter, System.Windows.Forms + Data constraint conflict + The code may already exist, or other business data may reference this record. + The server encountered an error + Try again later and contact the system administrator if the problem continues. + diff --git a/src/Jiaowu.Api/Resources/Infrastructure/Localization/SharedResource.resx b/src/Jiaowu.Api/Resources/Infrastructure/Localization/SharedResource.resx new file mode 100644 index 0000000..caa1c76 --- /dev/null +++ b/src/Jiaowu.Api/Resources/Infrastructure/Localization/SharedResource.resx @@ -0,0 +1,11 @@ + + + text/microsoft-resx + 2.0 + System.Resources.ResXResourceReader, System.Windows.Forms + System.Resources.ResXResourceWriter, System.Windows.Forms + 数据约束冲突 + 编码可能已存在,或该数据正在被其他业务引用。 + 服务器处理请求时发生错误 + 请稍后重试,并联系系统管理员查看日志。 + diff --git a/tests/Jiaowu.Api.Tests/AppCulturesTests.cs b/tests/Jiaowu.Api.Tests/AppCulturesTests.cs new file mode 100644 index 0000000..62ce861 --- /dev/null +++ b/tests/Jiaowu.Api.Tests/AppCulturesTests.cs @@ -0,0 +1,34 @@ +using Jiaowu.Api.Infrastructure.Localization; +using System.Globalization; +using System.Resources; + +namespace Jiaowu.Api.Tests; + +public sealed class AppCulturesTests +{ + [Theory] + [InlineData(null, "zh-CN")] + [InlineData("zh", "zh-CN")] + [InlineData("zh-Hans-CN", "zh-CN")] + [InlineData("en", "en-US")] + [InlineData("en-GB", "en-US")] + [InlineData("fr-FR", "zh-CN")] + public void Normalize_MapsSupportedLanguageFamilies(string? value, string expected) + { + Assert.Equal(expected, AppCultures.Normalize(value)); + } + + [Fact] + public void SharedResource_ContainsEnglishServerErrors() + { + var resources = new ResourceManager( + "Jiaowu.Api.Resources.Infrastructure.Localization.SharedResource", + typeof(SharedResource).Assembly); + + var title = resources.GetString( + "Errors.Unhandled.Title", + CultureInfo.GetCultureInfo(AppCultures.English)); + + Assert.Equal("The server encountered an error", title); + } +} diff --git a/web/package-lock.json b/web/package-lock.json index 341ddc0..b4bac73 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -26,6 +26,7 @@ "pinia": "^4.1.0", "qrcode": "1.5.4", "vue": "^3.5.44", + "vue-i18n": "^11.4.16", "vue-router": "^5.4.0" }, "devDependencies": { @@ -2684,6 +2685,67 @@ "integrity": "sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww==", "license": "MIT" }, + "node_modules/@intlify/core-base": { + "version": "11.4.16", + "resolved": "https://registry.npmjs.org/@intlify/core-base/-/core-base-11.4.16.tgz", + "integrity": "sha512-xB8nMdMRLNx7b0zPvrHy0+N9uq9Vfi1aUxHqWgn2e2/TbjCKy8HfoFpnUXXxVP8I0p1ccd6LFSC3XsFjZ3vweA==", + "license": "MIT", + "dependencies": { + "@intlify/devtools-types": "11.4.16", + "@intlify/message-compiler": "11.4.16", + "@intlify/shared": "11.4.16" + }, + "engines": { + "node": ">= 22" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, + "node_modules/@intlify/devtools-types": { + "version": "11.4.16", + "resolved": "https://registry.npmjs.org/@intlify/devtools-types/-/devtools-types-11.4.16.tgz", + "integrity": "sha512-Bl7arICsKgwcSEQuZJun3swenN4jwSpg35lCpijFznYbW9GvkfH4wLxcI5+gz7d/EHqu66UT9CZDIdnQdgMAGg==", + "license": "MIT", + "dependencies": { + "@intlify/core-base": "11.4.16", + "@intlify/shared": "11.4.16" + }, + "engines": { + "node": ">= 22" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, + "node_modules/@intlify/message-compiler": { + "version": "11.4.16", + "resolved": "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-11.4.16.tgz", + "integrity": "sha512-p4lDWmBAsi3ja+PuEfPRavYyvqkYn/Upxz7UpnyI9LgIIy8XawcGIDzN+k99Z+99etO3HmDXGeTxnJIJGgSZ+g==", + "license": "MIT", + "dependencies": { + "@intlify/shared": "11.4.16", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": ">= 22" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, + "node_modules/@intlify/shared": { + "version": "11.4.16", + "resolved": "https://registry.npmjs.org/@intlify/shared/-/shared-11.4.16.tgz", + "integrity": "sha512-xehmkbEgbbNh/V+d8r3hFup0ViaN29YTJSAfRr28C54rxjyZEO0RNQKqW7VVajj16gLdglotNjiq+sIVNtHGzw==", + "license": "MIT", + "engines": { + "node": ">= 22" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + } + }, "node_modules/@ionic/cli-framework-output": { "version": "2.2.8", "resolved": "https://registry.npmjs.org/@ionic/cli-framework-output/-/cli-framework-output-2.2.8.tgz", @@ -11352,6 +11414,33 @@ "integrity": "sha512-LwcxzeliO9fkQcpJG0PoX8X5kmAhKmH9wkpDLxNabwzkQ9Zeib2YVHwFV4pcWmMLfXVfjr/dSV+DaJ3cIPgSNA==", "license": "MIT" }, + "node_modules/vue-i18n": { + "version": "11.4.16", + "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-11.4.16.tgz", + "integrity": "sha512-Kv9tp6iTmaAeOwop7hkAo28N1IBsbSVpnxyE26b6gqc4Q2E9Ke3ZHHA3oqqwS6/cYLT1henZU4etTaLQxrK98Q==", + "license": "MIT", + "dependencies": { + "@intlify/core-base": "11.4.16", + "@intlify/devtools-types": "11.4.16", + "@intlify/shared": "11.4.16", + "@vue/devtools-api": "^6.5.0" + }, + "engines": { + "node": ">= 22" + }, + "funding": { + "url": "https://github.com/sponsors/kazupon" + }, + "peerDependencies": { + "vue": "^3.0.0" + } + }, + "node_modules/vue-i18n/node_modules/@vue/devtools-api": { + "version": "6.6.4", + "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.6.4.tgz", + "integrity": "sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==", + "license": "MIT" + }, "node_modules/vue-router": { "version": "5.4.0", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-5.4.0.tgz", diff --git a/web/package.json b/web/package.json index 6aa27bd..effcf60 100644 --- a/web/package.json +++ b/web/package.json @@ -5,6 +5,7 @@ "scripts": { "dev": "vite", "build": "vue-tsc -b && vite build", + "i18n:check": "node --experimental-strip-types scripts/check-i18n.mjs", "build:capacitor": "vue-tsc -b && vite build --mode capacitor", "ota:package": "npm run build:capacitor && node scripts/package-app-update.mjs", "preview": "vite preview", @@ -38,6 +39,7 @@ "pinia": "^4.1.0", "qrcode": "1.5.4", "vue": "^3.5.44", + "vue-i18n": "^11.4.16", "vue-router": "^5.4.0" }, "devDependencies": { diff --git a/web/scripts/check-i18n.mjs b/web/scripts/check-i18n.mjs new file mode 100644 index 0000000..155ab5b --- /dev/null +++ b/web/scripts/check-i18n.mjs @@ -0,0 +1,22 @@ +import enUS from '../src/i18n/messages/en-US.ts' +import zhCN from '../src/i18n/messages/zh-CN.ts' + +function flatten(value, prefix = '') { + return Object.entries(value).flatMap(([key, child]) => { + const path = prefix ? `${prefix}.${key}` : key + return child && typeof child === 'object' ? flatten(child, path) : [path] + }) +} + +const reference = new Set(flatten(zhCN)) +const candidate = new Set(flatten(enUS)) +const missing = [...reference].filter((key) => !candidate.has(key)) +const extra = [...candidate].filter((key) => !reference.has(key)) + +if (missing.length || extra.length) { + if (missing.length) console.error(`en-US missing keys:\n${missing.join('\n')}`) + if (extra.length) console.error(`en-US extra keys:\n${extra.join('\n')}`) + process.exitCode = 1 +} else { + console.log(`i18n catalogs match (${reference.size} keys).`) +} diff --git a/web/src/App.vue b/web/src/App.vue index 18f6876..e80ffaf 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -1,14 +1,20 @@ diff --git a/web/src/api/http.ts b/web/src/api/http.ts index e2d7862..938cab1 100644 --- a/web/src/api/http.ts +++ b/web/src/api/http.ts @@ -1,5 +1,6 @@ import axios from 'axios' import { goLogin } from '../utils/navigate' +import { currentLocale, hasTranslation, translate } from '../i18n' import { authStorageKeys, clearAuthSession, @@ -29,6 +30,7 @@ function isAuthenticationRequest(url?: string) { } http.interceptors.request.use(async (config) => { + config.headers['Accept-Language'] = currentLocale.value if (!isAuthenticationRequest(config.url) && !config.skipAuthSession) { const activeToken = await refreshIfNeeded(true) if (activeToken) markActivity() @@ -62,9 +64,15 @@ http.interceptors.response.use( ) export function apiErrorMessage(error: unknown) { - if (!axios.isAxiosError(error)) return '操作失败,请稍后重试。' + if (!axios.isAxiosError(error)) return translate('errors.generic') const status = error.response?.status const data = error.response?.data + const code = typeof data?.code === 'string' ? data.code.trim() : '' + const codeKey = code ? `api.${code}` : '' + if (codeKey && hasTranslation(codeKey)) { + const args = data?.args && typeof data.args === 'object' ? data.args : undefined + return translate(codeKey, args) + } const message = typeof data?.message === 'string' ? data.message.trim() : '' if (message) return message if (data?.errors && typeof data.errors === 'object') { @@ -79,11 +87,11 @@ export function apiErrorMessage(error: unknown) { if (detail) return detail const title = typeof data?.title === 'string' ? data.title.trim() : '' if (title) return title - if (status === 403) return '您没有权限执行此操作,请联系管理员。' - if (status === 404) return '请求的资源不存在。' - if (status === 401) return '登录已过期,请重新登录。' - if (status && status >= 500) return '服务器繁忙,请稍后重试。' - return '操作失败,请检查网络连接。' + if (status === 403) return translate('errors.forbidden') + if (status === 404) return translate('errors.notFound') + if (status === 401) return translate('errors.unauthorized') + if (status && status >= 500) return translate('errors.server') + return translate('errors.network') } export default http diff --git a/web/src/components.d.ts b/web/src/components.d.ts index dadac06..1757aa8 100644 --- a/web/src/components.d.ts +++ b/web/src/components.d.ts @@ -24,6 +24,7 @@ declare module 'vue' { ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup'] ElCollapse: typeof import('element-plus/es')['ElCollapse'] ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem'] + ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider'] ElDatePicker: typeof import('element-plus/es')['ElDatePicker'] ElDescriptions: typeof import('element-plus/es')['ElDescriptions'] ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem'] diff --git a/web/src/i18n/format.ts b/web/src/i18n/format.ts new file mode 100644 index 0000000..f5fad95 --- /dev/null +++ b/web/src/i18n/format.ts @@ -0,0 +1,43 @@ +import { currentLocale } from './index' + +type DateInput = Date | string | number + +function dateValue(value: DateInput) { + return value instanceof Date ? value : new Date(value) +} + +export function formatDate(value: DateInput, options?: Intl.DateTimeFormatOptions) { + return new Intl.DateTimeFormat(currentLocale.value, options ?? { dateStyle: 'medium' }) + .format(dateValue(value)) +} + +export function formatDateTime(value: DateInput, options?: Intl.DateTimeFormatOptions) { + return new Intl.DateTimeFormat( + currentLocale.value, + options ?? { dateStyle: 'medium', timeStyle: 'short' }, + ).format(dateValue(value)) +} + +export function formatNumber(value: number, options?: Intl.NumberFormatOptions) { + return new Intl.NumberFormat(currentLocale.value, options).format(value) +} + +export function formatPercent(value: number, options?: Intl.NumberFormatOptions) { + return new Intl.NumberFormat(currentLocale.value, { + style: 'percent', + maximumFractionDigits: 2, + ...options, + }).format(value) +} + +export function formatCurrency( + value: number, + currency = 'CNY', + options?: Intl.NumberFormatOptions, +) { + return new Intl.NumberFormat(currentLocale.value, { + style: 'currency', + currency, + ...options, + }).format(value) +} diff --git a/web/src/i18n/index.ts b/web/src/i18n/index.ts new file mode 100644 index 0000000..f83f363 --- /dev/null +++ b/web/src/i18n/index.ts @@ -0,0 +1,61 @@ +import { ref } from 'vue' +import { createI18n } from 'vue-i18n' +import enUS from './messages/en-US' +import zhCN from './messages/zh-CN' + +export const supportedLocales = ['zh-CN', 'en-US'] as const +export type AppLocale = (typeof supportedLocales)[number] + +const localeStorageKey = 'mingxu.locale' + +function normalizeLocale(value?: string | null): AppLocale | undefined { + if (!value) return undefined + const normalized = value.replace('_', '-').toLowerCase() + if (normalized === 'zh' || normalized.startsWith('zh-cn') || normalized.startsWith('zh-hans')) { + return 'zh-CN' + } + if (normalized === 'en' || normalized.startsWith('en-')) return 'en-US' + return undefined +} + +function detectLocale(): AppLocale { + const stored = normalizeLocale(localStorage.getItem(localeStorageKey)) + if (stored) return stored + for (const language of navigator.languages ?? [navigator.language]) { + const detected = normalizeLocale(language) + if (detected) return detected + } + return 'zh-CN' +} + +export const currentLocale = ref(detectLocale()) + +export const i18n = createI18n({ + legacy: false, + locale: currentLocale.value, + fallbackLocale: 'zh-CN', + missingWarn: import.meta.env.DEV, + fallbackWarn: import.meta.env.DEV, + messages: { + 'zh-CN': zhCN, + 'en-US': enUS, + }, +}) + +export function setLocale(locale: AppLocale) { + currentLocale.value = locale + i18n.global.locale.value = locale + localStorage.setItem(localeStorageKey, locale) + document.documentElement.lang = locale + window.dispatchEvent(new CustomEvent('mingxu-locale-changed', { detail: locale })) +} + +export function translate(key: string, args?: Record) { + return args ? i18n.global.t(key, args) : i18n.global.t(key) +} + +export function hasTranslation(key: string) { + return i18n.global.te(key, currentLocale.value) +} + +document.documentElement.lang = currentLocale.value diff --git a/web/src/i18n/messages/en-US.ts b/web/src/i18n/messages/en-US.ts new file mode 100644 index 0000000..8f604db --- /dev/null +++ b/web/src/i18n/messages/en-US.ts @@ -0,0 +1,32 @@ +export default { + locale: { + label: 'Language', + zhCN: '简体中文', + enUS: 'English', + }, + shell: { + notifications: 'Notifications', + manageFavorites: 'Manage favorites', + account: 'Account', + signOut: 'Sign out', + signOutFull: 'Sign out', + currentWorkspace: 'Current workspace', + currentUser: 'Current user', + favoritesHint: 'Choose and reorder frequently used features', + openNavigation: 'Open navigation menu', + closeNavigation: 'Close navigation menu', + mainNavigation: 'Main navigation', + }, + errors: { + generic: 'The operation failed. Please try again later.', + forbidden: 'You do not have permission to perform this action. Contact an administrator.', + notFound: 'The requested resource was not found.', + unauthorized: 'Your session has expired. Please sign in again.', + server: 'The server is busy. Please try again later.', + network: 'The operation failed. Check your network connection.', + }, + api: { + 'data.constraint_conflict': 'A data constraint conflict occurred.', + 'server.unhandled_error': 'The server encountered an error while processing the request.', + }, +} diff --git a/web/src/i18n/messages/zh-CN.ts b/web/src/i18n/messages/zh-CN.ts new file mode 100644 index 0000000..9c69672 --- /dev/null +++ b/web/src/i18n/messages/zh-CN.ts @@ -0,0 +1,32 @@ +export default { + locale: { + label: '语言', + zhCN: '简体中文', + enUS: 'English', + }, + shell: { + notifications: '消息中心', + manageFavorites: '管理常用', + account: '个人账户', + signOut: '退出', + signOutFull: '退出登录', + currentWorkspace: '当前工作区', + currentUser: '当前用户', + favoritesHint: '收藏与调整常用功能顺序', + openNavigation: '打开导航菜单', + closeNavigation: '关闭导航菜单', + mainNavigation: '主导航', + }, + errors: { + generic: '操作失败,请稍后重试。', + forbidden: '您没有权限执行此操作,请联系管理员。', + notFound: '请求的资源不存在。', + unauthorized: '登录已过期,请重新登录。', + server: '服务器繁忙,请稍后重试。', + network: '操作失败,请检查网络连接。', + }, + api: { + 'data.constraint_conflict': '数据约束冲突。', + 'server.unhandled_error': '服务器处理请求时发生错误。', + }, +} diff --git a/web/src/layouts/AdminLayout.vue b/web/src/layouts/AdminLayout.vue index 395c875..3b12436 100644 --- a/web/src/layouts/AdminLayout.vue +++ b/web/src/layouts/AdminLayout.vue @@ -1,5 +1,6 @@