openwrt web中文语言支持,并设置默认中文

OPENWRT WEB中文语言支持,并设置默认中文

在menuconfig中先选择支持luci-i18n-zh_ch

然后修改配置文件:

修改配置文件,配置默认中文

vim feeds/luci/modules/luci-base/root/etc/config/luci
修改 option lang 'auto' 为 option lang 'zh_cn'

或者直接执行sed语句

sed -i 's/option lang auto/option lang zh_cn/g' feeds/luci/modules/luci-base/root/etc/config/luci

上面说的是修改方案,这个接下来再说一下后面的细节

代码中,语言包的存在是.po后缀的文件,里面包含了

msgid "Mode"
msgstr "模式"

我这边修改支持了一个luci-base的中文包,修改的文件是这个:

luci/modules/luci-base/po/zh_cn/base.po

那么接下来编译,编译ipk软件包最终打包的文件是

book@book:~/openwrt/build_dir/target-arm_cortex-a7_musl_eabi/luci-base/ipkg-all/luci-i18n-base-zh-cn$ tree -L 6 .
.
├── CONTROL
│   ├── control
│   ├── postinst
│   ├── postinst-pkg
│   └── prerm
├── etc
│   └── uci-defaults
│       └── luci-i18n-base-zh-cn
└── usr
    └── lib
        └── lua
            └── luci
                └── i18n
                    └── base.zh-cn.lmo

8 directories, 6 files

在设备上识别的是lmo文件,因为openwrt只能识别紧凑型的lmo文件,所以中间是经过转换的,转换的方式是 po2lmo xxx.po xxx.lmo

其中po2lmo的文件位置是在:

~/openwrt/build_dir/target-arm_cortex-a7_musl_eabi/luci-base/po2lmo

后续测试的时候可以直接手动生成并替换测试,不需要再编译版本进行测试。

刚刚测试了上述说的手动验证的方法:

#编译
book@book:~/luci/modules/luci-base/po/zh_cn$ ~/openwrt/build_dir/target-arm_cortex-a7_musl_eabi/luci-base/po2lmo base.po base.zh-cn.lmo
#上传测试
book@book:~/luci/modules/luci-base/po/zh_Hans$ scp base.zh-cn.lmo admin@192.168.125.83:/usr/lib/lua/luci/i18n/base.zh-cn.lmo
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值