7

Hello I want to convert my whole UI view to arabic [from Right to left] If user change his language from settings and open App.

I have below query

1) Is i need to create separate UI for Each? 2) Is there any short way to achieve this? 3) I need complete UI to be transform like mirror which is from left side [slide menu] to be from right side etc... 4) Xcode 8.2 have autoresize again introduce with auto layout can i do this without auto layout?

Community
  • 1
  • 1
9to5ios
  • 5,319
  • 2
  • 37
  • 65
  • 3
    If you're using auto-layout, and properly using "leading" / "trailing" edges/margins rather than "left" / "right", you just shouldn't have to do anything at all (except check that all text properly fits where needed). – jcaron Dec 28 '16 at 17:35
  • i am just using autoresize... Xcode 8.2 enable it again – 9to5ios Dec 28 '16 at 18:14

1 Answers1

1
  1. No, you create only one UI regardless of language.

  2. yes there is a short way, you have to use localisation. apple doc for internationlization

  3. the UI transformation is done by iOS(that's true for uikit controllers only. see edit below)

  4. auotlayout has nothing to do with localisation. generally, its better to use autolayout, outherwise you have to calculate for different screen sizes. again it has nothing to do with localisation. see edit below.

edit: if you want to mirror your own views e.g., uiimage and uilabel. then you have to do it yourself either with autolayout or with frames. if you are using uinavigation or tabbarcontroller, these controllers will be mirrored by iOS. so you have to take care of the content views yourself. you can generate different constraints and install it accordingly during runtime. but if your views are very complex then you should design 2 different storyboards one for left-to-right and one for right-to-left, and load the appropriate storyboard during the app launch.

re-edit: so here is my app in english. and my app doesnt support right-to-left languages

english

now if I add, say right-to-left language like arabic: arabic

as you can see table cells are transformed by iOS automatically. and I have just added internationalisation for arabic beside english, german and so on. so if you use UIKit controls in appropriate places then it will transform automatically. But if your app is very customised and has complex view hierarchy, then iOS can't help then you have to do your it self. if you stick to standard and simple hierarchy. then you should not worry about it too much. just test it and see it for youself.

so in my app for example, all i have to do is translate the string into right-to-left language.

edit: here is the correct information apple doc regarding question number 4

Use Auto Layout to lay out your views relative to each other without fixed origins, widths, and heights, so that views reposition and resize appropriately when the language or locale changes. Auto Layout makes it possible to have one set of .storyboard and .xib files for all languages.

Hashmat Khalil
  • 1,826
  • 1
  • 25
  • 49
  • hey thanks for the answer, but just to know, my all work is done with autoresize , if i now apply internationalisation in it , will it transform the UI automatically? even if some part is added programatically? Suppose a label is added at the fdeviceheight-100 and fdevicewidth-50 position? will it convert automatically at 100 and 50 ? – 9to5ios Jan 29 '17 at 13:52
  • I have added additional explanation. – Hashmat Khalil Jan 29 '17 at 15:07
  • 1
    "auotlayout has nothing to do with localisation" - false. As pointed in comments to the question, using leading/trailing instead of left/right will cause the UI to mirror if device language is right-to-left. This is the behaviour of native apps and everyone should do it too. – hybridcattt Feb 01 '17 at 20:50
  • @hybridcattt thanks for pointing out. Yes I was wrong and edited my answer with link and quote from the documentation. – Hashmat Khalil Feb 03 '17 at 14:11
  • 1
    @HashmatKhalil "But if your views are very complex then you should design 2 different storyboards one for left-to-right and one for right-to-left, and load the appropriate storyboard during the app launch." - You actually should never do that. If all your views are auto-layout, there's no need for if-else stuff at all :) – hybridcattt Feb 03 '17 at 14:13
  • 1
    yes that one is contradictory to my own answer see number 1. for redesigning GUI for other languages one should have strong reasons like Japanese for example. if you like to have top-to-down direction. in that case that whole layout will change. then it might be clever to do new interface with different layout. – Hashmat Khalil Feb 03 '17 at 14:21