物业代码生成
This commit is contained in:
3
apps/web-antd/src/locales/README.md
Normal file
3
apps/web-antd/src/locales/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# locale
|
||||
|
||||
每个app使用的国际化可能不同,这里用于扩展国际化的功能,例如扩展 dayjs、antd组件库的多语言切换,以及app本身的国际化文件。
|
103
apps/web-antd/src/locales/index.ts
Normal file
103
apps/web-antd/src/locales/index.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
import type { Locale } from 'ant-design-vue/es/locale';
|
||||
|
||||
import type { App } from 'vue';
|
||||
|
||||
import type { LocaleSetupOptions, SupportedLanguagesType } from '@vben/locales';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import {
|
||||
$t,
|
||||
setupI18n as coreSetup,
|
||||
loadLocalesMapFromDir,
|
||||
} from '@vben/locales';
|
||||
import { preferences } from '@vben/preferences';
|
||||
|
||||
import antdEnLocale from 'ant-design-vue/es/locale/en_US';
|
||||
import antdDefaultLocale from 'ant-design-vue/es/locale/zh_CN';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const antdLocale = ref<Locale>(antdDefaultLocale);
|
||||
|
||||
const modules = import.meta.glob('./langs/**/*.json');
|
||||
|
||||
const localesMap = loadLocalesMapFromDir(
|
||||
/\.\/langs\/([^/]+)\/(.*)\.json$/,
|
||||
modules,
|
||||
);
|
||||
/**
|
||||
* 加载应用特有的语言包
|
||||
* 这里也可以改造为从服务端获取翻译数据
|
||||
* @param lang
|
||||
*/
|
||||
async function loadMessages(lang: SupportedLanguagesType) {
|
||||
const [appLocaleMessages] = await Promise.all([
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
localesMap[lang]!(),
|
||||
loadThirdPartyMessage(lang),
|
||||
]);
|
||||
return appLocaleMessages.default;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载第三方组件库的语言包
|
||||
* @param lang
|
||||
*/
|
||||
async function loadThirdPartyMessage(lang: SupportedLanguagesType) {
|
||||
await Promise.all([loadAntdLocale(lang), loadDayjsLocale(lang)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载dayjs的语言包
|
||||
* @param lang
|
||||
*/
|
||||
async function loadDayjsLocale(lang: SupportedLanguagesType) {
|
||||
let locale;
|
||||
switch (lang) {
|
||||
case 'en-US': {
|
||||
locale = await import('dayjs/locale/en');
|
||||
break;
|
||||
}
|
||||
case 'zh-CN': {
|
||||
locale = await import('dayjs/locale/zh-cn');
|
||||
break;
|
||||
}
|
||||
// 默认使用英语
|
||||
default: {
|
||||
locale = await import('dayjs/locale/en');
|
||||
}
|
||||
}
|
||||
if (locale) {
|
||||
dayjs.locale(locale);
|
||||
} else {
|
||||
console.error(`Failed to load dayjs locale for ${lang}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载antd的语言包
|
||||
* @param lang
|
||||
*/
|
||||
async function loadAntdLocale(lang: SupportedLanguagesType) {
|
||||
switch (lang) {
|
||||
case 'en-US': {
|
||||
antdLocale.value = antdEnLocale;
|
||||
break;
|
||||
}
|
||||
case 'zh-CN': {
|
||||
antdLocale.value = antdDefaultLocale;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function setupI18n(app: App, options: LocaleSetupOptions = {}) {
|
||||
await coreSetup(app, {
|
||||
defaultLocale: preferences.app.locale,
|
||||
loadMessages,
|
||||
missingWarn: !import.meta.env.PROD,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
export { $t, antdLocale, setupI18n };
|
59
apps/web-antd/src/locales/langs/en-US/component.json
Normal file
59
apps/web-antd/src/locales/langs/en-US/component.json
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"cropper": {
|
||||
"selectImage": "Select Image",
|
||||
"uploadSuccess": "Uploaded success!",
|
||||
"imageTooBig": "Image too big",
|
||||
"modalTitle": "Avatar upload",
|
||||
"okText": "Confirm and upload",
|
||||
"btn_reset": "Reset",
|
||||
"btn_rotate_left": "Counterclockwise rotation",
|
||||
"btn_rotate_right": "Clockwise rotation",
|
||||
"btn_scale_x": "Flip horizontal",
|
||||
"btn_scale_y": "Flip vertical",
|
||||
"btn_zoom_in": "Zoom in",
|
||||
"btn_zoom_out": "Zoom out",
|
||||
"preview": "Preview"
|
||||
},
|
||||
"tenantToggle": {
|
||||
"placeholder": "Please select a tenant",
|
||||
"switch": "Switch to tenant: ",
|
||||
"reset": "Reset to default tenant"
|
||||
},
|
||||
"notice": {
|
||||
"title": "Notice",
|
||||
"received": "You have received a new message"
|
||||
},
|
||||
"upload": {
|
||||
"save": "Save",
|
||||
"upload": "Upload",
|
||||
"imgUpload": "ImageUpload",
|
||||
"uploaded": "Uploaded",
|
||||
"operating": "Operating",
|
||||
"del": "Delete",
|
||||
"download": "download",
|
||||
"saveWarn": "Please wait for the file to upload and save!",
|
||||
"saveError": "There is no file successfully uploaded and cannot be saved!",
|
||||
"preview": "Preview",
|
||||
"choose": "Select the file",
|
||||
"accept": "Support {0} format",
|
||||
"acceptUpload": "Only upload files in {0} format",
|
||||
"maxSize": "A single file does not exceed {0}MB ",
|
||||
"maxSizeMultiple": "Only upload files up to {0}MB!",
|
||||
"maxNumber": "Only upload up to {0} files",
|
||||
"legend": "Legend",
|
||||
"fileName": "File name",
|
||||
"fileSize": "File size",
|
||||
"fileStatue": "File status",
|
||||
"pending": "Pending",
|
||||
"startUpload": "Start upload",
|
||||
"uploadSuccess": "Upload successfully",
|
||||
"uploadError": "Upload failed",
|
||||
"uploading": "Uploading",
|
||||
"uploadWait": "Please wait for the file upload to finish",
|
||||
"reUploadFailed": "Re-upload failed files",
|
||||
"uploadHelpMessage": "Please upload a file in {ext} format that does not exceed {size} .",
|
||||
"unknownFileType": "Unknown file type, unable to upload",
|
||||
"confirmDelete": "Confirm file deletion {0}?",
|
||||
"clickOrDrag": "Click or drag file to this area to upload"
|
||||
}
|
||||
}
|
12
apps/web-antd/src/locales/langs/en-US/demos.json
Normal file
12
apps/web-antd/src/locales/langs/en-US/demos.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"title": "Demos",
|
||||
"antd": "Ant Design Vue",
|
||||
"vben": {
|
||||
"title": "Project",
|
||||
"about": "About",
|
||||
"document": "Document",
|
||||
"antdv": "Ant Design Vue Version",
|
||||
"naive-ui": "Naive UI Version",
|
||||
"element-plus": "Element Plus Version"
|
||||
}
|
||||
}
|
7
apps/web-antd/src/locales/langs/en-US/http.json
Normal file
7
apps/web-antd/src/locales/langs/en-US/http.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"apiRequestFailed": "Operation failed",
|
||||
"operationSuccess": "Operation Success",
|
||||
"successTip": "Success Tip",
|
||||
"errorTip": "Error Tip",
|
||||
"loginTimeout": "Login timeout, please log in again"
|
||||
}
|
55
apps/web-antd/src/locales/langs/en-US/menu.json
Normal file
55
apps/web-antd/src/locales/langs/en-US/menu.json
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"root": "Root",
|
||||
"system": {
|
||||
"root": "System",
|
||||
"user": "User",
|
||||
"role": "Role",
|
||||
"menu": "Menu",
|
||||
"dept": "Department",
|
||||
"post": "Post",
|
||||
"dict": "Dictionary",
|
||||
"config": "Parameter Settings",
|
||||
"notice": "Notifications",
|
||||
"log": {
|
||||
"root": "Log",
|
||||
"operation": "Operation Log",
|
||||
"login": "Login Log"
|
||||
},
|
||||
"oss": "File",
|
||||
"client": "Client"
|
||||
},
|
||||
"tenant": {
|
||||
"root": "Tenant",
|
||||
"package": "Package"
|
||||
},
|
||||
"monitor": {
|
||||
"root": "System Monitoring",
|
||||
"online": "Online Users",
|
||||
"cache": "Cache Monitoring",
|
||||
"admin": "Admin Monitoring",
|
||||
"job": "Task Scheduling Center"
|
||||
},
|
||||
"tool": {
|
||||
"root": "System Tools",
|
||||
"gen": "Code Generation"
|
||||
},
|
||||
"workflow": {
|
||||
"root": "Workflow",
|
||||
"category": "Process Category",
|
||||
"model": "Model",
|
||||
"define": "Process Definition",
|
||||
"monitor": {
|
||||
"root": "Process Monitoring",
|
||||
"instance": "Process Instance",
|
||||
"todo": "Pending Tasks"
|
||||
},
|
||||
"form": "Form"
|
||||
},
|
||||
"task": {
|
||||
"root": "My Tasks",
|
||||
"apply": "My Initiated Tasks",
|
||||
"todo": "My Pending Tasks",
|
||||
"done": "My Completed Tasks",
|
||||
"cc": "My CC"
|
||||
}
|
||||
}
|
15
apps/web-antd/src/locales/langs/en-US/page.json
Normal file
15
apps/web-antd/src/locales/langs/en-US/page.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"auth": {
|
||||
"login": "Login",
|
||||
"register": "Register",
|
||||
"codeLogin": "Code Login",
|
||||
"qrcodeLogin": "Qr Code Login",
|
||||
"forgetPassword": "Forget Password",
|
||||
"oauthLogin": "Oauth Login"
|
||||
},
|
||||
"dashboard": {
|
||||
"title": "Dashboard",
|
||||
"analytics": "Analytics",
|
||||
"workspace": "Workspace"
|
||||
}
|
||||
}
|
27
apps/web-antd/src/locales/langs/en-US/pages.json
Normal file
27
apps/web-antd/src/locales/langs/en-US/pages.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"common": {
|
||||
"add": "Add",
|
||||
"edit": "Edit",
|
||||
"delete": "Delete",
|
||||
"more": "More",
|
||||
"search": "Search",
|
||||
"reset": "Reset",
|
||||
"import": "Import",
|
||||
"export": "Export",
|
||||
"expand": "Expand",
|
||||
"collapse": "Collapse",
|
||||
"info": "Info",
|
||||
"clear": "Clear",
|
||||
"unlock": "Unlock",
|
||||
"download": "Download",
|
||||
"sync": "Sync",
|
||||
"refresh": "Refresh",
|
||||
"generate": "Generate",
|
||||
"downloadLoading": "Downloading... Please wait.",
|
||||
"preview": "Preview",
|
||||
"tip": "Tip",
|
||||
"enable": "On",
|
||||
"disable": "Off",
|
||||
"beforeCloseTip": "You have unsaved changes. Are you sure you want to exit?"
|
||||
}
|
||||
}
|
59
apps/web-antd/src/locales/langs/zh-CN/component.json
Normal file
59
apps/web-antd/src/locales/langs/zh-CN/component.json
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"cropper": {
|
||||
"selectImage": "选择图片",
|
||||
"uploadSuccess": "上传成功",
|
||||
"imageTooBig": "图片超限",
|
||||
"modalTitle": "头像上传",
|
||||
"okText": "确认并上传",
|
||||
"btn_reset": "重置",
|
||||
"btn_rotate_left": "逆时针旋转",
|
||||
"btn_rotate_right": "顺时针旋转",
|
||||
"btn_scale_x": "水平翻转",
|
||||
"btn_scale_y": "垂直翻转",
|
||||
"btn_zoom_in": "放大",
|
||||
"btn_zoom_out": "缩小",
|
||||
"preview": "预览"
|
||||
},
|
||||
"tenantToggle": {
|
||||
"placeholder": "选择租户",
|
||||
"switch": "切换当前租户为: ",
|
||||
"reset": "还原为默认租户"
|
||||
},
|
||||
"notice": {
|
||||
"title": "消息",
|
||||
"received": "收到新消息"
|
||||
},
|
||||
"upload": {
|
||||
"save": "保存",
|
||||
"upload": "上传",
|
||||
"imgUpload": "图片上传",
|
||||
"uploaded": "已上传",
|
||||
"operating": "操作",
|
||||
"del": "删除",
|
||||
"download": "下载",
|
||||
"saveWarn": "请等待文件上传后,保存!",
|
||||
"saveError": "没有上传成功的文件,无法保存!",
|
||||
"preview": "预览",
|
||||
"choose": "选择文件",
|
||||
"accept": "支持{0}格式",
|
||||
"acceptUpload": "只能上传{0}格式文件",
|
||||
"maxSize": "单个文件不超过{0}MB",
|
||||
"maxSizeMultiple": "只能上传不超过{0}MB的文件!",
|
||||
"maxNumber": "最多只能上传{0}个文件",
|
||||
"legend": "略缩图",
|
||||
"fileName": "文件名",
|
||||
"fileSize": "文件大小",
|
||||
"fileStatue": "状态",
|
||||
"pending": "待上传",
|
||||
"startUpload": "开始上传",
|
||||
"uploadSuccess": "上传成功",
|
||||
"uploadError": "上传失败",
|
||||
"uploading": "上传中",
|
||||
"uploadWait": "请等待文件上传结束后操作",
|
||||
"reUploadFailed": "重新上传失败文件",
|
||||
"uploadHelpMessage": "请上传不超过{size}的{ext}格式文件",
|
||||
"unknownFileType": "未知的文件类型, 无法上传",
|
||||
"confirmDelete": "确认删除文件 {0}?",
|
||||
"clickOrDrag": "点击或拖动文件到这个区域上传"
|
||||
}
|
||||
}
|
12
apps/web-antd/src/locales/langs/zh-CN/demos.json
Normal file
12
apps/web-antd/src/locales/langs/zh-CN/demos.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"title": "演示",
|
||||
"antd": "Ant Design Vue",
|
||||
"vben": {
|
||||
"title": "项目",
|
||||
"about": "关于",
|
||||
"document": "文档",
|
||||
"antdv": "Ant Design Vue 版本",
|
||||
"naive-ui": "Naive UI 版本",
|
||||
"element-plus": "Element Plus 版本"
|
||||
}
|
||||
}
|
7
apps/web-antd/src/locales/langs/zh-CN/http.json
Normal file
7
apps/web-antd/src/locales/langs/zh-CN/http.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"apiRequestFailed": "请求出错,请稍候重试",
|
||||
"operationSuccess": "操作成功",
|
||||
"successTip": "成功提示",
|
||||
"errorTip": "错误提示",
|
||||
"loginTimeout": "登录超时, 请重新登录"
|
||||
}
|
55
apps/web-antd/src/locales/langs/zh-CN/menu.json
Normal file
55
apps/web-antd/src/locales/langs/zh-CN/menu.json
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"root": "根目录",
|
||||
"system": {
|
||||
"root": "系统管理",
|
||||
"user": "用户管理",
|
||||
"role": "角色管理",
|
||||
"menu": "菜单管理",
|
||||
"dept": "部门管理",
|
||||
"post": "岗位管理",
|
||||
"dict": "字典管理",
|
||||
"config": "参数设置",
|
||||
"notice": "通知公告",
|
||||
"log": {
|
||||
"root": "日志管理",
|
||||
"operation": "操作日志",
|
||||
"login": "登录日志"
|
||||
},
|
||||
"oss": "文件管理",
|
||||
"client": "客户端管理"
|
||||
},
|
||||
"tenant": {
|
||||
"root": "租户管理",
|
||||
"package": "套餐管理"
|
||||
},
|
||||
"monitor": {
|
||||
"root": "系统监控",
|
||||
"online": "在线用户",
|
||||
"cache": "缓存监控",
|
||||
"admin": "Admin监控",
|
||||
"job": "任务调度中心"
|
||||
},
|
||||
"tool": {
|
||||
"root": "系统工具",
|
||||
"gen": "代码生成"
|
||||
},
|
||||
"workflow": {
|
||||
"root": "工作流",
|
||||
"category": "流程分类",
|
||||
"model": "模型管理",
|
||||
"define": "流程定义",
|
||||
"monitor": {
|
||||
"root": "流程监控",
|
||||
"instance": "流程实例",
|
||||
"todo": "待办任务"
|
||||
},
|
||||
"form": "表单管理"
|
||||
},
|
||||
"task": {
|
||||
"root": "我的任务",
|
||||
"apply": "我发起的",
|
||||
"todo": "我的待办",
|
||||
"done": "我的已办",
|
||||
"cc": "我的抄送"
|
||||
}
|
||||
}
|
15
apps/web-antd/src/locales/langs/zh-CN/page.json
Normal file
15
apps/web-antd/src/locales/langs/zh-CN/page.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"auth": {
|
||||
"login": "登录",
|
||||
"register": "注册",
|
||||
"codeLogin": "验证码登录",
|
||||
"qrcodeLogin": "二维码登录",
|
||||
"forgetPassword": "忘记密码",
|
||||
"oauthLogin": "第三方登录"
|
||||
},
|
||||
"dashboard": {
|
||||
"title": "概览",
|
||||
"analytics": "分析页",
|
||||
"workspace": "工作台"
|
||||
}
|
||||
}
|
27
apps/web-antd/src/locales/langs/zh-CN/pages.json
Normal file
27
apps/web-antd/src/locales/langs/zh-CN/pages.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"common": {
|
||||
"add": "新增",
|
||||
"edit": "编辑",
|
||||
"delete": "删除",
|
||||
"more": "更多",
|
||||
"search": "搜索",
|
||||
"reset": "重置",
|
||||
"import": "导入",
|
||||
"export": "导出",
|
||||
"expand": "展开",
|
||||
"collapse": "收起",
|
||||
"info": "详情",
|
||||
"clear": "清空",
|
||||
"unlock": "解锁",
|
||||
"download": "下载",
|
||||
"sync": "同步",
|
||||
"refresh": "刷新",
|
||||
"generate": "生成",
|
||||
"downloadLoading": "下载中, 请稍后...",
|
||||
"preview": "预览",
|
||||
"tip": "提示",
|
||||
"enable": "启用",
|
||||
"disable": "禁用",
|
||||
"beforeCloseTip": "您有未保存的更改,确认要退出吗?"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user