-->

在PhoneGap的使用Closure库(安卓)应用程序(Using Closure Library

2019-08-02 09:31发布

喜用谷歌的封库中的任何一个https://developers.google.com/closure/在Android构建的PhoneGap应用程序。 我已阅读,关闭具有应用国际化的良好支持。 所以,如果有人能提供材料,他们称或样品片段来获得如何实现它的想法。

Answer 1:

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

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

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

所以你创建你的页面goog.dom.createDom 。 下面你会发现一个例子。

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...

};

做任何需要的翻译上面。 然后,只需设置负载的电流语言的东西很容易的等等。

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

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



文章来源: Using Closure Library on Phonegap(Android) application