My app is going to be made in both English, Arabic languages. I have made my xib using auto layout for english version. Now i want to use same xib for arabic version. But the problem is that interface will also change its layout from right to left.
I know about NSLocalization for xib's but i am clueless for arabic version, I googled last day but not found any thing relevant.
e.g. English version
Icon label
Arabic version
label Icon
Please put some light in how can i convert my english version of xib to be used in Arabic version.
Thanks
Use Auto Layout in your xibs. By default, the constraints created in Xcode's Interface Builder use Leading/Trailing properties, meaning all of the UI gets automatically flipped in RTL languages.
Like Leszek commented as well, you can check out Supporting Right-to-Left Languages for anything else.
Related
I'm using a custom font for English version of my app, before localizing for other languages, the font displayed fine, then I localized the app for Chinese, the custom font is replaced by system font when I run it, though it still looks right on the storyboard.
I set the font in storyboard, I think it's a easier approach as I have multiple view controllers using this font in different places, it'd be a little complicated to set font with code, here's the storyboard setting:
and info.plist:
localization:
So, what's wrong?
Problem solved by disabling localization of the font like this:
I would like to make an app using autolayout, such that when a device is configured in a right-to-left (RTL) language, the NSLayoutConstraints reverse the order of two views. I'm building the views programatically, without Interface Builder.
I am using leading and trailing constraints, and expect view A to be on the left and view B to be on the right. Once in RTL, I expect that order to be reversed, so that A is to the right of B.
I have added the RTL language to the localization list in the project Info tab.
Maybe I'm missing some project configuration. Where do I need to add the RTL language so that the project switches its layout according to the device language?
Note - I did try to change the "Localization native development region" in the Info.plist from "en" to an RTL language, and the constraints flipped. But this is not a solution because in this case it will always be flipped, even if the device language is in english.
Thanks in advance!
I am new to multi-language app.
What I am doing is,
an app with two languages.
English & Arabic
The language of the app depends upon the device language.
(I want to change this too, that app language should be controlled from inside the app. not device dependant but thats next question)
I am having some controls like UIButton,UITextField,UILabel, etc....
When my app is in English I gave these controls frame starting from left corner of device, and when my app is in Arabic I gave them frames starting from Right corner of device. (As arabic is written from Right - to - left)
My Question is,
For this purpose I need to do extra work,
i.e. check device language and then set the frames of control.
on each view I may have "n" number of controls, and giving the frame sizes to all controls for both language doesn't seems good from my view.
Is there anything available in Xcode itself by using which I can do this.
means I need to give frames for default language (i.e. English) and if my device language is change to Arabic then frames of Controls will be automatically Mirrored from Right to left.
Following screens may give some idea.
(I used different frames for all those controls checking device language)
Any help is accepted.
Thanks in advance.
sorry If question is asked already. But I didn't find anything.
If anyone found then link to that is Welcome :)
From Supporting Right-to-Left Languages:
Your user interface should be mirrored when displaying right-to-left languages. If you use base internationalization and Auto Layout, most of the user interface will appear mirrored automatically for you. The text direction changes to right-to-left with the exception of phone numbers and country codes which are always left-to-right. Some views and controls in your user interface may not change direction automatically which you can fix programmatically.
They functionality you're looking for is called Auto Layout which was introduced a few years ago by Apple. It will handle lots of things you need, but there's also a lot to do for you. The guide above will guide you through the necessary steps.
Update from iOS 9.0:
iOS 9 brings comprehensive support for right-to-left languages, which makes it easier for you to provide a flipped user interface. For example:
Standard UIKit controls automatically flip in a right-to-left context.
UIView defines semantic content attributes that let you specify how particular views should appear in a right-to-left context.
UIImage adds the imageFlippedForRightToLeftLayoutDirection method, which makes it easy to flip an image programmatically when appropriate.
To learn more about providing a flipped user interface, see Supporting Right-to-Left Languages.
My app supports both Arabic and English version and Autolayout handles alignment of text and UI elements. But a feature I need to add is a language switch button that immediately changes the language. I even need autolayout to adjust as per the language but doesn't seems to take effect unless the app is restarted. Any suggestions how to achieve this functionality.
I am making one application which can support English and Arabic language. My almost all code is done but now i am facing one problem that ,when i run application setting English language it looks great,but for arabic my UI get distrubed because English language has left allignment and Arabic has right allignment by default....what to do now ??please any one have idea then please help me.....waiting for reply
If it's about right align UI elements - use the Field.RIGHT style to have your components right align. It is left aligned by default. If you are using a HorizontalFieldManager you will also want to set the style for the scroll direction to be LEFTWARD.
To set the style pass in these in the components constructor OR'ed, so:
new myField(Field.RIGHT | Manager.LEFTWARD);
Use the Locale object to determine which language is currently set and set the alignment based on it.
APPROACH: Using third party library
Have a look at Arabic and English.
LWUIT UI library is pretty easy to create a common UI for both left-to-right and right-to-left languages. It might sound an uphill task now but going forward you will need to
support multiple ODM's
multipe screen device resolution
multiple flavors of VM, etc
LWUIT library resolves all these problems and to top it the library source code is licensed under GPLv2 with the classpath exception. This essentially means you can use this library in your commercial projects. It is supports most mordern Blackberry OS's.