且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

iOS本地化 - 仅使用新字符串更新Localizable.strings

更新时间:2023-11-15 16:00:10

结帐 BartyCrouch ,它完美地解决了您的问题。此外,开源积极维护,可以在项目中轻松安装和集成

Checkout BartyCrouch, it perfectly solves your problem. Also it is open source, actively maintained and can be easily installed and integrated within your project.

安装 BartyCrouch通过 Homebrew

Install BartyCrouch via Homebrew:

$ brew install bartycrouch

增量更新您的 Localizable.strings 文件:

$ bartycrouch code -p "/path/to/code/directory" -l "/directory/containing/Localizables" -a

这将完全符合您的要求。

This will do exactly what you were looking for.

为了保持您的 Localizable.strings 文件随时间更新我强烈建议您添加构建脚本(有关如何添加构建脚本的说明此处) :

In order to keep your Localizable.strings files updated over time I highly recommend adding a build script (instructions on how to add a build script here):

if which bartycrouch > /dev/null; then
    # Incrementally update all Storyboards/XIBs strings files
    bartycrouch interfaces -p "$PROJECT_DIR"

    # Add new keys to Localizable.strings files from NSLocalizedString in code
    bartycrouch code -p "$PROJECT_DIR" -l "$PROJECT_DIR" -a -s
else
    echo "warning: BartyCrouch not installed, download it from https://github.com/Flinesoft/BartyCrouch"
fi

除了逐步更新 Localizable.strings 这些文件也会确保您的Storyboards / XIBs字符串文件保持更新并添加新密钥。

In addition to incrementally updating your Localizable.strings files this will also make sure your Storyboards/XIBs Strings files stay updated with newly added keys.

确保有关其他信息,请访问 GitHub 查看BartyCrouch。

Make sure to checkout BartyCrouch on GitHub for additional information.