onesky / plugin-ios-ota

Over the air plugin
50 stars 8 forks source link

Strange issue #19

Closed stephenkopylov closed 8 years ago

stephenkopylov commented 8 years ago

In some cases, language setting in OneSkyOTAPlugin not working completely:

I set a language through "[OneSkyOTAPlugin setLanguage:]" to, for exapmle, "hi-IN" After that I tries to get some localizable string, and gets this message:

"OneSkyOTAPlugin - localized string not found for key: AVERAGE_INDICATOR_TITLE, locale: hi-IN, falling back to mainBundle"

After this, I tried to get this string directly from bundle ([NSBungle localizedStringForKey: value: table;]) and its works!

Code:

NSString *lang = [OneSkyOTAPlugin language:nil];  
NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"hi-IN" ofType:@"lproj"];  
NSBundle *myBundle = [NSBundle bundleWithPath:bundlePath];  
NSString *string = [myBundle localizedStringForKey:@"AVERAGE_INDICATOR_TITLE" value:@"" table:nil];  
NSString *string2 = OSLocalizedString(@"AVERAGE_INDICATOR_TITLE", nil);  
NSLog(@"\nOneSkyOTAPlugin language: %@\nBundlePath: %@,\nString from bundle: %@\nString from OneSkyOTAPlugin: %@", lang,bundlePath,string,string2);

And output:

OneSkyOTAPlugin language: hi-IN
BundlePath: /var/containers/Bundle/Application/DBD16C18-BBE9-44F1-A01D-55E4685FF42E/*******.app/hi-IN.lproj,
String from bundle: चलायमान औसत (right string)
String from OneSkyOTAPlugin: Скользящее среднее (wrong, falled back to system locale)

It's really hard to reproduce, but our QA does it like this: 1) Install release version of our app from appstore 2) Change language inside app 3) Remove app 4) Install debug version of our app from testflight/fabric 5) Change language inside app And after this issue started. From this point you can reinstall app, reboot your phone - nothing helps.

It's really strange problem, but our company faced it from time to time.

The question is - do you use "[NSBungle localizedStringForKey: value: table;]" for getting strings from specific locale?

bretdabaker commented 8 years ago

The plugin downloads translations from our server and keep them in a file in Document folder. However if no key can be found we will fallback to NSBundle.

We are investigating the problem, will keep you updated.

stephenkopylov commented 8 years ago

we will fallback to NSBundle

To mainBundle, or to [[NSBundle mainBundle] pathForResource:*\ ofType:@"lproj"]? Because falling back to mainBundle, without checking existed "language" bundle - it's slightly incorrect logic, I think.

We are investigating the problem, will keep you updated.

Thank you

bretdabaker commented 8 years ago

Fixed in 0.9.12