feat: release v0.26 portable i18n and presentation adapters
This commit is contained in:
28
examples/i18n/README.md
Normal file
28
examples/i18n/README.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# 独立国际化、HTTP 和前端示例
|
||||
|
||||
不依赖数据库、其他项目或外部服务。默认作为 CLI 运行;同一 Bundle 也接入 HTTP 错误和前端导出。
|
||||
|
||||
```sh
|
||||
go run ./examples/i18n
|
||||
go run ./examples/i18n -serve 127.0.0.1:8098
|
||||
```
|
||||
|
||||
访问 `http://127.0.0.1:8098/`,输入草稿并切换语言。只更新标题、标签和按钮文字;输入内容、提交次数和表单节点保留。浏览器模拟 `/locales/zh-Hans.json` 加载失败时保留当前语言;快速连续切换不会被旧加载覆盖。
|
||||
|
||||
```sh
|
||||
curl -i -H 'Accept-Language: zh-CN' http://127.0.0.1:8098/api/limit
|
||||
```
|
||||
|
||||
返回 HTTP 409,业务码 400001,中文公开提示;改成 `en` 时只改变展示文案。静态页面和语言包使用直接输出,不受公共响应格式包装。
|
||||
|
||||
项目管理普通 UI 词典;错误源文案只在 Go Catalog 中维护,`errori18n.Source` 在装配时提供源词典,JSON 只维护中文译文。所有语言包显式嵌入,不受进程工作目录或环境变量影响。
|
||||
|
||||
```sh
|
||||
go run ./examples/i18n -export-locale zh-Hans
|
||||
go run ./examples/i18n -catalog > /tmp/omni-i18n-errors.json
|
||||
go run ./cmd/go-omni i18n extract --catalog /tmp/omni-i18n-errors.json \
|
||||
--locale en --namespace errors
|
||||
go test ./examples/i18n
|
||||
```
|
||||
|
||||
前端 Pack 只导出 `ui` 命名空间,不把错误业务码、HTTP 状态、内部 cause 或未选择的文案混进去。更多检查与类型导出命令见 [通用说明](../../i18n/README.md)。
|
||||
Reference in New Issue
Block a user