Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Olaf Kock
Visualizing Localization Keys in Liferay: Plugins
June 23, 2011 4:56 AM
Answer

Olaf Kock

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1959

Join Date: September 23, 2008

Recent Posts

Hi all,

During the last days I've been playing with an old idea to help Liferay localization. It's far from done and more or less a technology study (based on 6.0 EE SP1), but the port (so far) can easily be scripted. Here's what I have done and what I'm planning to add (see attached screenshot for some not-so-impressive demo):

  • Changed the MessageTag implementation for <liferay-ui:message ... /> to print some additional markup. Instead of Page Layout (in the dock) it now generates <span class="i18n"><span class="i18n-key" style="display:none">page-layout</span><span class="i18n-value">Page Layout</span>
  • Introduced a new tag <liferay-i18n:message .../> where the old message tag cannot be used (e.g. in HTML attributes like <img title="<liferay-ui:message ..../>" ... />)
  • Changed all JSPs with these occurrences to use the new tag
  • Introduced some Javascript that processes the pages for the i18n elements and generate tooltips that will show the original language key when you hover over the translation.
  • Started to explore alloy-ui taglibs to see if it's realistic to change these taglibs to generate the additional markup as well


Currently I have
  • a small ext plugin, changing the MessageTag implementation and introducing a new taglib (couldn't immediately figure out how to extend the existing taglib in ext)
  • a hook with all changed JSPs and some initial changes to the alloy-ui taglib
  • a theme containing the Javascript and some CSS to work around some formatting issues introduced by the additional markup


Tasks to do:
  • Most of the current JSPs in the hook can (and should) easily be generated from the original portal JSPs with some script to be independent of the release. Currently I did it manually because I wanted to see if this all is realistic or not.
  • There's a lot of translation in alloy-ui taglibs.Identify how much this can be automated
  • If pootle supports this, the tooltips could have a link to http://translate.liferay.com (we know the current language being displayed) so that translation work would be really well integrated.


Is this something that somebody would be interested in collaborating? I can upload to github today or tomorrow. Based on the current content (EE SP1 only) it would be best to either have EE SP1 available or be able to do some scripting (sed? perl? whatever), so that the JSPs can be regenerated based on either trunk or 6.0.6. - In the long run I want this to be available for all editions, but this is just the start and EE was what I had at hand.

Target group is naturally translators, willing to install some plugins to see the original language keys. It's nothing that you would install in your production system.
Attachment

Attachments: translation-tooltip-screenshot.png (48.9k)
Mauro Mariuzzo
RE: Visualizing Localization Keys in Liferay: Plugins
June 23, 2011 6:39 AM
Answer

Mauro Mariuzzo

Rank: Regular Member

Posts: 139

Join Date: July 23, 2007

Recent Posts

For Liferay 6.0 SP1 I'm using the following property
1
2    #
3    # Set this to true to disable language translations. When a translation is
4    # requested for the key "first-name", instead of returning "First Name" in
5    # English (or in its relevant locale), it will return "first-name".
6    #
7    translations.disabled=false


This let me see every keys. Also ones inside hints and popups.
Olaf Kock
RE: Visualizing Localization Keys in Liferay: Plugins
June 23, 2011 7:21 AM
Answer

Olaf Kock

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1959

Join Date: September 23, 2008

Recent Posts

oh, nice. Didn't find this. However, this solves a different problem: When I see a bad german translation, I also want to see the original key - that's what I tried to do with this set of plugins.

But you triggered another idea - why not support a localization to the keys - inventing the language code "xx". This way, it's easy to switch between the two localizations. And the translation for key "page-layout" is "page-layout"... I'm also going to try this. Might be a simpler solution, but not as cool
Olaf Kock
RE: Visualizing Localization Keys in Liferay: Plugins
June 27, 2011 3:13 PM
Answer

Olaf Kock

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1959

Join Date: September 23, 2008

Recent Posts

Ok, finally something else is available:

While I rewrote the plugin (and tried to script all the JSP patches) I found a simpler solution: This now doesn't do the fancy hover, but displays a table of keys and values used on the current page at the bottom of the page. The UI can take a bit of work, it could be made fancier.

The target group for this would be translators running their personal system hunting for strange translations. Probably it'll be more useful for the less finished translations or those that have lots of automatic translations in it.

I just published it in the i18n-helper branch on github. You need the i18n-ext because I override LanguageImpl (I did it the stupid way - couldn't inherit from the original class because of its private constructor, so I had to copy the class and patch - see the _get method). Also, you'll need the themes, customizing classic and controlpanel: i18n-theme and i18n-controlpanel-theme. The first contains just the changes to the template while the second contains a modified controlpanel theme: Couldn't inherit from the original one and I didn't have enough time to debug the build process.

I'll post screenshots the next days - for today it's too late. Hope somebody can make use of it.
Olaf Kock
RE: Visualizing Localization Keys in Liferay: Plugins
June 28, 2011 5:03 AM
Answer

Olaf Kock

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1959

Join Date: September 23, 2008

Recent Posts

Olaf Kock:
I'll post screenshots the next days - for today it's too late. Hope somebody can make use of it.


This is what you get when you apply the ext-plugin and both themes: An ugly table at the bottom of the page, containing all keys and their current translations that have been looked up during this request. The nice thing is that this also includes "alt" and "title" attributes, that would otherwise never be visible on a page. (see screenshot)

Instead of generating the table in the theme, one could add a nice JS solution to present a bit more stylish, access it from a portlet or something similar, but this is the starting point.
Attachment

Attachments: i18n-screenshot.png (60.0k)
Julio Camarero
RE: Visualizing Localization Keys in Liferay: Plugins
July 4, 2011 12:04 AM
Answer

Julio Camarero

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1641

Join Date: July 15, 2008

Recent Posts

Hey Olaf,

this is very cool, I think it will be very useful for translators! emoticon
Luis Mas
RE: Visualizing Localization Keys in Liferay: Plugins
August 2, 2011 11:21 AM
Answer

Luis Mas

Rank: Regular Member

Posts: 146

Join Date: May 18, 2009

Recent Posts

Great contribution!!!
Jay Patel
RE: Visualizing Localization Keys in Liferay: Plugins
August 9, 2011 11:27 PM
Answer

Jay Patel

Rank: Regular Member

Posts: 116

Join Date: February 23, 2010

Recent Posts

Great idea & awesome contribution...this will save a lot of time..rather searching key-value in properties files..