Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to localize an accessibility label

I'm researching accessibility features in iOS. I can't seem to find how you localise the label for different locales.

If I enter labels directly into the nib in interface builder, can I only localise these by localising the WHOLE nib? Or is there a way to get these exported to a string file?

like image 650
Niall Mccormack Avatar asked Nov 29 '11 12:11

Niall Mccormack


People also ask

What is accessibility label?

For a text input field, its accessible label would be a short description of the data the field collects. For a control that is a group of options, such as a drop-down menu or list of radio buttons or checkboxes, the group should have a label that describes the relationship of the options.

How do I localize in Swift?

Now, to add new languages, go to your project's settings, under the Info tab, click on + to add a new language, and select the files you want to localize. Your file is now localized. You can select in wich language you want to write by selecting the localized Localizable.

How do I localize an iOS app?

Select your root project file, and then proceed to the project panel. Find the Localization section section, click the “plus” (+) icon, and add the desired languages. Select only the Localizable. strings file for localization.

What is Accessibilitylabel in iOS?

A succinct label in a localized string that identifies the accessibility element. iOS 3.0+ iPadOS 3.0+ Mac Catalyst 13.0+ tvOS 9.0+


1 Answers

You can also do it programmatically, no need for multiple nibs:

@implementation MyCustomViewController
- (id)init
{
  _view = [[[MyCustomView alloc] initWithFrame:CGRectZero] autorelease];
  [_view setIsAccessibilityElement:YES];

  [_view setAccessibilityTraits:UIAccessibilityTraitButton];
  [_view setAccessibilityLabel:NSLocalizedString(@"view.label", nil)];
  [_view setAccessibilityHint:NSLocalizedString(@"view.hint", nil)];
}

Taken from the Accessibility Programming Guide for iOS

like image 154
Olof_t Avatar answered Oct 07 '22 00:10

Olof_t