Support for Globalize.js source files

34 views
Skip to first unread message

Steffen N.

unread,
Mar 16, 2017, 7:15:38 AM3/16/17
to jabylon
Hi,
many JS applications use Globalize.js to localise their frontend. In Globalize.js, translations are stored in JSON format. The format is defined here:

Any chances this will get included? A more general JSON parser would also be fine. 
Looking at your source, maybe you could give some hints how to write my own plugin. I'm a Java developer myself, and maybe I would just write my own plugin and publish it as openSource.


Hope to hear from you,

regards
Steffen

Johannes Utzig

unread,
Mar 16, 2017, 8:05:14 AM3/16/17
to jabylon

Hi Steffen,

I personally have never heard of Globalize.js (not much of a JS developer I must admit) but I'd be definitely happy to include this as a plugin.


> Looking at your source, maybe you could give some hints how to write my own plugin. I'm a Java developer myself, and maybe I would just write my own plugin and publish it as openSource.

If you are willing to give it a shot I would gladly support you. Would you be interested in contributing the plugin under EPL? If so, I could give you push access to the plugins repository. Those plugins get published to jabylon.org and show up in the update center of the UI.
In general it is pretty easy to write a plugin for a new format (2 classes). I would take this as an example/starting point:

https://github.com/jutzig/jabylon-plugins/tree/master/android/src/main/java/org/jabylon/android

You need a PropertyConverter that can read the actual files and normalizes them to Jabylon's internal model and a PropertyScanner that understands the file/folder structure of the type of localization.
The scanner is the class that understands that in e.g. java properties messages.properties is a template and messages_de.properties is a german translation for that template.

After a first glance at Globalize.js it looks like template language and all translations are stored within a single file?
That's definitely a little different than the other formats. So when writing out new translations for e.g. French the PropertyConverter should only write those portions of the JSON and leave the others untouched.
That part could be a little tricky but I'm sure we can figure something out...

Best regards,
Johannes

Johannes Utzig

unread,
Mar 16, 2017, 3:34:32 PM3/16/17
to jabylon
So I looked some more into Globalize.js. The documentation is very... sparse and I found it hard to find some real life examples.
In the link you gave me, it looks as if typically one stores all locales in a single file.
However in the examples, I only find "en.json" files (with just one locale). The naming of the file alone seems to indicate that you would put only English in that file and not let's say French and German and well.
Also, where do translator comments go? I couldn't find this mentioned anywhere.

If in real-life projects it is 1 file per locale, it should be very simple to implement this in Jabylon...

Steffen N.

unread,
Mar 17, 2017, 5:23:59 PM3/17/17
to jabylon
Hi Johannes,
thanks for your reply! I wrote via google groups, and I thought I would get a notification if you post here: apparently not :)

Publishing under EPL is fine for me. 

And yes, Globalize.js uses one file per language, which I guess is a good thing if I look at your data structure. They have some other files for each language (localisation of numbers, dates, currencies...) but these are not relevant for Jabylon I guess

I will look at the android plugin next week. Unfortunately my experience with  OSGI is very limited, but I think I'll manage.

Ich glaube wir können auch deutsch reden, oder?

Best regards
Steffen

Johannes Utzig

unread,
Mar 17, 2017, 7:23:56 PM3/17/17
to jabylon
Hi Steffen,

Great, if you let me know your github account I can give you push access.
One file per language should make this very simple indeed.

90% of this plugin can be implemented with plain unit tests without ever really needing to boot Jabylon.
For the rest:
OSGi is (in its basics) very simple, but to make it easier I already put the basic pieces together and pushed a new maven module:
https://github.com/jutzig/jabylon-plugins/tree/master/globalize.js

To test in Jabylon, first get the latest SNAPSHOT by either building it, or downloading it here:
http://jenkins-jabylon.rhcloud.com/job/jabylon/

Start it with bin/karaf

Next you have 2 choices:

1. Drop your jar (and any libs you might need) in "deploy". Should be picked up right away and become usable in Jabylon
2. First, drop any external libs you might need in deploy. Next in the karaf shell, type

bundle:install mvn:org.jabylon:globalize.js

The advantage of the 2nd approach is, if you type "bundle:watch *" in the karaf shell, it will monitor your local maven repository and automatically redeploy the jar whenever you do a mvn install.


PS: Ja, wir können gerne auch deutsch reden, aber auf der Mailingliste ist englisch geschickter...

Best regards,
Johannes

Steffen N.

unread,
Mar 18, 2017, 5:01:59 AM3/18/17
to jabylon
Hi Johannes,
Wow, looks like you got started right away!

my github account is called snieuw. 

Next week I have time almost every evening. I will look into it then. Looking forward to it!

Regards
Steffen

Am Donnerstag, 16. März 2017 12:15:38 UTC+1 schrieb Steffen N.:

Steffen N.

unread,
Mar 18, 2017, 8:24:17 AM3/18/17
to jabylon
Hm, I just tried to setup eclipse.... I pulled the plugin repo, but get dependency problems because the parent pom is not found. I then pulled the master jabylon repo, but am greeted with hundreds of dependency problems. Do I need to setup eclipse so it can resolve the OSGI bundles? Though I am not even sure that's the problem...

Any help is appreciated :)

Thanks 
Steffen

Am Donnerstag, 16. März 2017 12:15:38 UTC+1 schrieb Steffen N.:
Reply all
Reply to author
Forward
0 new messages