google-closure

How to do localization in Google Closure

元气小坏坏 提交于 2021-02-07 20:25:56
问题 Currently I am using just plain text in my Closure application. I want to add localizations to those text. I just found several articles about goog.getMsg function which is used to do this kind of localization. As far as I understood it is done in compile time. How can we change language in run-time when user clicks a button? What is the easiest way to do this using Closure? 回答1: I have actually achieved a runtime i18n. I use .soy templates with {msg} tags in them. When you compile .soy to

How to do localization in Google Closure

醉酒当歌 提交于 2021-02-07 20:20:34
问题 Currently I am using just plain text in my Closure application. I want to add localizations to those text. I just found several articles about goog.getMsg function which is used to do this kind of localization. As far as I understood it is done in compile time. How can we change language in run-time when user clicks a button? What is the easiest way to do this using Closure? 回答1: I have actually achieved a runtime i18n. I use .soy templates with {msg} tags in them. When you compile .soy to

Test if object is implementation of interface in Google Closure class framework

元气小坏坏 提交于 2020-01-23 07:07:49
问题 How can I test if an JavaScript object is an implementation of an interface using the Google Closure inheritance mechanism? I could not find any hint of my.Animal in the objects created via new my.Dog() and object instanceof my.Animal didn't work. The only information about the interface are compiler errors when forgetting to implement methods in the child class. /** * @interface */ my.Animal = function() {}; /** * Does something. * @return {string} */ my.Animal.prototype.doSomething; /** *

How to use Google Closure compiler

对着背影说爱祢 提交于 2020-01-22 16:27:08
问题 I'm trying to migrate from the closurebuilder.py script to the Closure compiler because of this message: ../../closure-library/closure/bin/build/closurebuilder.py: Closure Compiler now natively understands and orders Closure dependencies and is prefererred over using this script for performing JavaScript compilation Since I'm using Google Closure Library and the OpenLayers 3, how do I have to call the compiler (compiler.jar) to Build an myapp-deps.js dependency file Build an minified version

Fallback AJAX file upload for Internet Explorer

房东的猫 提交于 2020-01-14 03:44:05
问题 I have implemented an AJAX file uploader in HTML5 using xHR2 and File api for an internal project. We were only required to support Firefox/Safari/Chrome. I used the following links as a reference http://www.html5rocks.com/en/tutorials/file/xhr2/ http://www.html5rocks.com/en/tutorials/dnd/basics/ https://developer.mozilla.org/en-US/docs/Using_files_from_web_applications Now I am required to support Internet Explorer 10 and below. IE 10 supports XHR2 but File API support is lacking. Is there a

Http-Method changes from POST to OPTIONS when changing Content-Type

為{幸葍}努か 提交于 2020-01-11 03:20:09
问题 I am using closure library to do a simple POST. I think XhrIo should work because from my machine when I use any other rest client ,like Firefox browser app RESTClient or Chrome's Simple Rest Client , I can make POST request to the server and content type is application/json. But from my application I am unable to make a post. I am using the following code xhr = new goog.net.XhrIo; xhr.send('http://myhost:8181/customer/add','POST', goog.json.serialize(data)); If I leave the headers default, I

goog.string is overridden when I use soyutils.js

限于喜欢 提交于 2020-01-05 12:12:08
问题 goog.string is not able to be used when soyutils.js is included in the same HTML file. because in soyutils.js has its own goog.string that completely override goog.string <-- goog.require('goog.string'). <!DOCTYPE html> <html> <head> <title>codeBox</title> <script src="{{STATIC_URL}}closure-library/closure/goog/base.js"></script> <script> goog.require('goog.string'); </script> <script src="{{STATIC_URL}}soyutils.js"></script> </head> <body> <script> console.log(goog.string.trim); </script> <

goog.string is overridden when I use soyutils.js

﹥>﹥吖頭↗ 提交于 2020-01-05 12:11:14
问题 goog.string is not able to be used when soyutils.js is included in the same HTML file. because in soyutils.js has its own goog.string that completely override goog.string <-- goog.require('goog.string'). <!DOCTYPE html> <html> <head> <title>codeBox</title> <script src="{{STATIC_URL}}closure-library/closure/goog/base.js"></script> <script> goog.require('goog.string'); </script> <script src="{{STATIC_URL}}soyutils.js"></script> </head> <body> <script> console.log(goog.string.trim); </script> <

Creating a script to use Google Closure for multiple javascript files

你离开我真会死。 提交于 2020-01-04 03:16:07
问题 I need to use the Google Closure compiler.jar to minify a huge project I am working on. I have multiple js files that I want to compile into a single game.min.js file. I know I can use the following: java -jar compiler.jar --js file1.js --js file2.js --js etc, etc --js_output_file game.min.js ...but I have a LOT of files and as I understand it Closure doesn't have support for adding a directory and finding all the *.js files residing under that directory. My fumbling google searches are not

Google Closure and generated getters/setters

只谈情不闲聊 提交于 2020-01-04 02:34:07
问题 I'm trying to get KineticJS to work with Google Closure Compiler. KineticJS, however, generated it's getters & setters based on the name of the variables. Something like this: // add getter and setter methods Kinetic.Node.addSetters = function(constructor, arr) { for(var n = 0; n < arr.length; n++) { var attr = arr[n]; this._addSetter(constructor, attr); } }; Kinetic.Node.addGetters = function(constructor, arr) { for(var n = 0; n < arr.length; n++) { var attr = arr[n]; this._addGetter