Xcode PhoneGap 本地化
这两天我一直在努力尝试向我的应用程序添加特定于语言的本地化。 该应用程序正在使用 PhoneGap 1.1,我正在尝试使用 XCode 4.1 构建它。
自 2 天以来我一直在搜索信息/教程/其他内容,但我找不到任何详细信息。所以,要么这是一个微不足道的问题,我无法理解它,要么这是一个不常见的问题。
我看到的许多线程解释说我必须在“资源”下创建一个新文件夹并将以下文件夹添加到项目中(假设我希望我的应用程序本地化为法语和非法语国家):
--locales
--- en
---- local.strings
--- fr
---- local.strings
我现在已经遇到麻烦了:首先,我应该将什么视为我的项目根文件夹?我的所有代码都位于“www”文件夹内,据我所知,这是 PG 在执行其工作时查看的主节点。所以我假设我必须在“www”下创建“locales”。
假设这是正确的位置,我必须将键值对输入到 .strings 文件中。现在,我如何告诉 Xcode 它需要在我的 index.html 页面中查看哪些字符串? 在 Objective-C 中,这是通过调用 NSLocalizedString(@"StringKey") 来完成的,但由于我使用 PG,所以我可以使用纯 HTML 或 JS。有没有内置的方法可以做到这一点?
这是错误的做法吗? 有关该主题的任何提示、教程、文档、参考指南都会有很大帮助。
I have been banging my head against the wall for 2 days trying add language-specific localization to my app.
The App is using PhoneGap 1.1 and I am trying to build it up using XCode 4.1
I have been searching for infos/tutorial/whatever since 2 days now but I could not find anything detailed. So, either it's a trivial issue and I am failing at understing it, or it's an uncommon issue.
Many threads I've seen explain that I have to create a new folder under "Resources" and add the following folders to the project (say I want my app to be localized in French and for non-French speaking countries):
--locales
--- en
---- local.strings
--- fr
---- local.strings
I am already in troubles now: first of all, what should I consider as my project root folder? All my code is inside the "www" folder and as far as I understood, this is the main node PG looks at when doing its job. So I assume I have to create "locales" under "www".
Assuming this is the correct place, I have to enter the key-value pairs into the .strings file. Now, how do I tell Xcode which strings it needs to look at in my index.html page?
In Objective-C this is done by calling NSLocalizedString(@"StringKey")
, but since I am using PG I have either plain HTML or JS to use. Is there any built-in method to do so?
Is this the wrong approach?
Any hint, tutorial, documentation, reference guide on the subject would be of great help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
PhoneGap 以不同的方式组织。
www/index.html 文件作为 webView 从 DroidGap 类中加载。
至少从我的理解来看,这是您可以拦截 html 页面加载并应用任何本地化解析的唯一点(除了 Javascript 插件)。
一旦 www/index.html 被呈现,任何进一步的链接要么在内部处理(多页面方法),要么通过链接到“外部”(单页面方法)html 页面。
如果没有到达 Javascript Callback 方法,则不会调用和处理 PhoneGap 后端类,因此不会调用和处理 iOS 特定类。
PhoneGap 插件为本地编码环境提供了一个 Javascript 桥接器,因此可用于提供本地化。
刚刚找到一个可能有帮助的线程:
http://community.phonegap.com/nitobi/topics/problem_with_binary_details_ios_localization_builded_with_phonegap_build?from_gsfn=true
PhoneGap is organized in a different way.
The www/index.html file is loaded as a webView from within the DroidGap class.
This is, at least from my understanding, the only point (besides a Javascript Plugin) where you could intercept the loading of the html page and apply any localization parsing.
Once the www/index.html is rendered, any further links are either processed internally (multi-page approach) or via links to "external" (single page approach) html pages.
If no Javascript Callback method is reached, no PhoneGap backend classes and thus no iOS specific classes are called and processed.
PhoneGap plugins provide a Javascript-Bridge to the native coding environment and can thus be used to provide localization.
Just found a thread which might help:
http://community.phonegap.com/nitobi/topics/problem_with_binary_details_ios_localization_builded_with_phonegap_build?from_gsfn=true