We're working on an app that's localized only in the German language and want to add accessibility feature to it. Since the accessibilityLabel
s are in German, it would be great to always read it in German, regardless of what the user's default system language is.
I noticed one can set that with the accessibilityLanguage
property. But it needs to be set on each control repeatedly.
Is there any way to set the accessibility language once globally for every control in the app?
Just found out a way shortly after posting the question! :)
You can set accessibilityLanguage
directly on UIApplication
in AppDelegate
. For example, in application:didFinishLaunchingWithOptions:
,
application.accessibilityLanguage = @"de";
And it will be applied to all the controls. Tested on iOS 7.
You can make a category on NSObject in a header file like this:
@implementation NSObject (Accessibility)
- (NSString *)accessibilityLanguage {
return @"de";
}
@end
Then consider importing it in you prefix header (.pch file) so you don't have to import it everywhere you need it
You can do it by inheritance, and use your customised components which by default would have this value set in the way you want. But probably in the existing project it won't be so easy and quick to apply.