如何本地化辅助功能标签

发布于 2024-12-18 16:50:41 字数 119 浏览 3 评论 0原文

我正在研究 iOS 中的辅助功能。我似乎无法找到如何针对不同区域设置本地化标签。

如果我直接在界面生成器中的笔尖中输入标签,我是否只能通过本地化整个笔尖来本地化这些标签?或者有没有办法将它们导出到字符串文件?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

马蹄踏│碎落叶 2024-12-25 16:50:42

您问题的答案是,整个 nib(实际上是 xib)旨在针对每种语言进行本地化。有一种用于英语的 xib,一种用于西班牙语,一种用于日语,等等。

The answer to your question is that the WHOLE nib (or xib, actually) is meant to be localized per language. There's one xib for English, one for Spanish, one for Japanese, etc.

庆幸我还是我 2024-12-25 16:50:42

似乎可以使用 IBOutlet 以编程方式设置辅助功能标签,其方式与在 xib 中设置任何其他 UI 组件相同。

本地化的最佳实践/技术完全是另一个主题,但我们通常会尽可能避免本地化 xib(例如,确保设计有足够的空间来处理我们支持的语言之间的差异,避免图像中的文本等),依赖于NSLocalizedString 调整面向用户的(和/或用户可听到的?)副本。

It seems as though programmatically setting the accessibility labels could be accomplished in the same manner as setting any other UI component in a xib, using IBOutlets.

Best practices / techniques for localization is another topic entirely, but we generally avoid localizing the xib when possible (eg. ensuring that designs have enough space to handle the differences among the languages we support, avoiding text in images, etc.), relying on NSLocalizedString to adjust user-facing (and/or user-audible?) copy.

喜你已久 2024-12-25 16:50:41

您也可以通过编程方式完成此操作,不需要多个笔尖:

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

取自 辅助功能编程指南iOS

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文