How to localize the availability label

I am studying accessibility features in iOS. I cannot find how you localize the shortcut for different locales.

If I enter labels directly into nib in the interface builder, can I only localize them by localizing the WHOLE nib? Or is it possible to export them to a string file?

+6
source share
3 answers

The answer to your question is that WHOLE nib (or xib, actually) is designed to be localized into each language. There is one xib for English, one for Spanish, one for Japanese, etc.

+6
source

You can also do this programmatically, no need to use multiple tips:

@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)]; } 

Adapted from Accessibility Programming Guide for iOS

+6
source

It seems that programmatically installing accessibility shortcuts can be done in the same way as installing any other user interface component in xib using IBOutlets.

Best practice / methods for localization is another topic, but we generally avoid xib localization when possible (for example, ensuring that projects have enough space to handle the differences between the languages ​​we support, avoiding text in images, etc. .)., relying on NSLocalizedString to set up a copy facing the user (and / or user).

+2
source

Source: https://habr.com/ru/post/902644/


All Articles