Community

Topic: Xamarin component

Translate iOS info messages

Bastian Buchholz
Monday, August 14, 2017

Hello,
is it possible to translate the info messages displayed by pikkart?
For example the "enable location services" message?
Screenshot: https://goo.gl/hg79t3
Regards
(Same as https://goo.gl/xv4b7d but for iOS)

user profile image
Support Team  (expert)
Wednesday, August 16, 2017

Hello,
with the actual version we didn't translate some text yet, but you could translate key strings contained in the Localizable.strings file, that should be inserted in your localizable folder. This is an example of Localizable.strings file:

"App needs permission to use the camera, please change privacy settings" = "App needs permission to use the camera, please change privacy settings";

"Attention" = "Attention";
"Attivare servizi di localizzazione da Impostazioni per poter utilizzare l'app" = "Attivare servizi di localizzazione da Impostazioni per poter utilizzare l'app";
"Cancel" = "Cancel";
"Impostazioni" = "Impostazioni";
"Servizi di localizzazione non disponibili" = "Servizi di localizzazione non disponibili";
"Settings" = "Settings";
"Unable to start camera" = "Unable to start camera";

In order to localize enable location service message info (due to a missing localizable macro), you should override this CLLocationManager delegate method, inside PKTGeoMainController subclass:
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {

CLLocationManager * clLocationManager=[self valueForKey:@"locationManager"];
if (status == kCLAuthorizationStatusNotDetermined) {
if ([clLocationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[clLocationManager requestWhenInUseAuthorization];
return;
}
}
if (status == kCLAuthorizationStatusAuthorizedWhenInUse ||
status == kCLAuthorizationStatusAuthorizedAlways) {
[clLocationManager startUpdatingLocation];
}
if (status == kCLAuthorizationStatusDenied ||
status == kCLAuthorizationStatusRestricted) {
NSLog(@"servizi di localizzazione disabilitati");
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Servizi di localizzazione non disponibili",nil)
message:NSLocalizedString(@"Attivare servizi di localizzazione da Impostazioni per poter utilizzare l'app",nil)
preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Ok",nil) style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action)
{
exit(0);
}]];
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Impostazioni",nil) style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}]];
[self presentViewController:alertController animated:true completion:nil];
}
}

Best,

Bastian Buchholz
Sunday, August 20, 2017

Thanks, but I am not sure how to implement this with Xamarin.
There is no method I could override and ValueForKey(new NSString("locationManager")) always returns null.
Regards

Sign in to add a comment