X code。与剧本5分镜本地化删除* .strings文件? [英] xcode 5 localize storyboard with script delete *.strings file?

查看:302
本文介绍了X code。与剧本5分镜本地化删除* .strings文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不好意思再拍打扰。
我实现一个应用程序,并在X code 5英语和日语的本地化,使用由安德烈·平托创建的脚本文件的基础上的单故事板多种语言的。好了,之前升级为x code 5(X code 4.6,我的意思),事情正常工作。但由于X code 5,出现此错误时运行脚本文件:

sorry to make another bother. I'm implement an app, with localization of English and Japanese in xcode 5, using the script file created by André Pinto, based on SIngle Storyboard for multiple languages. Well, before upgrade to xcode 5 (xcode 4.6, I mean), things work properly. But since xcode 5, this error occurs when run the script file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>com.apple.ibtool.errors</key>
    <array>
        <dict>
            <key>description</key>
            <string>Interface Builder could not open the document "xx.storyboard" because it does not exist.</string>
        </dict>
    </array>
  </dict>
</plist>

Iconv: ./xx/Base.lproj/xx.strings.new: No such file or directory
Rm: ./xx/Base.lproj/xx.strings.new: No such file or directory
Merging xx.strings changes for en.lproj...
Merging xx.strings changes for ja.lproj...
Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure

在故事板,有2个分档:xx.storyboard(基本)和xx.storyboard(日语)

In the storyboard, there are 2 sub-files: xx.storyboard(Base) and xx.storyboard(Japanese)

在第一个版本,不会发生错误。一切都很好。应用本地化那么好。

In the first build, no error occur. Everything went fine. App localize so good.

在第二个版本,我做在故事板somechange(增加一些新的功能),然后发生错误。此外,xx.storyboard(日本)变成空白,这是不可思议。我花费了很多精力翻译这些东西,现在我必须重新做...

In the second build, I made somechange in storyboard (add some new feature), then error occur. Also, the xx.storyboard(Japanese) become blank, and this is weird. I put lots of effort translate those things, and now I have to do it again...

我觉得有一些问题,剧本,strings.new和strings.old ...

I think there's some problem with the script, the strings.new and strings.old...

下面的脚本:

#!/bin/sh
# Update storyboard string files
#
# by 2013 André Pinto andredsp@gmail.com
# based on http://forums.macrumors.com/showthread.php?t=1467446

storyboardExt=".storyboard"
stringsExt=".strings"
newStringsExt=".strings.new"
oldStringsExt=".strings.old"
localeDirExt=".lproj"
baselprojName="Base.lproj"

# Find Base internationalization folders
find . -name "$baselprojName" | while read baselprojPath
do
    # Get Base project dir
    baselprojDir=$(dirname "$baselprojPath")

    # Find storyboard file full path inside base project folder
    find "$baselprojPath" -name "*$storyboardExt" | while read storyboardPath
    do
        # Get Base strings file full path
        baseStringsPath=$(echo "$storyboardPath" | sed "s/$storyboardExt/$stringsExt/")

        # Get storyboard file name and folder
        storyboardFile=$(basename "$storyboardPath")
        storyboardDir=$(dirname "$storyboardPath")

        # Create strings file only when storyboard file newer
        newer=$(find "$storyboardPath" -prune -newer "$baseStringsPath")
        [ -f "$baseStringsPath" -a -z "$newer" ] && {
            echo "$storyboardFile file not modified."
            continue
        }

        # Get New Base strings file full path and strings file name
        newBaseStringsPath=$(echo "$storyboardPath" | sed "s/$storyboardExt/$newStringsExt/")
        stringsFile=$(basename "$baseStringsPath")

        echo "Creating default $stringsFile for $storyboardFile..."
        ibtool --export-strings-file "$newBaseStringsPath" "$storyboardPath"
        iconv -f UTF-16 -t UTF-8 "$newBaseStringsPath" > "$baseStringsPath"
        rm "$newBaseStringsPath"

        # Get all locale strings folder with same parent as Base
        ls -d "$baselprojDir/"*"$localeDirExt" | while read localeStringsDir
        do
            # Skip Base strings folder
            [ "$localeStringsDir" = "$storyboardDir" ] && continue

            localeDir=$(basename "$localeStringsDir")
            localeStringsPath="$localeStringsDir/$stringsFile"

            # Just copy base strings file on first time
            if [ ! -e "$localeStringsPath" ]; then
                echo "Copying default $stringsFile for $localeDir..."
                cp "$baseStringsPath" "$localeStringsPath"
            else
                echo "Merging $stringsFile changes for $localeDir..."
                oldLocaleStringsPath=$(echo "$localeStringsPath" | sed "s/$stringsExt/$oldStringsExt/")
                cp "$localeStringsPath" "$oldLocaleStringsPath"

                # Merge baseStringsPath to localeStringsPath
                awk '
NR == FNR && /^\/\*/ {
    x=$0
    getline
    a[x]=$0
    next
}
/^\/\*/ {
    x=$0
    print
    getline
    $0=a[x]?a[x]:$0
    printf $0"\n\n"
}'  "$oldLocaleStringsPath" "$baseStringsPath" > "$localeStringsPath"

                rm "$oldLocaleStringsPath"
            fi
        done
    done
done

Localizable.strings和InfoPlist.strings都还是不错的。

Localizable.strings and InfoPlist.strings are still good.

任何人有这样的事情经历帮助我,请...是一些与X code或脚本文件或文件xx.strings?我不明白这一点...

Anyone has experience with this kind of things help me please... Is that something with xcode, or script file or xx.strings file? I don't get it...

我可以直接问它的脚本的创作者,但我想在这里发布的问题会更好。我是一个SO情人:)

I may ask it directly the script's creator, but I think post the question here will be better. I'm a SO lover :)

推荐答案

我用的是同一个脚本,你,并有同样的问题你。然后,我发现这些文章从AppliedIS 中,详细介绍他们的国际化和本地化的过程。他们使用这个脚本,这似乎是稍微更稳健的更新版本。

I was using same script as you, and had the same issues as you. Then I found these articles from AppliedIS, detailing their process of I18n and L10n. They used an updated version of this script that seems to be slightly more robust.

他们也有一个脚本从 NSLocalizedString 语句提取键和生成 Localizable.strings 的各个地区,以及。生成新的条目时,这是相当聪明的这个脚本使用作为值的注释。

They also have a script for extracting keys from NSLocalizedString statements and generate Localizable.strings for every locale as well. This script uses the comment as the value when generating the new entries, which is quite clever.

我已经转向这些现在,它似乎更快(这可能是只是我; 哦,新的==更快),有更多的输出(漂亮调试)它只有在安装也是作品,未经运行脚本

I have switched to these now, and it seems faster (that might be just me; ooh, new == faster), has more output (nice for debugging) and it also works without the Run script only when installing.

快来看看吧! (我不以任何方式与他们有联系,只是一个快乐的用户)

Check it out! (I'm not associated with them in any way, just a happy user)

这篇关于X code。与剧本5分镜本地化删除* .strings文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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