Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIAccessibility default language throughout the app

We're working on an app that's localized only in the German language and want to add accessibility feature to it. Since the accessibilityLabels 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?

like image 254
zavié Avatar asked Jan 22 '14 13:01

zavié


3 Answers

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.

like image 66
zavié Avatar answered Oct 17 '22 01:10

zavié


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

like image 27
Mikkel Selsøe Avatar answered Oct 16 '22 23:10

Mikkel Selsøe


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.

like image 35
Julian Avatar answered Oct 17 '22 00:10

Julian