Skip to content

wpvsyou/translation_utils_jar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auto translation Android resource strings.xml jar util.

[email protected] personal translation utils jar. create on 2017-07-05

translation_util_jar 一个能批量自动翻译Android资源文件的java工具.

自动翻译Android项目resource资源文件,方便快捷国际化。在项目根目录下运行如下命令查看效果

gradle clean; gradle build; java -jar build/libs/translation_utils_jar-1.0.jar -f test.xml; cat out/strings.xml; echo "=====> origin string.xml file:"; cat test.xml

帮助文档

-f	--file	The input source file path that will be translation.

指定原文件路径,一次只能指定一个源文件。

-h	--help	Get help information.

帮助

-i	--info	Print the process debug logs.

打印脚本执行详情。

-m	--mode	[batch] is batch translation,Low accuracy but fast.
                 [single] is translation one by one,Time consuming but accurate.

模式(模式1为批量翻译,将源文件解析成gson传,一次翻译多条,节省时间。 模式2为逐条翻译,每次只翻译一行,效率低但是准确率高。

-s	 --src	Src code.

原文件语言编码,如若不知道请使用auto。

-d	 --dst	Dst code.

将被翻译成的语言编码,不能是auto。

  因为某些语种翻译后的返回值难于分片(因为批翻译是解析所有串的值用\n来做分割合成一个大串在做翻译,此时返回值由于语种 不同,差异很大,导致代码不能准确定位到\n分隔符去做分片,还原数据,导致数据丢失或者不准确),或通过json还原,所以会强制 走模式single.强烈建议大家在使用时加上参数-m single,此模式会大大提高翻译准确率与成功率,只有中文简体/繁体之间的转换可 以用batch模式.

暂时只支持标准string字符串的翻译。格式如下:

<string name="string_name">string</string>

支持的翻译语言范围如下:

语言简写 名称
auto 自动检测
zh 中文
en 英语
yue 粤语
wyw 文言文
jp 日语
kor 韩语
fra 法语
spa 西班牙语
th 泰语
ara 阿拉伯语
ru 俄语
pt 葡萄牙语
de 德语
it 意大利语
el 希腊语
nl 荷兰语
pl 波兰语
bul 保加利亚语
est 爱沙尼亚语
dan 丹麦语
fin 芬兰语
cs 捷克语
rom 罗马尼亚语
slo 斯洛文尼亚语
swe 瑞典语
hu 匈牙利语
cht 繁体中文
vie 越南语

to make the translation util jar.(使用gradle工具变异项目)

"gradle build" 

show help information.(使用如下命令去获取jar包帮助信息)

"java -jar build/libs/translation_utils_jar-1.0.jar -h"

声明,此项目不已盈利为目的,只为服务大众码农,代码有不足支出请指正。由于baiduAPI的限制,每月只能翻译低于200万个字符,否则将要收费。所以请各位自行更换代码中的key.

http://api.fanyi.baidu.com/api/trans/product/index

Releases

No releases published

Packages

No packages published

Languages