按照官网的demo配置的国际化,vue页面中正常,但是pages.json中没有生效,直接就是字符串显示
如图

local文件夹路径
pages.json中 tabbar的配置
main.ts文件
import { createSSRApp } from "vue";
import { createI18n } from "vue-i18n";
import App from "./App.vue";
import { en, zh } from '/locale';
import uviewPlus from 'uview-plus';
export type LocaleMessages_type = keyof typeof messages;
const messages = {
en,
'zh-Hans': zh
};
const i18n = createI18n({
locale: uni.getLocale(), // 获取已经设置的语言
messages, // 翻译字典
legacy: false, // VUE3 中使用组合式API,必须设置为 false,
globalInjection: true // 全局注入 $t 函数
});
export function createApp() {
const app = createSSRApp(App);
app.use(i18n);
app.use(uviewPlus as any);
// 配置uview-plus内部的各项内置配置
uni.$u.setConfig({
// 修改$u.config对象的属性
config: {
// 修改默认单位为rpx,相当于执行 uni.$u.config.unit = 'rpx'
unit: 'rpx'
},
// 修改$u.props对象的属性
props: {
// 修改radio组件的size参数的默认值,相当于执行 uni.$u.props.radio.size = 30
radio: {
size: 15
}
// 其他组件属性配置
// ......
}
});
return { app };
}
zh-Hans.json文件
{
"A new way to make your air conditioner smarter": "让您的暖通空调更智能",
"GET STARTED": "开始",
"Tenant": "租户",
"Password": "密码",
"I have read and agree": "我已阅读并同意",
"User agreement": "用户协议",
"Privacy Policy": "隐私政策",
"Sign In": "登录",
"Sign Up": "注册",
"Please agree and check the User Agreement and Privacy Policy": "请同意并勾选用户协议、隐私政策",
"Please enter the correct tenant name": "请填写正确的租户名",
"Gateway SN": "网关序列号",
"Data value": "数值",
"Device name": "设备名称",
"Generation time": "发生时间",
"Message": "消息",
"Workbench": "工作台",
"Me": "我的",
"User Information": "用户信息",
"Change Password": "修改密码",
"Lite Mode": "精简模式",
"Setting": "设置",
"Log Out": "退出",
"End users can only enable it": "终端用户才可开启",
"User name": "用户名",
"Real name": "真实姓名",
"Gender": "性别",
"Phone number": "电话",
"Email": "邮箱",
"Last login time": "上次登录时间",
"Male": "男",
"Femal": "女",
"Old password": "旧密码",
"New password": "新密码",
"Repeat password": "再次确认密码",
"Confirm": "确认",
"Can not be empty": "不能为空",
"Old password is incorrect": "旧密码不正确",
"Password length is 8 to 16": "密码长度应在8到16位",
"Passwords do not match": "两次密码不一致",
"Change successfully": "修改成功",
"Change fail": "修改失败",
"Language": "语言",
"About us": "关于我们",
"Currently selected": "当前选中",
"Search keywords": "搜索关键字",
"All": "全部",
"Online": "在线",
"Offline": "离线",
"Gateway status": "网关状态",
"Alarm status": "告警状态",
"Device details": "设备详情",
"Control panel": "遥控器",
"Device alias": "设备别名",
"Device status": "设备状态",
"Residual flow": "剩余流量",
"Last register time": "最后注册时间",
"Last connect time": "最后联系时间",
"More": "更多",
"Installation information": "安装信息",
"Scheduled task": "定时任务",
"Control record": "控制记录",
"Alarm message": "告警消息",
"Temp": "温度",
"Wind scale": "风向",
"Humidity": "湿度",
"Data name": "数据项名称",
"Data alias": "数据项别名",
"Set value": "设置值",
"Update time": "更新时间",
"Run time": "运行时间",
"Edit": "编辑",
"Delete": "删除",
"Cancel": "取消",
"Confirm delete": "确认删除?",
"Data item": "数据项",
"Task name": "任务名称",
"Periodic": "周期执行",
"Enable": "是否运行",
"Periodic type": "周期类型",
"Everyday": "每天",
"Workday": "工作日",
"Custom": "自定义",
"Sunday": "周日",
"Monday": "周一",
"Tuesday": "周二",
"Wednesday": "周三",
"Thursday": "周四",
"Friday": "周五",
"Saturday": "周六",
"Select data item": "选择数据项",
"Filter data item": "过滤数据项",
"There are still contents not filled in": "还有内容未填写",
"Operator customer": "操作人",
"Starting time": "开始时间",
"Control result": "控制结果",
"No more data": "没有更多了",
"Success": "成功",
"Fail": "失败"
}