Search code examples
objective-ccocoalocalizationarabicbidi

Current Text Direction (BiDi support) in Cocoa?


I recently received an Arabic translation for my app, but would like to do more than simply replace the strings. I can re-layout most of the NIBs with Interface builder, but there are a few things that I need to do programmatically.

  1. Is there some way in Cocoa to figure out if the current locale is a RightToLeft locale, or do I just have to check to see if the current locale is Arabic or Hebrew?

  2. I have been searching for any "Bidi" articles or information for Cocoa apps for a while now, but without much luck. Any suggestions?

Thanks.


Solution

  • In 10.6, see -[NSApplication userInterfaceLayoutDirection]. For earlier releases, no explicit support, so yeah, you could just look for specific locales.

    You can do a respondsToSelector check to use -userInterfaceLayoutDirection on any system on which it is available.

    See the AppKit release notes for this and other changes.