How does waze change objects location with their localization? - ios

The first image is when the language is set to Hebrew, the second is in English. Look at the word " Thanks: " in the image. How Waze managed to change the location of the word to a Right To Left language? With regular localization
Thanks:x
should have been
תודות:X
That's just one example. Waze does that a lot.
Waze supports iOS 4.3 and later so AutoLayout is out of the question. With regular localization I know you can change the content of the word but location? that's a first.
Can I set an if iphone language is English then change the layout to..? (if so that's a lot of ifs.."
Thanks

Frankly, I do not know if there is any standarized way of doing that.
But I see several options:
1. Using localized .xib files or even full storyboards.
2. Changing that programmatically. Get the current localization and add some IFs to the view controller and re-arrange the items. If this is in a custom UITableViewCell subclass then overwrite the layoutSubViews (or so) and change the layout accoring to the locale settings. If you layout it within cellForRowAtIndexPath then apply the localization there.

Related

Is it possible to remove a UILabel from localization?

Hello localisation pros,
after searching the various tutorials, tipps and tricks around "Localization" and of course this stackoverflow forum, I have to commit, that I did not find a good answer. Thats why I post my problem here and hope for an answer.
I have two types of UILabel in my Storyboard. And I have plenty of each type in the app.
One type contains text, that is not necessary to localize, because it is just an integer (e.g. "5"), or an emoji or it is just an international word (e.g. "Computer").
And of course I have the other type of UILabel in my app, that contain text, that must be localized.
When exporting for localization, ALL UILabel in the Storyboard will be put in the localization files by xCode and makes the file bigger than necessary, since plenty of the UILabels belong to type 1.
Is there any way, to take out these UILabels from the localization process and to mark them as "not necessary to localize" ??
Thanks for helping.
You need to manually remove the each label entry from localize file as Xcode localize whole storyboard not single one or you can create xib of each viewController the you can localize each viewController .
Thanks
Change them to attributed and they won't get exported.

iOS is there a way to assign Localized String to a UILable from IB/storyboard

I want to assign NSLocalizedString(key, comment) to a UILabel from storyboard without creating an outlet for it.
Just select your storyboard/xib, go to File Inspector. In the Localization part, you can tick the language you want. Then, it will create a .string file with all text used in storyboard. You'll just have to provide a translation for each text used in storyboard.
If no language appear in this part, you have to change values of Localization native development region in Info of your project.
This might help, the official Apple guide to translating storyboard texts. I found it pretty straightforward. I am currently translating texts in-code, in the storyboard and in my info.plist files without issue. Hope it helps!

Possible to hide a button on particular language in iOS with base localization?

I'm new to localization. I've got my app mostly converted, but I have a case where a button only appears in the US English version of the app, but no other languages. Is this possible using main.strings and localizable.strings?
Jakub Vano's answer is pretty useful, but also you can set that string with a special value as "notToShow" and do this
if ([NSLocalizedString(#"MyString", nil) isEqual:#"notToShow"]){
//hide button
}
If we are talking code, you can check current locale via
[[NSLocale currentLocale] localeIdentifier]
and show / hide button accordingly. If you are using storyboard / xib, you can have separate interface for each localization.

Creating Right to Left user interface for iOS

As per apple documentation
"iOS doesn’t automatically mirror controls, so if you want this behaviour for an iOS app, subclass the control and override the drawing methods."
I want to mirror my whole UI when the user selects the language as Arabic or hebrew in the home screen. i was searching for tutorials and documentation for the same but nothing helps.
Please find what i have done till now:
am using Xcode 6.1 and the app targets from iOS 7 to iOS 8.1.
Autolayout is enabled and am not using left or right constraints. am using only leading or trailing constraints.
Base internationalisation is enabled in project settings also have added the languages in localization. but when am running the app in device and set device language and region to arabic i cant get the mirrored UI. Do i have to do anything in code to get the mirrored UI?
What is the best way to support RTL based UI? How to subclass control and override drawing methods?
Please use this link to get the sample screenshot of my app.
I just found a easy way from Apple documentations instead of having 2 storyboards for RTL and LTR languages.
First of all enable Base internationalisation in project settings
Add your language - in my case i have added arabic and hebrew
xCode will localize your stroy boards and you can see different storyboard strings for different languages
Change the texts for your labels in the newly created strings file. In my case i changed in arabic and hebrew string files
Use AutoLayout for designing the whole UI.
Don't use Left or right constraints. Instead of use only leading and trailing constraints
Add the below code in your main function and run the app in simulator
NSArray* languages = [NSArray arrayWithObjects:#"ar", nil];
[[NSUserDefaults standardUserDefaults] setObject:languages forKey:#"AppleLanguages"];
Your app now will work for RTL language with mirrored UI without having 2 storyboards.
Note : if you are not setting the autolayout constraints correctly it wont work. However because of the new screens you have to learn to use auto layout.
in Swift
let languages = ["ar"]
UserDefaults.standard.set(languages, forKey: "AppleLanguages")

Default Xib get loaded instead of desired Xib?

In my Application I enabled the Localization for spanish Language . Sources like strings, Plist, Images etc are working fine without any problem except the xib files.
Instead of the xib of selected Language(spanish in my example) the View controller load default xib file
below is my bundle
And the screen shots of english and spanish Xibs respectively
EditViewController.xib(English)
EditViewController.xib(Spanish)
As seen in the above images I have translated the texts(in xib) into spanish for spanish xib
But the viewcontroller is loading same xib(default one) for both language. Help me to Show the desired xib.
Note:-
The Save Button on the top left corner change it's text to the selected language(I set the identifier type of that UIBarButtonItem to "save")
I think u have to change the language of your ipad or ur iPhone.
Your app should dettect that language and display the desired xib, on "EN" or "ES" folders.
The default folder that ios will use, is "EN" (English), so u can try to swap all files on "EN" to "ES" language.
Other opcion, is to use same xib for both languages, and use NSLocalizedString instead making 2 xibs.

Resources