Nick Ginanto
Nick Ginanto

Reputation: 32170

Cancel automatic RTL flip with autolayout when doing localization

I added a RTL language (hebrew, arabic, etc) for localization in Xcode, and to my surprise (or not) some of the xibs got flipped to right-to-left design. That is indeed a great feature, but I don't want it..

How can I force Xcode not to flip the views, and only flip the view I choose instead? (or go over them gradually, to make sure they are ok)?

Upvotes: 0

Views: 1795

Answers (2)

Ryan Brodie
Ryan Brodie

Reputation: 6620

I don't think the accepted answer is the reality in the real world, in some cases you may wish to force LTR even when localising for RTL languages (edge cases, people!).

You can do this on a view-by-view basis by selecting it within your Interface Builder file and going to Utilities → Attributes and setting View → Semantic to Force Left-to-Right,

enter image description here

Upvotes: 6

user242849
user242849

Reputation:

I'm afraid I'll have to answer your question with another question... why would you not want that?

Right-to-left languages are expected to have right-to-left UI. The notions of forward and backward, leading and trailing are generally flipped when it comes to Right-to-left languages.

I would highly recommend you keep your UI flipped for these languages because this is what users expect; it's the best experience you can provide for Arabic, Hebrew, and other RTL languages.

In any case, if you do run into a case where the directionality must remain the same for any language: I'm assuming you're using Auto Layout/constraints since you're mentioning xibs and automatic flipping — all you have to do is change the constraint types from Leading to Left and Trailing to Right. 'Left' and 'Right' are still the same in RTL, as opposed to Leading and Trailing.

Upvotes: 2

Related Questions