LoginSignup
0
1

More than 3 years have passed since last update.

xib、storyboardのstringsファイルへの追加方法

Posted at

はじめに

Interface Builder を多言語対応するには、以下の2つの方法で対応が可能です。
1. Interface Builder Storyboard : 言語毎にStoryboardを作成しレイアウトを設定
2. Localizable Strings : レイアウトは同じで言語毎のstringsファイルを作成

今回、後者を選択後に新たにリソースをstringsファイルに追加する方法です。
情報が少なく見つけにくかったので、忘備録として以下に記しておきます。

環境

  • macOS Catalina 10.15.2
  • Xcode 11.3.1

手順

手順は参考元にあるとおり。

xib、storybaord は Base.lproj フォルダに格納されているので、そこでコマンドを実行。
言語.lproj にstringsファイルが格納されているので、マージすれば追加できます。

参考元

Updating Storyboard and Xib Strings Files Using ibtool

Updating Storyboard and Xib Strings Files Using ibtool

When you change user-facing text in .storyboard or .xib files, use the ibtool command to generate new strings files. Use another tool—for example, FileMerge—to identify the changes and merge them into the existing strings files for each language you support. Xcode doesn’t automatically update the corresponding strings files when you edit a .storyboard or .xib file.

In Terminal, change to the Base.lproj folder, and run this command to generate a strings file for an xib file:

ibtool [MyNib].xib --generate-strings-file [MyNib_new.strings]

Optionally, localize the changes in the output file before merging the changes with the [MyNib].strings file in each lproj folder. To launch FileMerge from Xcode, choose Xcode > Open Developer Tool > FileMerge.

Alternatively, you can use the ibtool command to merge translations back into a nib file and perform other incremental localization updates, as described in the ibtool man page. Or use the appleglot command to manage changes to the strings files, as described in Importing Localizations.

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1