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?
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.
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.
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.
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+
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With