Localization and internationalization of XIB and Storyboard files has historically been a very manual process. Typically these file types would be duplicated in each 'language directory' (*.lproj) and then the text and layout tweaked independently by each translator. Changes to the actual Storyboard or XIBs would need to be manually propagated across all the 'language copies'.
In iOS6 Apple introduced a new concept - Base Localization - which you can read about in their documentation on Internationalizing Your App. Your project can contain a 'special'
There is a small sample showing how this works with MonoTouch - TaskyL10nStoryboard on github. There is no IDE support currently, but you can easily create the
then inside the Storyboard itself you need to identify the controls you wish to localize. Click on a control to discover its Object ID, and shown in this screenshot:
Using the Object IDs from the Storyboard file, we can translate the display values for various properties (including text, placeholders and others) in the
Here's the localized Storyboard, in Japanese:
What about layout?
Strings can often be very different lengths in different languages. When you used a different Storyboard or XIB for each language then the control sizes could be manually adjusted to fit. When using Base Localization you should use Apple's new constraint-based layout to handle these size differences.
What about iOS5 and earlier?
This method only works on iOS6. To localize text on earlier versions of iOS you will have to duplicate your Storyboards and XIBs for each language, or create outlets for all the controls and set their localized text values in code using
There is another localized sample - TaskyL10n - which shows how to localize text elements directly and uses
In iOS6 Apple introduced a new concept - Base Localization - which you can read about in their documentation on Internationalizing Your App. Your project can contain a 'special'
Base.lproj
directory where the Storyboard files are located, and then a corresponding *.strings
file (whose filename matches the Storyboard's) in each language directory with the translations.There is a small sample showing how this works with MonoTouch - TaskyL10nStoryboard on github. There is no IDE support currently, but you can easily create the
Base.lproj
directory manually in MonoDevelop and everything works as expected. Here's a screenshot of the project structure:then inside the Storyboard itself you need to identify the controls you wish to localize. Click on a control to discover its Object ID, and shown in this screenshot:
Using the Object IDs from the Storyboard file, we can translate the display values for various properties (including text, placeholders and others) in the
MainStoryboard.strings
file in each language directory, like this:"SXg-TT-IwM.placeholder" = "nombre de la tarea"; "Pqa-aa-ury.placeholder"= "otra informaciĆ³n de tarea"; "zwR-D9-hM1.text" = "Detalles de la tarea"; "bAM-2j-Rzw.text" = "Notas"; "NF3-h8-xmR.text" = "Completo"; "MWt-Ya-pMf.normalTitle" = "Guardar"; "IGr-pR-05L.normalTitle" = "Eliminar";Using the Object ID and property as the localization key is quite different to Apple's previous guidance on localization, where the key is typically the base-language's actual displayable value.
Here's the localized Storyboard, in Japanese:
What about layout?
Strings can often be very different lengths in different languages. When you used a different Storyboard or XIB for each language then the control sizes could be manually adjusted to fit. When using Base Localization you should use Apple's new constraint-based layout to handle these size differences.
What about iOS5 and earlier?
This method only works on iOS6. To localize text on earlier versions of iOS you will have to duplicate your Storyboards and XIBs for each language, or create outlets for all the controls and set their localized text values in code using
NSBundle.MainBundle.LocalizedString()
.There is another localized sample - TaskyL10n - which shows how to localize text elements directly and uses
MonoTouch.Dialog
.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.