6

I have an app that includes two languages: Arabic (Right To Left) and English (Left To Right), I used Base Internationalization with Auto Layout to make things simple and use one storyboard (base storyboard) for this purpose, however, because I live in a country where Arabic is the primary language I started to design my base storyboard with an Arabic interface (RTL), I checked the option "Respect Language Direction" for each horizontal constraint.
After I added English language from project settings, translated its storyboard strings file, and ran the app on an English iPhone (Settings -> General -> International -> Language -> English), the interface never changed to LTR, is stays as is (RTL), I tried to uncheck the option "Respect Language Direction" but to no avail.
However, if the scenario is opposite everything would work fine, i.e. if I designed the interface on the base storyboard with English language (LTR) the interface will flip to RTL when I run the app on an Arabic iPhone.

how can I tell the base storyboard that I'm designing an RTL interface so it should flip this interface to LTR when the iPhone's language is (for ex.) English ?

p.s. the testing environment was on Xcode 5.1.1 and iPhone 4S iOS 7.1

JAHelia
  • 6,934
  • 17
  • 74
  • 134
  • Have you tried with any other LTR or RTL language. Perhaps it is a bug ? What say ? – Abhishek Bedi May 19 '14 at 15:33
  • Can you provide us with a sample project that demonstrates the issue? I have a hunch that editing the project file directly might help with your issue, but I still have trouble generating a test case on my own that matches your situation. – Thomas Tempelmann May 28 '14 at 09:38
  • https://dl.dropboxusercontent.com/u/57066689/TestAutoLayout.zip the project's storyboard contains only 1 UILabel placed to the right of the screen (as i mentioned in the question, i always design my projects in Arabic UI first because my country's language is Arabic - RTL) with two constraints, try to change the simulator's language between Arabic & English, you will notice that the label is still in the right-hand-side in English and goes to the left-hand-side in Arabic. Note: the word "Arabic" appears as "العربية" in Simulator's Settings -> General -> International -> Language. – JAHelia May 29 '14 at 07:03
  • the problem is that the storyboard always understands the left edge of the label as the leading edge and the right edge as the trailing edge, this is true in English and all other LTR languages, but for RTL languages the leading edge is right edge and the trailing edge is left edge but the storyboard can't recognize this thing. – JAHelia May 29 '14 at 07:08

2 Answers2

1

Try this one.

setTextAlignment:NSTextAlignmentNatural

This will solve your problem it set RTL for language like arabic and set interface to LRT language like English.

Dharmesh Vaghani
  • 718
  • 6
  • 23
1

I believe "Respect Language Direction" depends on the currently set device language, as is suggested by Apple's documentation.

You might have better luck by manually setting the language detected by NSLinguisticTagger or using this method

The problem might also be that Xcode's storyboard editor is reversing the Arabic text while keeping everything as LTR (documented here), in which case you might want to use a separate editor to set the text, or set the text programmatically rather than in the storyboard.

Community
  • 1
  • 1
jaggedcow
  • 1,405
  • 1
  • 12
  • 23
  • Apple has resolved the reversed Arabic text bug in Xcode ... but still I didn't get the answer to my question – JAHelia May 28 '14 at 06:00
  • Have you tried changing the device language to see what effect that has? – jaggedcow May 28 '14 at 10:49
  • if i designed the BaseStoryboard with an RTL language and changed the device's language to an RTL language it will flip the interface, and if I changed the device's language to an LTR language it will not flip the interface. – JAHelia May 28 '14 at 10:56