0

I am writing an iOS app, which operates in a multi-language environment. As a consequence the program can operate in a language different than the system language. The language can even be changed inside the App without restarting the app. So instead of using NSLocalizedString I am using a mechnismn like this:

- (NSString *)stringForLanguage:(NSString*)key
{
  NSString *path;
  if(prefLanguage == 0) {
    path = [[NSBundle mainBundle] pathForResource:@"de" ofType:@"lproj"];
  } else {
    path = [[NSBundle mainBundle] pathForResource:@"fr" ofType:@"lproj"];
  }
  NSString* str=[[NSBundle bundleWithPath:path] localizedStringForKey:key value:@"" table:nil];
  return str;
}

As I want to make my program accessible I wrote this little method to switch between german and french language :

- (void)setVoLanguage:(NSObject*)object
{
  if (prefLanguage == 0){
    [object setAccessibilityLanguage:@"de-DE"];
  } else {
    [object setAccessibilityLanguage:@"fr-FR"];
  }
}

I am using these method like this:

- (NSString *)accessibilityLabel {
  [appDelegate setVoLanguage:self];
  return [NSString stringWithString:[appDelegate stringForLanguage:@"UI_SPLIT_SLIDER"]];
}

- (NSString *)accessibilityHint {
  [appDelegate setVoLanguage:self];
  return [NSString stringWithString:[appDelegate stringForLanguage:@"UI_SPLIT_SLIDER_H"]];
}

My phone is running in English. The first one works fine, which means the value is read in German or French, whereas the hint is always read in English. I am confused.

So it works fine for accessibilityLabels and accessibilityValues, but not for accessibilityHints. Does anybody know how to set the language for accessibilityHints?

Thank you.

mschmitt
  • 169
  • 1
  • 6
  • According to the documentation, that should work. Are you using `NSLocalizedString` to be returned with `accessibilityHint` getter ? – A-Live May 08 '12 at 09:28
  • NSLocalizedString would only only localize my string for the current system language. As the app uses different languages, I am using a different mechanism. I will edit my question to make this more clear. – mschmitt May 08 '12 at 12:00
  • that's right, what i mean is - are you using anything alike by overriding the `accessibilityHint` getter ? – A-Live May 08 '12 at 12:22
  • @A-Live No, there is nothing more than I already have listed above. – mschmitt May 08 '12 at 12:27
  • It's hard to tell what's wrong with that code, my guess is that you're using a custom localization macros or a switch to distinguish the strings depending on the Locale-code. The confusing part is at `stringForLanguage:` parameter, the strings passed are obviously not language-codes but the accessibility-item keys. I believe you'll find an issue in the macros/code branch responsible for `UI_SPLIT_SLIDER_H` key or at Strings datasource, not in the iOs Accessibility SDK. – A-Live May 08 '12 at 12:40
  • @A-Live I doubt that, as the accessibilityHint is German or French text, just pronounced with the English speech synthesizer. So the language switch is o.k. Anyway, ... thank you. – mschmitt May 08 '12 at 12:54
  • Now I see the issue, you are getting the text but it is always spoken in English. Have you tried to force an app locale this way http://stackoverflow.com/questions/1669645/how-to-force-nslocalizedstring-to-use-a-specific-language ? – A-Live May 08 '12 at 13:22
  • Yes, same result. Labels and values are spoken using the correct language, whereas hints are always spoken using the system language. – mschmitt May 08 '12 at 15:42
  • Sorry friends, you did not have a chance to solve this problem. An Apple employee confirmed me it is a bug in iOS, which will be fixed soon. – mschmitt May 09 '12 at 11:44

0 Answers0