Fame
Delightful localization of .storyboard and .xib files, right within Interface Builder.
Fame makes it easy to enable specific Interface Builder elements to be translated and exported to localizable .strings files.
Introduction
Compared to localization in code (NSLocalizedString
), Storyboard and XIB localizations are a tedious task for both developers and translators.
Static vs. dynamic localization
Storyboard and XIB files usually contain a mixed set of elements with static or dynamic text:
- Static text: Elements with fixed localization strings that will never change at runtime
- Dynamic text: Elements that will change their localized text during runtime. For example a label that is populated with data from an API or a status label that is populated using
NSLocalizedString
at runtime.
Static text elements should be localized using a generated .strings file, dynamic text elements should be ignored during translation.
However, Storyboard and XIB .stings files generated by Xcode also contain dynamic text localizations that will always be overridden at runtime. This makes it hard to distinguish between localizations that should be translated and dynamic text that can be safely ignored during translation. Its up to the app developers to either manually remove generated localizations that should not be translated, or leave them for the translators to waste their time with.
Localization comments
Storyboard and XIB .stings files generated by Xcode do not provide a useful comment that provides context to the translator.
/* Class = "UILabel"; text = "Label"; ObjectID = "Rfi-2u-xEd"; */
"Rfi-2u-xEd.text" = "Label";
Translators use this comment to make sure their translation fits into the context it is used in. Its again up to the app developers to either manually search for specific translations and add a comment, or leave let the translators figure out how to find the best translation without context.
Why Fame?
Fame solves the above mentioned issues to help developers and translators get the most out of tedious localization tasks.
Integrated into Interface Builder
Fame makes it easy for developers to specify which elements of your Storyboard and XIB files should be translated, all right within interface builder. Developers may also add a comment for each element to provide additional context to translators.
Command line interface
Using the fame CLI, developers can export .strings files that only contain localizations for elements previously enabled in Interface Builder.
Generates beautiful .strings files
Translators only receive the strings that should actually be translated, saving them time (and you potentially lots of money). All generated .strings files also contain each element's name and a useful comment to provide more context by the app developer.
/* MyViewController.label.text: Explains how to purchase a pro subscription. */
"Rfi-2u-xEd.text" = "Label";
Installation
Install the fame ruby gem using your terminal to get access to the fame command line interface.
$ gem install fame
Enable localization for Interface Builder files
Note: You may skip to the next section if you have already setup your project and Interface Builder files for localization.
First off, add all supported languages to your project. This can be done by clicking the + button under your project's Localizations configuration. Go ahead and add as many languages as you want.
Next, make sure to enable localization for your Interface Builder files and choose the "Localizable Strings" option from the dropdown.
You should now have a Base Interface Builder file (e.g. Main.storyboard
) in a Base.lproj
folder and multiple localizable strings files (e.g. Main.strings
) each within a language folder (e.g. en.lproj
and de.lproj
).
That's it, read on to enable fame for localization.
Setup Fame for Interface Builder
In order to enable the Interface Builder integration to specify the elements that should be translated, add the Fame.swift file to your Xcode project. To test the Interface Builder integration, open any Interface Builder file in your project, select an element (e.g. a UILabel) and you should see a new section that lets you configure localization for this element in the Attributes inspector.
You can now enable localization for each element you want to have translated.
Usage
Once all localizable elements have been configured in Interface Builder, you can export the localizable .strings file using the fame
command line tool.
First, make sure to commit all local changes, just to be safe. Then open terminal, navigate to the root folder of your project and run
$ fame
In a nutshell, the fame command does the following:
- Find all .storyboard and .xib files in the current folder (recursively, you can also pass a subpath or file to the fame command)
- Lookup the localizable settings (you have set in Interface Builder) for each file
- Generate the full localizable .strings file using Apple's
ibtool
- Filter the
ibtool
output based on your licalizable settings - Save a new
<NameOfStoryboardOrXIB>.strings
file to theen.lproj
folder
Contributing
- Fork it ( https://github.com/aschuch/fame/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
TODO
- Incremental updates of .string files (
ibtool --previous-file <OLD .storyboard> --incremental-file YY --localize-incremental
) - Write tests with fixtures
Contact
Feel free to get in touch.
- Website: http://schuch.me
- Twitter: @schuchalexander