开发者

Adding custom language to the iOS app

I need to add a custom language (iOS has no localisation for it) among with support languages. A user is able to choose desired language in app settings (built-in screen, no in Settings app). I store it to NSUserDefaults:

[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObject:@"lv"] forKey:@"AppleLanguages"];

Next time, when the app starts, it loads with selected language. And works great.

But here is a 'small' issue. The app needs to be restarted. Thus, I need a way to quit the app.

I don't want to add UIApplicationExitsOnSuspend to Info.plist, because usually the user won't switch languages, thus, I want the app typically goes to background and resumes, when a user comes back.

I know, I am not allowed to kill the process with exit(). Thus, I imagine maybe it is possible to set UIApplicationExitsOnSuspen开发者_JS百科d at runtime? Scenarios will be similar to this: A user sets desired language and confirms it. The app sets UIApplicationExitsOnSuspend (or do something similar to it). The app instructs a user to quit the app by pressing Home button.

Of course, I may instruct a user to quit the app, by killing the process (go to Home screen, double click Home button, tap and hold an app icon, tap the minus). But it looks to complicated and annoying.

Maybe you have another suggestions, how to add to an app ability to switch languages?


I have achieve in-app language switch by implementing my own string bundle.

Source is available here: https://github.com/amjaliks/ObjCAdditions/tree/master/Source/Classes

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜