在PhoneGap的使用Closure库(安卓)应用程序 [英] Using Closure Library on Phonegap(Android) application

查看:166
本文介绍了在PhoneGap的使用Closure库(安卓)应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜用谷歌的封闭图书馆 https://developers.google.com/closure/ 构建PhoneGap的应用程序的任何一个在Android上。我已阅读,关闭具有应用国际化的良好支持。因此,如果任何人都可以提供材料,他们提到或样品片段,以了解如何实现它的想法。

Hi has any one used google's Closure Library https://developers.google.com/closure/ in building Phonegap applications on Android. I have read that Closure has good support for internationalization of applications. So if anyone could provide material they referred or sample snippets to get an idea of how to implement it.

推荐答案

没有区别,以你如何使用PhoneGap的。取景本机应用程序的背景内的Web视图,不会改变。

There is no difference as to how you use PhoneGap. Framing a web view inside a native app background, doesn't change.

Closure库,不同于任何其他库,将编译你的JavaScript原始严重缩小的code与语义特征。 否则,是的,用它作为你请,包括PhoneGap的。

The Closure Library, unlike any other library, will compile your javascript to raw heavily minified code with semantic features. otherwise yes, use it as you please, PhoneGap included.

当你建立的东西与闭合,可以呈现在JavaScript中的DOM。这是超级快,远远超过了传统的方式要好得多。

When you build something with Closure, you can render the DOM in JavaScript. It is super fast and much much better than the conventional way.

让您创建您的网页 goog.dom.createDom 。下面你会发现一个例子。

so you create your pages with goog.dom.createDom. Below you will find an example.

var menuButton = goog.dom.createDom('a', {
    'class': 'menu-button',
    'otherAttributes': 'otherValues etc'
}, myproject.translations.menuButton.currentLanguage);

//Now you have a file like this:
goog.provide('myproject.translations');

// Language variations corresponding to that element.
myproject.translations.menuButton = {
    'EN': 'go',
    'FR': 'aller',
    'DE': 'gehen'//etc...

};

执行上述任何需要翻译。然后,只需设置负载的电流语言的东西,很容易一样。

Do the above wherever translations are needed. Then simply set the current language on load with something very easy like.

myproject.boot = function(parameters) {
    myproject.translations.currentLanguage = parameters['currentLanguage'];
};
goog.exportSymbol('myproject.boot', myproject.boot);

然后调用window.load在index.php或任何内部的引导方法和回声JSON字符串从服务器的启动参数。当心,一切源于必须在引用的引号内封装服务器。否则,编译器将压平ADVANCED_OPTIMIZATIONS模式的属性名称。

and then call the boot method inside the index.php or whatever on window.load and echo a JSON string with the boot parameters from the server. Beware, everything that comes from the server must be encapsulated within quotes when referenced. Otherwise the compiler will flatten the property name in ADVANCED_OPTIMIZATIONS mode.

这篇关于在PhoneGap的使用Closure库(安卓)应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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