UIImagePickerController language not changed - iphone

In my app used
[[NSUserDefaults standardUserDefaults] setObject:#[#"fr"] forKey:#"AppleLanguages"];
this func to change app language.
It working fine all labels,button and all other elements. but, it is not replicated in UIImagePickerController.
Language change when i kill and reopen the app.
pls any suggestion.
Advance thanks

You need to synchronize your NSUserDefaults and change it like this:
[[NSUserDefaults standardUserDefaults] setValue:#"fr" forKey:#"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
Next you need to use the macro :
NSLocalizedString(string, nil)
for the text inside your UIImagePickerController.

I change in Info.plist file string Localization native development region to my language, and then in app UIImagePickerController changed language. Maybe and for you it will work.

Related

iOS: override NSLocale language

If you have a localized version of your app in several languages but if the user is not using any of the languages the app is localize.
How to set a default language? Or what will be the best practice to define a default language in this case?
Here are the scenarios I was trying to tackle:
The application has be localize in en/fr/es but if language locale is not en/fr/es how you define a default?
In case the the language locale is either one of this en/fr/es and the user whants to use a different language define on there NSUserDefaults. Let's say is using english as NSUserDefaults but wants to use the fr localized version of the aplication. There is a way to overwrite the language on NSUserDefaults ?
write the NSUserDefaults before the apps start
question1 : you can set your prefer order as below.
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:#"de", #"en", #"fr", nil] forKey:#"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
Question2: force to use fr
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:#"de", nil] forKey:#"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
I'm finding this no longer works in iOS 9 (and probably 10). We have several targets in our code base. For a couple of them I always want it to come up in English even though localized strings may be present in the bundle.
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:#"en", nil] forKey:#"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
I have added the above code in main(). The first time the app runs it comes up in the user's chosen language. On subsequent runs it will come up in English as desired.
Can anyone confirm this doesn't work in iOS 9 and suggest an alternative? I'd rather not delete the other lproj entries if I don't have to.

How to implement instruction view for iPhone app

I have 2 pages that I want to show as instructions the first time the app is run. How would I accomplish this?
You can utilize NSUserDefaults for something like this.
if(![[NSUserDefaults standardUserDefaults] boolForKey:#"didLoad"]) {
//Show your instructions
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:#"didLoad"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
What this does is, check if the didLoad bool is FALSE (Which will be on first Load), if it is you show your instructions and set the BOOL to YES for the next Launch. You can put this in your viewDidLoad method.

Registration form on an iphone application

I have an application developed using iOS5. I have used the storyboard to design the whole screens. The problem I am facing right now is that, when the user runs the application for the very first time, I have to show a view for the user to register. I have no clue on earth on how to do it. I have created the registration forms on the storyboard itself.
Can someone put some light on this issue please?
Thankx in advance.
Try this (and also check this):
Set a value after the user starts the application:
[[NSUserDefaults standardUserDefaults] setValue:[NSNumber numberWithInt:1] forKey:#"registered"];
[[NSUserDefaults standardUserDefaults] synchronize];
and then check with this:
NSNumber *numb=[[NSUserDefaults standardUserDefaults] objectForKey:#"registered"];
if ([numb isEqualToNumber:[NSNumber numberWithInt:1]]) {
NSLog(#"registered");
}else{
NSLog(#"not registered");
}

Change application settings through settings bundle while application is running IOS

I have written code in -(void)applicationWillEnterForeground:(UIApplication *)application , but my application is not detecting the change made in the settings bundle, new settings work when application restarts, someone please help me how to make changes in application's settings while application is running
Try to -(BOOL)synchronize; the NSUserDefaults.
After setting the values in NSUserDefaults try calling [[NSUserDefaults standardUserDefaults] synchronize]; so that the values get written to disk.
in your applicationWillEnterForeground: methode after this line
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults], add this line
[defaults synchronize];

Language change after selecting a option from the drop down list in iphone

I was working with language localisation .I want to change the language of my application whenever i select a language from a drop down list which is present in my application , that is it should change the language without changing the language of device .please suggest me how can i implement
Thanks in advance
Have a look at this: How to force NSLocalizedString to use a specific language
You can do this, but it won't play nicely with the built in localization functions in Foundation (e.g. NSLocalizedString), so you'll need to ignore them and write your own string-getting function, XIB-loading path, etc.
The question and answer here covers how to access localizations in the bundle on the fly like this:
Overriding preferred strings localization on the fly for testing
You can force the "AppleLanguages" user default.
The example below shows how can be done; in particular here I'm switching the first (default) with the second language.
NSArray *lang = [[NSUserDefaults standardUserDefaults] arrayForKey:#"AppleLanguages"];
NSLog(#"current lang: %#",lang);
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:
[lang objectAtIndex:1],
[lang objectAtIndex:0],
nil]
forKey:#"AppleLanguages"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSMutableArray *languages = [NSMutableArray arrayWithArray:[defaults objectForKey:#"AppleLanguages"]];
[languages replaceObjectAtIndex:0 withObject:#"fr"];
[defaults setObject:languages forKey:#"AppleLanguages"];
[defaults synchronize];
This is setting the language to French. Just put on position 0 what language you want to be loaded.