1

I have a picker view which I want it to change the language of the app, I have localized my app with 3 languages and it switches to different languages when I change device language but how can I use the picker view to change the language of the app ?

enter image description here

I'm using Xcode 7 and swift 2.1

Veve
  • 6,643
  • 5
  • 39
  • 58
anonymox
  • 419
  • 1
  • 9
  • 32
  • Sorry! i want to add this as comment but due to insufficient points i'm not able to do that. Yes, you can change the app language manually. there are so many repositories on GitHub also, like [Swift friendly localization and i18n with in-app language switching](https://github.com/marmelroy/Localize-Swift) by @Roy Marmelstein – Anand Kore Apr 27 '17 at 13:05
  • Possible duplicate of [How can i change the localization programmatically by swift](http://stackoverflow.com/questions/29985614/how-can-i-change-the-localization-programmatically-by-swift) – Anand Kore May 19 '17 at 06:47

1 Answers1

1

Short answer: You can't. The system is starting your localized app according to the device settings, which you cannot override.

Side note: If you opt to not use any localization features provided by apple and implement everything yourself, you may provide whatever means to change your own language setting in-app. But that is a real pain and you are likely to make mistakes, not taking into account anything.

If you want to go down that road, see semanticContentAttribute to help with problems regarding RTL languages.

Also, please note that this might become a problem in review. Most apps should not need to reinvent the wheel here.

Tobi Nary
  • 4,566
  • 4
  • 30
  • 50
  • Thanks for answer but I have to implement manual language selection for my app, I need to know how to connect the picker view to those string files, I mean how can i find out which language is selected and how it detect from string files. – anonymox Feb 20 '16 at 11:46
  • You should not use any of apple's localization features. Parsing string files at run time is not a one-liner, parsing json is. Consider using json as the backing of your self-rolled `NSLocalizedString()` method. Prepare for a lot of work and maybe a rejection from the store. – Tobi Nary Feb 20 '16 at 11:55
  • Oh and if you do not know and cannot figure out how to use a `UIPickerDelegate`, you might want to reconsider reimplementing all localization features. – Tobi Nary Feb 20 '16 at 11:57
  • Thanks for your answers. – anonymox Feb 20 '16 at 13:00