strsync-自动转换和同步xcode定义的基本语言中的可本地化资源文件。

strsync的Python项目详细描述


[广告]使用StringSync与我们的应用程序会面,Elie-您的下一个移动摄影 助理。http://elie.cam

AwesomePyPI versionLicense

从中自动转换和同步“.strings”文件 定义的基本语言。

这个python cli工具的基本概念是直接的文件名 基于单向同步器。如果您正在运行,其他本地化的 资源将具有自动转换字符串的相同键。 当然,在已经存在的键上的字符串将不会被修改。 全部。

当我真正工作的时候,我最大的愿望就是迅速填补 首先是许多空字符串。这个工具就是为这个目的而制造的。在一个 正常项目,自动翻译就足够了。因为他们是 总是简单的句子。是的,不,做,不同意,等等。如你所知 这个工具的所有翻译结果都是基于google 翻译。stringsync使用非官方的google ajax翻译api。所以 不需要帐户和API密钥。请注意,如果 更为复杂的是,为了得到准确的结果,需要人工检查。 但是你可以节省很多时间!

要求

安装

pip install strsync

如果需要,更新python ssl包

对于python-2.7.9+,这不是必需的

pip install requests[security]

用法

当然,这个工具遵循standard ISO639 1~2 codesapple’s official documentthis tsv table

usage: strsync <target localization resource path>

Automatically translate and synchronize .strings files from defined base language.

positional arguments:
  target path           Target localization resource path. (root path of
                        Base.lproj, default=./)

optional arguments:
  -h, --help            show this help message and exit
  -b, --base-lang-name BASE_LANG_NAME
                        A base(or source) localizable resource
                        name.(default='Base'), (e.g. "Base" via 'Base.lproj',
                        "en" via 'en.lproj')
  -x, --excluding-lang-names [EXCLUDING_LANG_NAMES ...]
                        A localizable resource name that you want to exclude.
                        (e.g. "Base" via 'Base.lproj', "en" via 'en.lproj')
  -f, --force-translate-keys [FORCE_TRANSLATE_KEYS ...]
                        Keys in the strings to update and translate by force.
  -o, --following-base-keys [FOLLOWING_BASE_KEYS ...]
                        Keys in the strings to follow from "Base".
  -l, --following-base-keys-if-length-longer
                        Keys in the strings to follow from "Base"
                        if its length longer than the length of "Base" value.
  -c, --ignore-comments
                        Allows ignoring comment synchronization.
  -v, --verify-results [VERIFY_RESULTS [VERIFY_RESULTS ...]]
                        Verify translated results via reversed results
  -i, --ignore-unverified-results [IGNORE_UNVERIFIED_RESULTS [IGNORE_UNVERIFIED_RESULTS ...]]
                        Allows ignoring unverified results when appending them.

使用

的示例
~/Documents/myapp/myapp/Resources/Localizations$ strsync

定义所需的特定路径。

$ strsync ./myapp/Resources/Localizations

不包括日语、西班牙语和芬兰语

$ strsync ./myapp/Resources/Localizations -x ja es fi

强制按所需的特定键转换和更新。

$ strsync -f Common.OK Common.Undo "Key name which contains white space"

通过所有键强制转换和更新。

$ strsync -f  (input nothing)

当你想接受“基”中的值时。

$ strsync -o autoenhance flashmode

#before
"flashmode" = "وضع الفلاش";
"flashmode.auto" = "السيارات";
"flashmode.on" = "على";
"autoenhance" = "تعزيز السيارات";

#after
"flashmode" = "Flash Mode";
"flashmode.auto" = "السيارات";
"flashmode.on" = "على";
"autoenhance" = "Auto-Enhance";

如果添加选项-v-验证结果,则字符串相似性 将显示每种语言的反向翻译结果。

$ strsync (...) -v

el
  Hi: Hi -> Γεια σου -> Hi, Matched: 100%
fr-CA
  Hi: Hi -> Salut -> Hello, Matched: 50%
id
  Hi: Hi -> Hai -> Two, Matched: 0%
fr
  Hi: Hi -> Salut -> Hello, Matched: 50%
uk
  Hi: Hi -> Привіт -> Hi, Matched: 100%
hr
  Hi: Hi -> Bok -> Book, Matched: 0%
da
  Hi: Hi -> Hej -> Hi, Matched: 100%
ja
  Hi: Hi -> こんにちは -> Hello, Matched: 50%
he
  Hi: Hi -> היי -> Hey, Matched: 50%
ko
  Hi: Hi -> 안녕 -> Hi, Matched: 100%
sv
  Hi: Hi -> Hej -> Hi, Matched: 100%
es-MX
  Hi: Hi -> Hola -> Hello, Matched: 50%
sk
  Hi: Hi -> ahoj -> Hi, Matched: 100%
zh-CN
  Hi: Hi -> 你好 -> How are you doing, Matched: 50%

或者添加–忽略未验证的结果[整数,百分比 (0~100)(默认值=0)],如果每个反向翻译的相似性 结果在给定值下,将跳过该字符串(忽略)。

ex)

strings will be skipped if its text similarity from reversed translation result is under 50

$ strsync (...) --ignore-unverified-results 50

el
  Hi: Hi -> Γεια σου -> Hi, Matched: 100%
fr-CA
  (Ignored) Hi: Hi -> Salut -> Hello, Matched: 50%
id
  (Ignored) Hi: Hi -> Hai -> Two, Matched: 0%
fr
  (Ignored) Hi: Hi -> Salut -> Hello, Matched: 50%
uk
  Hi: Hi -> Привіт -> Hi, Matched: 100%
hr
  (Ignored) Hi: Hi -> Bok -> Book, Matched: 0%
da
  Hi: Hi -> Hej -> Hi, Matched: 100%
ja
  (Ignored) Hi: Hi -> こんにちは -> Hello, Matched: 50%
he
  (Ignored) Hi: Hi -> היי -> Hey, Matched: 50%
ko
  Hi: Hi -> 안녕 -> Hi, Matched: 100%
sv
  Hi: Hi -> Hej -> Hi, Matched: 100%
es-MX
  (Ignored) Hi: Hi -> Hola -> Hello, Matched: 50%
sk
  Hi: Hi -> ahoj -> Hi, Matched: 100%
zh-CN
  (Ignored) Hi: Hi -> 你好 -> How are you doing, Matched: 50%

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java是否在servlet中检索上一页路径?   Java抱怨在开关的默认情况下未初始化最终字段   Java泛型:为什么编译器不能判断这个类<t>对象与这个类的类型参数的对象的类具有相同的类型?   Java:继承方法中使用的私有变量   HibernateJava。ClassCastException:java。lang.Integer不能强制转换为abc。def。我的项目。奥姆。EmployeeTopMetaData   http java发布和下载文件   java改进条件检查   java如何将2d数组的条目作为键放在地图中   java如何获取传递给运行时的值。getRuntime。JUnit测试用例中的exit(value)   java注释来创建所有可能的构造函数   自动建议列表:java。lang.IllegalArgumentException:在XPath表达式为null时找不到元素   为什么MapAPI在Java中不提供流功能?   gradle不导入本地java库   尽管我使用的是SessionCreationPolicy,java Spring安全性似乎仍在使用会话。无国籍   使用java查找MongoDB中数组元素的平均值