本地化 UIDatePicker“今天”标签
如何在UIDatePicker
的日期和时间模式下本地化标签“今天”?
我需要俄语,所以我设置了 UIDatePicker
语言环境,在设备设置中设置区域和语言,在 info.plist
中设置“本地化本机开发区域”和“本地化”属性改为“ru”,但没有任何区别 - 所有月份和日期标签都是俄语,但“今天”标签仍然是“今天”。
How can I localize label "today" in date and time mode of UIDatePicker
?
I need russian, so I've set UIDatePicker
locale, set region and language in device settings, set "Localization native development region" and "Localizations" property in info.plist
to "ru" but it did not make any difference - all month and days labels are russian, but "today" label is still "today".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在以下代码的帮助下,日期选择器中的所有文本都已本地化,包括字符串“Today”:
这里我使用 NSLocalizedString 将“en_US”(键)替换为适当的区域设置标识符(值)。这是在您需要添加的特定语言环境/语言的相应 Localized.strings 文件的帮助下完成的:
我在这里使用了意大利语(意大利)。
With the help of following code all the text in date picker got localized including the string "Today":
Here I am using NSLocalizedString to replace "en_US"(key) with the appropriate locale identifier(value).This is done with the help of corresponding Localizable.strings file for that particular locale/language in which you need to add:
I have used Italian(Italy) here.
通过创建本地化资源 .xib 解决了问题(只需使用 datePicker 将 IB 中的本地化添加到 .xib 中,不执行任何其他操作)。
有人可以解释为什么吗?
Problem was solved by creating localized resource .xib (just add localization in IB to .xib with datePicker and do nothing else).
Can someone explain why?
是的,本地化有两个组成部分。第一个是 strings.lproj 文件,其中包含每种语言的键值对,第二个同样重要的是本地化的 xib 或故事板。这两个文件由 Xcode 自动链接到彼此。因此,在您的情况下,需要 ru.lproj localized.strings 文件以及本地化的俄语 Xib 文件。
Yes, there are two components to localization. the first is your strings.lproj fie which contains your Key-value pairs for each language, and the second, and equally important is the localized xibs or storyboards. These two files are automatically linked to each other by Xcode. So, an ru.lproj localizable.strings file is required as well as a Localized Russian Xib in your case.