I am currently working on Localization. I have my app in English and Arabic. When I change the Language to Arabic all object goes to right, but there are few objects that i want them to be in left. Could please tell how to disable that function on a specific object?
Try setting the semanticContentAttribute property for the particular view to forceLeftToRight
someView.semanticContentAttribute = .forceLeftToRight
You can find more about it semanticContentAttribute in apple docs
Related
UIActivityController view is not supporting rtl. I have set UIView.appearance().semanticContentAttribute = .forceRightToLeft in AppDelegate. If device language is English ActivityController is still opening in leftToRight instead of RightToLeft.
It is working fine with device language is Arabic.
Even I have tried to make activity controller view to rightToleft but no luck.
Should be rightToLeft.
You need to add languages in localisation section under info section in Xcode.
for more details checkout this link
output:
I am using googlecast example.
When I show GCKUIExpandedMediaControlsViewController, all the buttons are in the correct position.
But when I use this part of the code, the buttons overlap each other.
UIView.appearance().semanticContentAttribute = .forceRightToLeft
I don't know if this is important, but the language in the iPhone settings - English.
This is the result that I get
We don't support RTL well now. You can file a feature request here https://developers.google.com/cast/support
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.
I am creating an app that will be in English and Arabic. I am using my own localization system because I want to allow users to switch languages themselves from within the app and while the app is running (I am not aware of a way how to do this official Apple way). I would like to switch entire app to right-to-left when user picks arabic language, i.e. switch trailing and leading, text alignment etc.
Is this even possible?
EDIT: I am targeting iOS 7+
Yes, this is possible. From what I am understanding you want to move all of your components to the opposite side and also the text should be written from the right, right?
First of all, you have to set your language to the "AppleLanguage" key in user defaults:
NSUserDefaults.setObject(["ar"], forKey: "AppleLanguage")
Then you have to use auto layout. By default auto layout detects the region depending on the language chosen and when you've set leading and trailing spaces correctly, it will change the position of your text fields for example. If you want some of your components to stay on the same place, you have to use "left" instead of "leading".
If you need to change the direction of app to LTR & RTL then you could use that solution.
//FOR RIGHT TO LEFT
UIView.appearance().semanticContentAttribute = .forceRightToLeft
//FOR LEFT TO RIGHT
UIView.appearance().semanticContentAttribute = .forceLeftToRight
Hope this will solve your problem.
Reference: https://stackoverflow.com/a/48963618/8809657
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.