当前位置:网站首页>【ZeloEngine】本地化流程/ImGui中文化
【ZeloEngine】本地化流程/ImGui中文化
2022-06-13 03:43:00 【zoloypzuo】
【ZeloEngine】本地化流程/ImGui中文化
结论
填了中文化和icon的坑(2021/12/19开的坑)
- ImGui编辑器界面中文化
- 一个所见即可译的完全自动化翻译流程
- 【坑】中文字符集范围
- 【坑】icon font和id机制
- 【坑】屏蔽节点
本地化流程
先做了一版标准流程v1,然后做一下优化v2
v1本地化流程
【ZeloEngine】本地化流程/ImGui中文化_哔哩哔哩_bilibili
v1的标准流程是:
- 我打开游戏,看到“Open all”是英文,没有翻译
- 我去代码里搜"Open all",找到字符串,用gettext函数包一下,转换成中文
- 去.pot添加"Open all",然后翻译.po
- 游戏中显示中文
v2本地化流程
Q:本地化是什么?
A:所有用户可以看到的文本都应该是中文的
所以我们可以去监听ImGui里所有会显示出来的文本参数,在ImGui实现上包一下gettext,并且输出运行时所有遇到/看到的文本,自动更新翻译模板文件.pot
直接修改imgui.cpp风险还是太大了,imgui仍然在更新中
好在我们有Lua的脚本绑定层,算是一层封装,且所有imgui逻辑都是在Lua写的,在这里改就好了
v2的流程是:
- 我打开游戏,看到"Open all"
- 关闭游戏,自动刷新.pot,新增"Open all"
- 翻译.po
- 游戏中显示中文
优化掉了
- 观察哪个文本没有翻译
- 去代码里搜索key并改代码
- 在.pot里添加key
坑
完全自动化的美好愿景,往往会被各种corner case打破,让自动化变成一个处理各种奇怪情况的黑盒
v1标准流程并非完全不好,实现简单,没有BUG,完全可控
中文字符集范围
GetGlyphRangesChineseSimplifiedCommon is misleading · Issue #2882 · ocornut/imgui
imgui里的两个范围Common和Full都有问题
- Common太小,很多字都是乱码
- Full太大,实测额外消耗300MB内存
issue里的那一套,实测100MB,也没有乱码,先用着吧
label ID & icon font
直接用ImGui的接口gettext的问题是,imgui有类似my_name##1
的ID机制
icon font是个好东西,一般的icon做法是小图片,icon font是把icon当作字来画的,类似emoji
但是一个串里面有icon就很麻烦,需要做一个简单的parse,识别开头的icon和结尾的id,把正文裁剪出来,翻译好再拼回去
"%icon% my name ##1"
=> "%icon%" gettext("my name") "##1"
边栏推荐
- Multi thread writing method and the making of slot machine
- Two Chinese vector map data with map review number
- LVS four layer load balancing cluster (4) main methods of load balancing
- 【测试开发】测试管理工具禅道的安装
- Display line number in MySQL query result
- Lambda end operation find and match findfirst
- 不卷了!团队又一位成员离职了。。
- Jumpserver: user - system privileged user - Asset - authorization
- 基于华为云物联网设计的浇花神器(STM32+ESP8266)
- On interests and hobbies
猜你喜欢
[test development] automatic test selenium (I)
【测试开发】自动化测试selenium(三)——unittest框架解析
Jumpserver installation
Explain usage, field explanations, and optimization instances of MySQL
swap()
MapReduce internal execution principle
机器人避障系统基础
CDN domain name
LVS four layer load balancing cluster (5) LVS overview
GoFrame第五天
随机推荐
Doris data import broker load
Oracle database management
Database object, sequence, view, index
MySQL 8.0 enables remote root user access and solves the problem of you are not allowed to create a user with Grant
Scala method and function notes
Two Chinese vector map data with map review number
单片机:A/D(模数转换)的主要指标
UnionPay commerce - merchant statistics service platform
swap()
An error is reported in the JDBC connection database: connection to 139.9.130.37:15400 referred
try-catch finally执行顺序的例题
双目视觉——打造室外避障的“最优解”
H5 jump to mobile app store
Getting started with Oracle
Several common ways for Flink to extract eventtime and generate watermark
GoFrame第四天
Lambda end operation find and match findany
Big Five personality learning records
Detailed explanation of MySQL storage process
无人机避障四种常见技术中,为何大疆首选双目视觉