- Retrieving language ID moved to HWUtils ios-revival
authorantonc27 <antonc27@mail.ru>
Tue, 20 Oct 2015 23:56:31 +0200
branchios-revival
changeset 11219 c51ecb9bcf05
parent 11218 08f20ffa5801
child 11220 32366eb83383
- Retrieving language ID moved to HWUtils
project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m
project_files/HedgewarsMobile/Classes/HWUtils.h
project_files/HedgewarsMobile/Classes/HWUtils.m
project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m
--- a/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Tue Oct 20 00:51:45 2015 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameInterfaceBridge.m	Tue Oct 20 23:56:31 2015 +0200
@@ -100,9 +100,7 @@
     CGFloat screenScale = [[UIScreen mainScreen] safeScale];
     NSString *ipcString = [[NSString alloc] initWithFormat:@"%d",self.port];
     
-    NSString *firstLanguage = [[NSLocale preferredLanguages] firstObject];
-    NSString *language = [[firstLanguage componentsSeparatedByString:@"-"] firstObject];
-    NSString *localeString = [[NSString alloc] initWithFormat:@"%@.txt", language];
+    NSString *localeString = [[NSString alloc] initWithFormat:@"%@.txt", [HWUtils languageID]];
     
     NSUserDefaults *settings = [NSUserDefaults standardUserDefaults];
 
--- a/project_files/HedgewarsMobile/Classes/HWUtils.h	Tue Oct 20 00:51:45 2015 +0200
+++ b/project_files/HedgewarsMobile/Classes/HWUtils.h	Tue Oct 20 23:56:31 2015 +0200
@@ -41,6 +41,7 @@
 +(NSInteger) randomPort;
 +(void) freePort:(NSInteger) port;
 +(BOOL) isNetworkReachable;
++(NSString *) languageID;
 //+(UIView *)mainSDLViewInstance;
 
 @end
--- a/project_files/HedgewarsMobile/Classes/HWUtils.m	Tue Oct 20 00:51:45 2015 +0200
+++ b/project_files/HedgewarsMobile/Classes/HWUtils.m	Tue Oct 20 23:56:31 2015 +0200
@@ -155,6 +155,12 @@
     return ((isReachable && !needsConnection) || nonWiFi) ? testResult : NO;
 }
 
++ (NSString *)languageID
+{
+    NSString *language = [[NSLocale preferredLanguages] firstObject];
+    return [[language componentsSeparatedByString:@"-"] firstObject];
+}
+
 /*
 +(UIView *)mainSDLViewInstance {
     SDL_Window *window = HW_getSDLWindow();
--- a/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m	Tue Oct 20 00:51:45 2015 +0200
+++ b/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m	Tue Oct 20 23:56:31 2015 +0200
@@ -37,9 +37,7 @@
     [super viewDidLoad];
 
     self.trPath = [NSString stringWithFormat:@"%@", LOCALE_DIRECTORY()];
-    NSString *firstLanguage = [[NSLocale preferredLanguages] firstObject];
-    NSString *language = [[firstLanguage componentsSeparatedByString:@"-"] firstObject];
-    self.trFileName = [NSString stringWithFormat:@"%@.txt", language];
+    self.trFileName = [NSString stringWithFormat:@"%@.txt", [HWUtils languageID]];
     // fill the data structure that we are going to read
     LoadLocaleWrapper([self.trPath UTF8String], [self.trFileName UTF8String]);