Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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, but this controller's buttons and labels not appear in string files

Is it possible to update this 3 storyboard attached string files or I must add new strings translations programmatically with using NSLocalizableString and Localizable.strings?

like image 899
GeLB Avatar asked Oct 12 '22 03:10

GeLB


People also ask

What does localized string mean?

A localized string can have different values depending on the language in which the project is being build. There are two categories of localized strings: the strings included in the installation package's UI, common to every MSI file.

What is localized string key?

The key used to look up an entry in a strings file or strings dictionary file.

How do I add localizable strings?

To add Localizable. strings file, go to File->New->File , choose Strings File under Resource tab of iOS, name it Localizable. strings , and create the file. Now, you have a Localizable.


2 Answers

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

like image 271
Tha Leang Avatar answered Oct 18 '22 22:10

Tha Leang


Check out ReMafoX, it's a Mac app that perfectly solves your problem. It can be easily installed and integrated within your project, watch this video for a detailed walkthrough.

Alternatively, if you prefer an open source CLI tool without a GUI, you can also use BartyCrouch.


Install BartyCrouch via Homebrew:

brew install bartycrouch

Alternatively, install it via Mint:

mint install Flinesoft/BartyCrouch

Incrementally update your Storyboards/XIBs Strings files:

$ bartycrouch update

This will do exactly what you were looking for.


In order to keep your Storyboards/XIBs 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
    bartycrouch update -x
    bartycrouch lint -x
else
    echo "warning: BartyCrouch not installed, download it from https://github.com/Flinesoft/BartyCrouch"
fi

In addition to incrementally updating your Storyboards/XIBs Strings files this will also make sure your Localizable.strings files stay updated with newly added keys in code using NSLocalizedString and show warnings for duplicate keys or empty values.

Make sure to checkout BartyCrouch on GitHub or this detailed article for additional information.

like image 88
Jeehut Avatar answered Oct 18 '22 23:10

Jeehut