iPhone/iOS:如何判断手机在运行时使用的本地化版本?

发布于 2024-11-28 13:32:12 字数 346 浏览 0 评论 0原文

我在本地化应用程序时遇到了困难。它需要本地化为波斯语(伊朗波斯语)。不仅如此,当选择 fa_IR 作为本地化时,它还需要使用阳历。

该操作系统有一个波斯日历。我使用它没有问题,但我需要知道fa_IR本地化已被选择。雪上加霜的是,我无法在美国测试这个语言环境,因为 AT&T 似乎不允许将其作为本地化。我必须把它寄到伊朗,这是皇家PItA。

我在运行时找出本地化真是太痛苦了。有很多用于访问捆绑标志的东西,但我找不到任何用于获取运行时信息的东西。

我对 iOS 编程非常陌生,所以我仍然需要确定 RTFM 的 M 。我一直在用很多关键字搜索文档,但无济于事。

任何人都可以帮忙解决这个看似简单得荒谬的问题吗?

I'm having a difficult time localizing an app. It needs to be localized into Farsi (Iranian Persian). Not only that, it needs to use the Solar Calendar, when fa_IR is selected as a localization.

The OS has a Persian calendar. It's no problem for me to use it, but I need to know that the fa_IR localization has been selected. To add insult to injury, I can't test this locale in the US, as it seems that AT&T doesn't allow it as a localization. I have to send it to Iran, which is a royal PItA.

I'm having the devil of a time finding out the localization at runtime. There's a bunch of stuff for accessing the bundle flags, but I can't find anything for getting runtime info.

I'm pretty damn green at iOS programming, so I still need to determine which M to RTFM. I've been searching the docs with many keywords, to no avail.

Can anyone help with what seems to be an absurdly easy question?

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

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

发布评论

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

评论(2

写下不归期 2024-12-05 13:32:12

NSLocale将包含您需要的区域设置信息。请注意,基础类支持建议的设置,例如 24 小时时钟和区域设置信息。

NSLog(@"%@", [[NSLocale currentLocale] localeIdentifier]);

NSLocale will have the locale information you need. Do note that foundation classes support suggested settings such as 24 hour clock and locale information.

NSLog(@"%@", [[NSLocale currentLocale] localeIdentifier]);
墨小墨 2024-12-05 13:32:12
NSArray *localizations = [[NSBundle mainBundle] preferredLocalizations];
for (NSString *string in localizations) {
    NSLog(@"Localization: %@", string);
}

上面的代码应该有助于查找当前的本地化。

NSLog(@"%@", [[NSLocale currentLocale] localeIdentifier]);

NSLocale 返回 en_US,而 NSBundle 返回 sv,这对于我的手机来说是正确的。

NSArray *localizations = [[NSBundle mainBundle] preferredLocalizations];
for (NSString *string in localizations) {
    NSLog(@"Localization: %@", string);
}

The above code should be helpful in finding the current localization.

NSLog(@"%@", [[NSLocale currentLocale] localeIdentifier]);

NSLocale returns en_US, while NSBundle returns sv, which is correct for my phone.

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