Preview localized versions of strings-translated auto-layout XIBs - localization

I'm migrating away from one-XIB-per-locale to a single Base interface with Auto-Layout that is localized using .strings files.
How can I easily preview localized versions of my interface?
I'd like to see how my UI looks in German, Chinese and Arabic without having to change system-wide language preferences each time.
Selecting another language in Interface Builder's "Jump Bar" just shows me raw the .strings file source. IB's "Simulate Document" only shows me document in my current language.

You can launch application in a particular language with an extra argument:
Foo.app/Contents/MacOS/Foo -AppleLanguages '(de)'
However, that's not enough for Arabic, as it sets the language, but doesn't enable RTL layout:
app -AppleLanguages '(ar)' -NSForceRightToLeftWritingDirection YES -AppleTextDirection YES

Related

Swift Bar button item set to system item "save" ignores app language

In my app I have a bar button item in my top navigation bar. I have set the button system item to "Save" which will display the button as Save
But even if my phone has a different language set the button still shows up with the text "Save"- english when I start the app
The language that various UI components appear in your app is based on two things:
The device's list of languages under the "Preferred Language Order" section of the "Language & Region" page of the Settings app.
The languages supported by your app as defined by the localization bundles your app provides.
An app only supports a single language by default. To support additional languages you must add an additional bundle for each language and then provide appropriate localization resources such as strings files and localized storyboards, etc.
Based on your app's supported languages and the devices settings, UI components will appear in a single, chosen language.
Lets say your app supports English, Spanish, and Chinese.
Now lets say a user's device has the languages German and English, in that order, listed on the Language & Region screen.
Your app will appear in English to this user. Based on your question, you seem to expect the Save button to appear in German. But if your app doesn't support German, why have the Save button appear in German and the rest of the app appear in English? That would be confusing.
So now go back to the simple case. You have a basic app and you haven't done any localization yet. Your app only has the one bundle - the default language for your app. Lets say that is English. Since your app only supports English, it would be really confusing for the Save button to be in any other language while the rest of the app is in English. So no matter what language the user has set for their device, the Save button will be in the app's only language, English in this example.

Can't find the custom font in English language for iOS

I download a third party icon font file, and I drag it into my project and check the target. Everything is OK except when I change the Application Language using English. It show me the origin character but the icon.
Then I println all of the font families, that I can't find the icon font in English, instead in Chinese.
I don't know what happen.
Add in application info plist file this :

How to preview Storyboard in Xcode using Non-Base localisation

I have a Storyboard in Xcode 5.1 with a base Localization of English, and a second Localization in French.
When I'm using the Xcode Storyboard editor the strings are shown in English, as expected. Is there any way to make Xcode display the Storyboard in my other localization (French)?
I don't want to change Mac OSX's language, I'm hoping there's an option in Xcode somewhere.
EDIT: I have this in my resources folder
If I double-click Main.storyboard then the storyboard opens showing English (base language), as expected.
Is there a way to view Main.storyboard, but showing the text displayed in Main.strings?
EDIT:
I've since discovered (thanks to this tutorial) that there's a 'preview' option in Xcode. To get this, open the storyboard, click the 'assistant' editor, click the 'assistant editor menu button' (immediately to the right of the > arrow at the top left of the assistant window) and select Preview. This shows how the ViewController will look in landscape/portrait 568/480 high modes. Very handy, but still shows everything in English.
If only this'd let me select a localization, it'd be a great way to check the text layout works in different languages..
I believe that Xcode is not prepared to show localized storyboards in Interface Builder when using string files. However, it allows for you to convert formats quite easily. Select your storyboard file and in the utilities panel, select the language you want to preview:
Change the "Localizable Strings" to "Interface Build Cocoa Touch Storyboard":
You should now be able to select the French storyboard file and preview it within IB.
Once you are done, you can convert the file back to "Localizable Strings" reversing this procedure, or using your source code version control system. Then you can update the base file with any necessary adjustments, and verify it is to your liking using this method again.
Xcode 6 now includes a feature to do this.
From What's New in Xcode - New Features in Xcode 6:
Preview in Interface Builder. While designing in Interface Builder, the preview assistant can show how the interface appears in other languages. You can see how your interface responds to longer or shorter languages.
Hurrah!
Just click on you storyboard file and you can devellope it to show your Localization storyboard.
In Your case if you use the localization "base" option, you must see 3 storyboard file (one for "base localization", one for english and one for french).
Sorry for my english but i hope that help you.

Single language ios app

I have a project in Xcode 5.0 and I want to support only a specific language different from english, for intance, pt. When the project is created, it has "Use base internationalization" checked. A tried adding my language and removing english, then when I run the app on a device of that language (pt), everything is ok, the controls of a image picker, for instance, are localized. But, if the device's language is english or a different one (for instance fr), the controls are shown in english. How can I force the app to show all controls in my language (pt)?
Maybe it is noob question, but when I uncheck "Use base internationalization" I lose the storyboard, and when I try to check again it asks for files but no options are shown. How can I change the reference language of base internationalization?

Can localization be done only through Code and not directly in Interface Builder?

Does IB not allow one to specify a localized key for components that display text instead of hardcoding the value? For instance, if you want a UILabel to display internationalized text is the only way to do this via code? Seems like such a PITA to have to set all your label text in code when you have a nice WYSIWYG editor like IB. I think I had this feature back in VB5!
You actually don't normally need to write any code to localize your Interface Builder user interface (Xibs). What you do is create localized versions of these Xibs, with the help of XCode. In your XCode project, select a Xib, open the File Inspector (it's in the Utilities panel) and you'll see a Localization section in there. Click the + button and XCode will create a version for the language of your choice, which you can then localize by translating the text as well as resizing UI elements or do anything else you like.
The normal way in Cocoa/AppKit is to localize the files you want to exist in different languages. But probably the only files you want make localized are your nib/xib files and your strings files.
Clafou has explained how you localize the nib files.
The strings files are files which contain key-value pairs. By calling functions like NSLocalizedString you can query them with the key you've set.
Apple has documented all these features.
Nib files
Strings files

Resources