Is it possible to update a localized storyboard's strings?

前端 未结 14 1170
星月不相逢
星月不相逢 2020-11-28 00:13

I localized a part of my application with creating a base.lproj storyboard and 3 string files for it. It was a month ago and after that I added new view controller to app, b

相关标签:
14条回答
  • 2020-11-28 00:58

    I got a huge storyboard with a lot of strings there. Two languages base english and another arabic. The task was to add some fields and labels to storyboard and add localization for them without any scripts and NSLocalizableStrings.

    For me helped next:

    First: Ensure, you have git to prevent unexpectable changes.

    1. Go to target screen in xcode and press Editor -> Export For Localization.... Save the ar.xliff file somewhere.
    2. Download XLIFF Edtior.
    3. Open ar.xliff file and make changes.
    4. Import this file in xcode. Done! You have updated storyboard strings file.
    0 讨论(0)
  • 2020-11-28 01:01

    Here is a script to extract strings from storyboards and xibs, and merge them with existing translations.

    To run the script automatically when you build a project, put the script into your project root directory, and add a Run Script phase with the following line to a target build phases in your project settings.

    ./mergegenstrings.py PathToSourceDir
    

    Or you can run the script on Terminal manually when you want to.

    The script runs ibtool as Tha Leang answered. It also runs genstrings to extract and merge strings marked with NSLocalizedString in your source code. The script is based on a script in this post, which merges strings after running genstrings.

    0 讨论(0)
  • 2020-11-28 01:06

    There is an app a command line tool from Apple named AppleGlot that supports incremental localisation. I haven't tried it yet, but it looks exactly like the tool you searched for (some time ago).

    0 讨论(0)
  • 2020-11-28 01:08

    There are two options:

    Option 1

    Xcode can "reload" the file by converting the file to either an [Interface Builder Cocoa Touch Storyboard] file type or a [Localizable Strings] file type.

    1. Select your base storyboard file from the Project Navigator
    2. Find the Localization section in the File Inspector
    3. If your file is currently a [Localizable Strings], change it to [Interface Builder Cocoa Touch Storyboard] or vice-versa.
    4. Xcode should have converted your storyboard to the current version, while preserving your old localization efforts. Here you can change the file back to the original file type if you would like.

    Option 2

    Use ibtool to extract the strings in your storyboard.

    1. Open the Terminal application

    2. Locate your Base.lproj directory

    3. Use this line to extract the strings:

      ibtool MainStoryboard.storyboard --generate-strings-file file_name.strings

    4. After ibtool extracts the strings to file_name.strings, you can copy and paste it to your original .strings file

    Visit for more info: https://conyac.cc/business/columns/localization_guide_ios

    0 讨论(0)
  • 2020-11-28 01:09

    You can manually add a key in your localization file. You can find the key object by selecting it on storyboard editor. Let's have a look at Object-ID in the identity inspector. It's look like "nwc-b2-19c"

    On your localization update or add translation. For example :

    "nwc-b2-19c.title" = "Translated title";
    
    0 讨论(0)
  • 2020-11-28 01:11

    This one is not for everybody, but it requires no additional tools in the terminal and it's easy for small manual changes. (Do not consider this when you want to automate your process.)

    Step 0: Storyboard language setup

    • Base (with english texts)
    • English (localizable strings file does not exist because the base file is english)
    • other languages (localizable strings files)

    This step is done only once.

    Now when I add something to the storyboard I do the following

    Step 1: add the English localizable strings file

    just mark the English line item.

    This creates a completely new english localizable strings file with all the lines

    Step 2: copy the new line items into the other language files

    and translate them

    Step 3: unmark English, remove the corresponding localizable strings file

    the file was only needed to get the new line items

    This is an easy and fast process, everything is done in the storyboard editor

    Edit:

    This process works very well with small storyboards. For example, I have a tabs based project and I have a storyboard for each tab.

    Search for "storyboard reference" to find tutorials.

    Good example: Storyboard reference in Xcode, where should we use it?

    So each small storyboard only has a few strings to localize.

    0 讨论(0)
提交回复
热议问题