I understand how to localise an app and that the language displayed is based on the users language / region choice in their phone's settings.

My question is, what if I want to let the user choose the language in the app itself, rather than default to what is set in the settings (e.g have a screen where the user chooses a language).

Am I ok to take this approach ? And could I use the existing localisation process (i.e of having a plist with string and using NSLocalised string ?) somehow ?

Thanks !

有帮助吗?

解决方案

Of course you can do that. You can make a screen, sort of a settings screen where user gets to choose the language. You then take the selected language and store it in NSUserDefaults.

Then, you can make a static method that takes a string key as a parameter and based on the selected language returns the appropriate value from one of your language files.

其他提示

Thinking that your question does not have a simple yes or no answer, I am just responding to what I did.

Fist of all, it is good to start the localisation on the current environment settings. And it is sometimes good and advisable to allow further customization because not all aspects of localization is handled by the system settings.

I had the problems with number formatting and weights which might vary in certain locales. So my recommendation is to start with the given localization and allow the user to customize it. It is up to you to use the full system of locales determing strings, and layout parts based on the localization.

Was this what you wanted to know?

See my answer to: iOS - Could I change the localizable.strings content during runtime?

It describes how to do this and includes the code snippets.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top