Hi there
Is there a way to know what’s the iphone language setting? I use it for my iphone apps to automatically enable the users language if available but I have no clue how this can be done with unity.
Joaquin
Hi there
Is there a way to know what’s the iphone language setting? I use it for my iphone apps to automatically enable the users language if available but I have no clue how this can be done with unity.
Joaquin
yes thats possible to find out through using the corresponding iOS native function in a plugin.
within unity: no
Actually you don’t need any plugin, you can get the language of your device with player prefs, simply put this in xcode, overwriting the previous function with this one
- (void) applicationDidFinishLaunching:(UIApplication*)application
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
NSString *currentLanguage = [languages objectAtIndex:0];
[[NSUserDefaults standardUserDefaults] setObject:currentLanguage forKey:@"language"];
[[NSUserDefaults standardUserDefaults] synchronize];
printf_console("-> applicationDidFinishLaunching()\n");
[self startUnity:application];
}
And then get the language in any unity script with
var languageString : String = PlayerPrefs.GetString("language");
would be wiser to have a function that gets this and returns it directly and put that in an own mm file
I agree with you in some points dreamora, but maybe beacuse I’m a programmer this solution is enough for my needs. Having a single string in memory won’t be a big deal.
Of course a plugin with a postprocess build that handles the code each time you make a new build is a better option, but is good to know more different ways to do the same thing