如何在 Xcode 中自动检查缺少的本地化? [英] How can I automatically check for missing localizations in Xcode?

查看:26
本文介绍了如何在 Xcode 中自动检查缺少的本地化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NSLocalizedString(@"Word 1", @"");
NSLocalizedString(@"Word 2", @"");

de.lproj/Localizable.strings

"Word 1" = "Wort 1";
"Word 2" = "Wort 2";

fr.lproj/Localizable.strings

/* Missing Word 1 */
"Word 2" = "Mot 2";

是否有脚本或编译器设置可以检查所有本地化字符串是否在所有支持的语言环境中都已翻译?

Is there a script or a compiler setting that will check that all localised strings are translated in all supported locales?

推荐答案

您可以使用diff 键列表上的键来查看缺少什么

You can use diff on the list of keys to see what's missing

这是一个 shell 脚本(我们称之为 keys.sh),用于打印给定 .strings 文件的键,排序为 stdout:

Here's a shell script (let's call it keys.sh) to print out the keys of a given .strings file, sorted to stdout:

#!/bin/sh
plutil -convert json "$1".lproj/Localizable.strings -o - | ruby -r json -e 'puts JSON.parse(STDIN.read).keys.sort'

然后您可以将它与 <(cmd) shell 语法结合使用来比较两个本地化之间的键;例如比较你的 Base.lprojfr.lproj:

You can then use it combined with the <(cmd) shell syntax to compare keys between two localisations; for example to compare your Base.lproj and fr.lproj:

diff <(keys.sh Base) <(keys.sh fr)

这篇关于如何在 Xcode 中自动检查缺少的本地化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆