XCode PhoneGap本地化 [英] XCode PhoneGap Localization
问题描述
我一直在我的头撞墙,试图添加语言本地化到我的应用程序。
该应用程序正在使用PhoneGap 1.1,我试图使用XCode 4.1构建它
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
---- local.strings
--- fr
---- local.strings
---- local.strings
已经在麻烦现在:首先,我应该考虑作为我的项目根文件夹?所有我的代码是在www文件夹内,据我所知,这是主要节点PG看看在做什么工作。所以我假设我必须在www下创建locales。
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".
假设这是正确的地方,我必须输入键值对到.strings文件。现在,如何告诉Xcode哪些字符串需要在我的index.html页面看?
在Objective-C这是通过调用 NSLocalizedString(@StringKey)
,但是由于我使用PG我有纯HTML或JS使用。有没有任何内置的方法这样做?
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?
这是错误的方法吗?
推荐答案
PhoneGap是有组织的以不同的方式。
PhoneGap is organized in a different way.
www / index.html文件从DroidGap类中作为webView加载。
这是,至少从我的理解,唯一的点(除了Javascript插件),你可以拦截html页面的加载和应用任何本地化解析。
一旦www / index.html被渲染,任何进一步的链接被内部处理(多页方法)或通过外部(单页方法)html页面的链接。
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.
如果没有达到Javascript回调方法,则不会调用和处理任何PhoneGap后端类,因此也不会调用和调用任何iOS特定的类。
If no Javascript Callback method is reached, no PhoneGap backend classes and thus no iOS specific classes are called and processed.
PhoneGap插件为本地编码环境提供一个Javascript桥,因此可用于提供本地化。
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:
这篇关于XCode PhoneGap本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!