0

I need to change the language of the app from English to Arabic and vice versa programatically from the app. I use xib files, not story boards. With lot of googling, I could force load the localisation strings. But the xibs do not reload to reflect the right to left allignment of Arabic language. Kindly help.

Edit: Or is there a way to reload the xibs? Or even restart the app programatically?

dinny
  • 17
  • 5
  • Are you trying to do it dynamically without relaunching the app or after changing and relaunching the app? What are your typical methods used to load the xib files? – Pradeep K Mar 21 '16 at 13:27
  • what do you mean by force lad the localisation strings ? – Teja Nandamuri Mar 21 '16 at 13:28
  • @PradeepK Yes. I have a settings tab, and there I need to give an option to change the language in a tableview. Once that language selection is done, the app needs to reflect the changes. I have no issues in relaunching the app internally too. – dinny Mar 21 '16 at 13:31
  • @TejaNandamuri Force loading the localisation strings from within the app. Not by the usual way of changing the phone language. – dinny Mar 21 '16 at 13:38
  • How did you try to check localisation strings without changing the device language ? – Teja Nandamuri Mar 21 '16 at 13:41
  • @TejaNandamuri I tried a method mentioned in [link](http://stackoverflow.com/questions/1669645/how-to-force-nslocalizedstring-to-use-a-specific-language) – dinny Mar 21 '16 at 13:43
  • @TejaNandamuri That helps to get the respective strings. But since it is Arabic, I need to change to right to left alignment of objects in xib. – dinny Mar 21 '16 at 13:44
  • are you trying in device or simulator? – techloverr Mar 21 '16 at 14:23
  • you need to refresh the outlets one-by-one. – holex Mar 21 '16 at 14:28
  • @techloverr I have tried on device and simulator. No luck. – dinny Mar 21 '16 at 14:33
  • @holex yes, but how? Any tutorials? Samples? – dinny Mar 21 '16 at 14:35
  • @dinny, imagination. you don't need any tutorial for that simple tasks. – holex Mar 21 '16 at 14:51
  • Please don't do this. This will never work 100% and also provides a very confusing user experience. Users expect their apps to follow the system language, and they certainly don't expect every single one of their apps to have a separate language selector with tons of options. – wakachamo Mar 21 '16 at 18:18
  • @wakachamo Yes, but these days there are lot of apps in the store that allows to change the language on the fly. My client requirement demands the same. – dinny Mar 22 '16 at 05:38
  • @holex imagination does not work :( – dinny Mar 22 '16 at 05:39
  • Since you're using XIBs, you can just use `[NSBundle -pathForResource:ofType:inDirectory:forLocalization:]` and load the NIB directly by hand. See duplicate question. It does require redesigning part of your app, but since you're already working with XIBs, it's probably not too massive. See also the NSUserDefaults option if you're willing to restart the app. – Rob Napier Mar 22 '16 at 12:54

0 Answers0