Localizing an iOS app is pretty straightforward thanks to Apple’s app internationalization options, whether you want to do it from interface builder or code. Things get a bit more complicated when you have some code which you want to separate into a framework (e.g. registration process, profile settings, etc.) in order to use through multiple projects.

You might still use the same way as above to translate the app and framework separately, but often times you’d want full control over the translations. In that case it’s best to add a class which would handle this work. The class is shown in the code below:

 

 

The method named “string” receives a translation key, tries to translate it from the app (main bundle), then searches for translation in framework’s bundle. This enables you to override frameworks’ translations if needed.

If the app allows users to chose the app language independently of the device settings, this method can easily be extended to select a specific translation file, since all the translation code is in one place.