iOS寻找区域特定的.lproj目录(例如en_US.lproj)? [英] Does iOS Look for Region-Specific .lproj Directory (e.g. en_US.lproj)?

查看:1834
本文介绍了iOS寻找区域特定的.lproj目录(例如en_US.lproj)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据官方文档国际化编程主题


如果您的Mac应用程式包含美国,英国,
和澳大利亚用户,捆绑例程将首先搜索适当的
区域目录(en_US.lproj,en_GB.lproj或en_AU.lproj),然后搜索en.lproj目录。
iPhone上的相同应用程序只能显示在en.lproj目录中。


但我试图把我的Localizable.strings在en_US.lproj目录, en.lproj,我仍然可以通过使用 NSLocalizedString()函数。



有什么问题?

解决方案

但这里是我有根据的猜测。



首先要认识到的是OS X和iOS共享大量的代码。你实际上可以找到官方 OS X - 只有几个功能,实际上也在iOS上工作。



这是我观察到的在我的手机上:



如果我只有

   -  en_US。 lproj 
- Localizable.strings

那么,它会从该文件读取值,矛盾



但是,如果我有:

   -  en_US.lproj 
- Localizable.strings
- en.lproj
- Localizable.strings



那么,它将采用 en.lproj



现在,当我使用Xcode图形化时,它只会让我选择一个本地化 en-US

code>,这是 en_US (美国地区)相同的东西。所以,我猜你(像我一样),走出Xcode,手动添加 en_US.lproj 目录,然后将它添加到你的Xcode项目。 p>

也许苹果的想法是,虽然iOS仍然可以识别 en_US.lproj ,因为他们配置Xcode不允许你直接创建本地化,应用程序不会结束那里?



另一个注意事项:如果你像我一样做,并手动创建了.lproj文件夹,你必须小心,当你改变他们,在Xcode外面,他们真的走了,当你认为他们是。此外,您可能需要卸载您的应用程序,以吹走您添加(和删除)以这种方式旧的.lproj目录。



有了文档,我不会提交一个带有这种类型的本地化的应用程序App Store。它可能会被拒绝,或打破(不找到一个字符串值)在未来,因为它不是官方支持的iOS。也就是说,如果这个功能继续无限期地工作,也不会感到惊讶。


According to the official document Internationalization Programming Topics:

if your Mac app had localizations for United States, Great Britain, and Australian users, the bundle routines would search the appropriate region directory (en_US.lproj, en_GB.lproj, or en_AU.lproj) first, followed by the en.lproj directory. The same application on the iPhone would look only in the en.lproj directory.

But I tried to put my Localizable.strings in en_US.lproj directory, not en.lproj, I still can find the string in English by using NSLocalizedString() function.

What's the problem?

解决方案

I'm not sure, but here's my educated guess.

First thing to recognize is that OS X and iOS share a large amount of code. You can actually find quite a few features that are officially OS X - only, that actually work on iOS, too.

Here's what I observed on my phone:

If I only had

- en_US.lproj
    - Localizable.strings

then, it would read the value from that file, contradicting what the documentation you found says (as you noted).

However, if I had:

- en_US.lproj
    - Localizable.strings
- en.lproj
    - Localizable.strings

then, it would take the value from en.lproj, sort of respecting the spirit of the documentation.

Now, when I use Xcode, graphically, it will only let me choose a localization for en-US, which is not the same thing as en_US (US region). So, I'm guessing that you (like me), went outside of Xcode, added the en_US.lproj directory manually, then later added it to your Xcode project.

Perhaps the thinking of Apple was that although iOS can still recognize en_US.lproj, since they've configured Xcode to not allow you to directly create that localization, apps won't wind up there? So, you've hacked your way (kind of) into that feature.

One more note: if you did as I did, and manually created .lproj folders, you have to be careful that when you change them around, outside of Xcode, they're really gone when you think they are. Also, you may have to uninstall your app to blow away old .lproj directories that you added (and deleted) in this way. So, that's one more way to see strange behaviour.

Long story short, with the documentation as it is, I wouldn't submit an app with this type of localization to the App Store. It might either be rejected, or break (not find a string value) in the future, since it's not officially supported on iOS. That said, it also wouldn't surprise me if this feature continued to work indefinitely.

这篇关于iOS寻找区域特定的.lproj目录(例如en_US.lproj)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆