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.