Skip to content

Instantly share code, notes, and snippets.

@ronkorving
Created January 28, 2015 07:20
Show Gist options
  • Save ronkorving/919774edae27631b2ece to your computer and use it in GitHub Desktop.
Save ronkorving/919774edae27631b2ece to your computer and use it in GitHub Desktop.
Extracting iOS system language for Unity in Assets/Plugins/iOS/GetSystemLanguage.mm
#include "UnityAppController.h"
/*
* This Plug in will set a "systemLanguage" string key in PlayerPrefs with the system language code.
*/
@interface GetSystemLanguage : UnityAppController
@end
@implementation GetSystemLanguage
- (void)preStartUnity
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
NSString *currentLanguage = [languages objectAtIndex:0];
[[NSUserDefaults standardUserDefaults] setObject:currentLanguage forKey:@"systemLanguage"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (void)shouldAttachRenderDelegate
{
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment