Archive for month: March, 2012

Mobile Web & Internationalization

20 Mar
2012/03/20

For my work, we are building the trending-trend for the mobile world: mobile web applications. Web applications, or whatever you prefer to call them, thought and optimized for being used through a mobile device. This is all great and cool, you can exploit your HTML5-CSS-JavaScript-fu, and you do not have to learn to program natively on the various mobile platform out there. It is more or less a win-win situation: write once, use on every device. There are drawbacks of course: no real power from your device, you are doomed by the Lord of the Internet Connections and offline access to the data is not really good, and you loose a little bit of that native feeling. Even with all of these, you are still able to create great mobile experiences: the available tool-kits are really well done and are actively developed (jQuery Mobile, Sencha, KendoUI), there are tools to help you building a “native” app converting your HTML5 code, and you are even able to access (with some tricks) some of the hardware resources. But there is always one problem that sometimes people forget to think about: provide users with content in their own language (or at least try to get close to that very language).

The problem we are facing now is exactly this: how to do it? How to provide users with localized content? How to better handle the localization process?

Since we are on the web, we can get language information from different sources, which one to trust is open to debate: should we trust the web browser? Should we get the language via the geolocation of the user or should we get, in some way or another, the information from the underlying operating system?

I usually consider my case: I’m Italian, I live in France, my desktop environment is in Italian, but I prefer, where possible, to read websites in English (that is because websites tend to be better in English if not properly translated).

OK, deciding that is a little bit tricky, you can get into nasty discussions about how to render time and dates, monetary currency, the direction of the text, plural forms, left aside cultural changes if you embrace a broader users base (colors, icons…).

But, if we know which source to trust, how can we “easily” extract the text to be localized, translate it, and reconstruct everything after? Our software stack is composed of HTML + PHP, JavaScript (that comes from jQuery Mobile and Sencha), and Java.

Java provides us our backend, and some messages comes from it too: error messages if something goes kaput, email messages for authenticating a user, plus other small things. But with Java we are more or less safe: there is support for gettext in Java or we can use the Java built-in features (message bundles and properties file, that I do not like much). PHP has gettext support, so even here we are safe.
JavaScript seems a little bit more problematic. Around the web the are a lot of different approaches one can take, even if they all share a small common idea. jQuery Mobile seems to have some sort of internationalization support, Sencha I wasn’t able to find any, but there is a JavaScript implementation of the gettext library (it is not clear if it supports MO file loading).

All these JavaScript approaches looks like they are made with the idea to load the translations dynamically (a-la-gettext), but what if we want to create the final translated page on the server, and send it already translated to the user? Caching the pages directly on server side and serving content a little bit faster? These, and probably others, are questions that I will have to find an answer in the coming months, and they look interesting.

Eclipse Tools

11 Mar
2012/03/11

This is more a brain-dump kind of post for me, so I do not forget, every time I need to re-install Eclipse for whatever reasons, to install the plugins I need the most (and where to find them) or to tweak it a little bit. Since my daily work is more Java-based, the tools I use are Java-centric.

Bash Tool

I tend to write a lot of shell code too, maintenance scripts for the servers or for repetetive tasks, and since I’m mostly working with Java and Eclipse, I needed something that could decently handle bash files inside Eclipse.

ShellEd comes to the rescue (the website is pretty basic, with not a lot of info). I didn’t look deeply into other shell plugins for Eclipse, but this one works nicely.

To use it, it is necessary to install also the LinuxTools Eclipse plugin (from here). The only necessary part of that set of tools, if C/C++ development and the other Linux integrations are not necessary, is the man pages viewer. ShellEd is able to present you with man pages of the shell commands in a hoover-help fashion (even if I find it tad slow).

To install, download the zip file, and from Help → Install New Software → Add, use the Archive button to install it.

Editing Sessions

At work I might be working or looking on different projects, with different set of files each, and I tend to work focused on the task at hand, trying not to pollute the screen with other distractions, even in the terms of files from another project. I was looking for an easy way to save and restore the “editing session”, the open files.

I find the Extended VS Presentation plugin to be very useful in this (info here).

Pretty simple to install in Eclipse via the “Help → Install New Software“, and then pasting in the “Work with” text-box this URL: http://andrei.gmxhome.de/eclipse/

Python

From time to time I also write some Python code, and as for shell code, I prefer to not move from the environment I’m used. For Eclipse there is a powerful plugin for Python: PyDev. Installation instructions are very well written.

Static Analysis

Other tools that for me are a must have, are a set of static analysis tools. The more useful:

  • PMD: Eclipse instructions are here;
  • FindBugs: installable via the Eclipse Market;
  • CodePro Tools: comes from Google, and it is more than a static code analysis tool: can calculate code metrics, is a code coverage tool, has JUnit integration and can generate unit tests automatically. Can’t live without this.

Speed Eclipse a Little Bit

And this is my Eclipse configuration file, I find Eclipse a little bit faster at startup (make a copy of your old one if you want to use this!):