Home

Awesome

AGi18n

Utility to easily localize your iOS apps by automatically extracting texts from code and XIB files into a Localizable strings and inject them back on runtime without changing your XIB files. Check out the demo video

Why use AGi18n?

Localizing apps that use Interface Builder is tedious. You have a few methods provided by Apple (like the ibtool) but they are hard to use, time consuming, difficult to mantain and their output format is not as clean as the one in Localizable.strings using NSLocalizableString. You can find more info about the problems of the standard ways here Localization in iOS apps made simple.

By using AGi18n you make all your IB elements to use your Localizable.strings by default, without changing any single line of code or property in your IB files. It just works! Moreover, AGi18n comes with two useful utilities:

/* SDCartItemCell~iphone.xib, SDCartItemSmallCell~iphone.xib */
"price" = "price";

/* SDCartItemCell~iphone.xib, SDCartItemSmallCell~iphone.xib */
"quantity" = "quantity";

/* SDOrderCell~ipad.xib */
"status" = "status";

Installation of the library into your project

For any project where you want to use AGi18n, you need to include the source files contained in the /lib folder. For that you can just drag & drop the files into your project or use CocoaPods:

pod 'AGi18n'

Installation of the tools

The project also includes a set of command line utilities to help you extracting the labels from your Storyboard or XIB files into Localizable files. This step is not required if you do not want to use the extracting tools.

To install the command line utilities, just run this installation tool

curl -L https://raw.github.com/angelolloqui/AGi18n/master/bin/install.sh | sh

or, if you want to do it manually, copy and paste the genxibstrings and agi18n files in any folder contained in your PATH (with +x permission)

WARNING: The current version of AGi18n tools require ruby 1.9.0.

Internals

The library can run in 2 hook modes:

Since issue #32 the default method is the override. However, you can change it to swizzling by declaring the precompilation header AGI18N_USE_SWIZZLING=1.

Both hook modes will call to a method called [NSObject localizeFromNib], so virtually every object can be localized in the XIB files. AGi18n also includes a built-in set of categories for standard UI components such as UILabel, UIButton, UITextField... to correctly set their localizable properties (text, title, placeholders,...).

If you want to localize a custom component, just overwrite the method localizeFromNib and place your localization logic there. Make sure you call to [super awakeFromNib]if you override that method.

Caveats

All this magic can not come without some caveats:

License

Made available under the BSD3 License

Collaboration

Forks, patches and other feedback are always welcome.

Thanks for your pull requests to:

Credits

AGi18n is brought to you by Angel Garcia Olloqui. You can contact me on:

Project Page: AGi18n

Personal webpage: angelolloqui.com

Twitter: @angelolloqui

LinkedIn: angelolloqui