From 1682bbe10b745005c8333cd13025e894975b43e4 Mon Sep 17 00:00:00 2001 From: handongxun Date: Fri, 26 Nov 2021 17:03:21 +0800 Subject: [PATCH] =?UTF-8?q?i18n:=20=E6=96=B0=E5=A2=9Eschema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/collocation/i18n.md | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/docs/collocation/i18n.md b/docs/collocation/i18n.md index e9a4fd8ce..f14cfe2a2 100644 --- a/docs/collocation/i18n.md +++ b/docs/collocation/i18n.md @@ -139,6 +139,69 @@ pages.json 支持以下属性配置国际化信息 `manifest.json` 中支持配置默认语言,参见上面的示例,默认跟随系统语言 +## schema 国际化@schema + +HBuilderX 3.3.0+ + +在项目根目录 uniCloud/database/locale/{数据库表名}/`语言地区代码`.json 文件,然后在 `*.schema.json` 文件中使用 %% 占位 + +``` +├─uniCloud +│ ├─cloudfunctions +│ └─database +│ │ hello.schema.json +│ └─locale +│ └─hello +│ en.json +│ zh-Hans.json +``` + +hello.schema.json 文件内容 + +```json +// 文档教程: https://uniapp.dcloud.net.cn/uniCloud/schema +{ + "bsonType": "object", + "required": [], + "permission": { + "read": false, + "create": false, + "update": false, + "delete": false + }, + "properties": { + "_id": { + "description": "ID" + }, + "name": { + "bsonType": "string", + "label": "%name%", + "errorMessage": { + "format": "{label}%name.format%" + } + } + } +} +``` + +en.json 文件内容 + +```json +{ + "name": "Name", + "name.format": " invalid format" +} +``` + +zh-Hans 文件内容 + +```json +{ + "name": "姓名", + "name.format": "格式无效" +} +``` + ## 应用中原生ui界面的国际化 应用中调用到相册选择、地图等包含界面的原生能力时,这些原生界面的ui无法在前端控制。 -- GitLab