在我的
以下是我额外的要求:
输出结果应该是:
这个问题是我自己的问题的更复杂的变种,你可以在这里找到它:重新排序.strings文件。
Localizable.Strings
文件中,我尝试将所有键值对按字母顺序排列。是否有可能使用genstring或特殊的bash脚本按字母顺序重新排列它们?以下是我额外的要求:
1. 排序应不区分大小写。
2. 前X行(例如前五行)应复制,而不是排序。
因为Localized.strings文件中顶部的注释包含作者、公司名称和产品名称,所以必须满足此要求。3. 保留注释
我想保留已翻译字符串的注释,并在每个翻译之间保留换行符。这些注释是iOS开发人员使用特殊的genstrings命令生成的(例如find./ -name "*.m" -print0 | xargs -0 genstrings -o en.lproj
会在我的代码中查找所有NSLocalizedString(@"Param",@"Comment")
并生成配对/* Comment */ /r/n "Param" = "Param";
到文件中)。翻译之前的注释行是可选的,可能只有一行。例如,文件:/* This is Billy */
"Billy" = "The smartest guy in the univererse";
/* The Hitchhiker's Guide to the Galaxy */
"42" = "the answer to life the universe and everything";
"Johny" = "Johny";
/* Optional field */
"Anny" = "Anny";
输出结果应该是:
/* The Hitchhiker's Guide to the Galaxy */
"42" = "the answer to life the universe and everything";
/* Optional field */
"Anny" = "Anny";
/* This is Billy */
"Billy" = "The smartest guy in the univererse";
"Johny" = "Johny";
这个问题是我自己的问题的更复杂的变种,你可以在这里找到它:重新排序.strings文件。