Message Boards

RE: Visualizing Localization Keys in Liferay: Plugins

thumbnail
Olaf Kock, modified 12 Years ago.

Visualizing Localization Keys in Liferay: Plugins

Liferay Legend Posts: 6403 Join Date: 9/23/08 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.
thumbnail
Mauro Mariuzzo, modified 12 Years ago.

RE: Visualizing Localization Keys in Liferay: Plugins

Regular Member Posts: 142 Join Date: 7/23/07 Recent Posts
For Liferay 6.0 SP1 I'm using the following property

    #
    # Set this to true to disable language translations. When a translation is
    # requested for the key "first-name", instead of returning "First Name" in
    # English (or in its relevant locale), it will return "first-name".
    #
    translations.disabled=false


This let me see every keys. Also ones inside hints and popups.
thumbnail
Olaf Kock, modified 12 Years ago.

RE: Visualizing Localization Keys in Liferay: Plugins

Liferay Legend Posts: 6403 Join Date: 9/23/08 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
thumbnail
Olaf Kock, modified 12 Years ago.

RE: Visualizing Localization Keys in Liferay: Plugins

Liferay Legend Posts: 6403 Join Date: 9/23/08 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.
thumbnail
Olaf Kock, modified 12 Years ago.

RE: Visualizing Localization Keys in Liferay: Plugins

Liferay Legend Posts: 6403 Join Date: 9/23/08 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.
thumbnail
Julio Camarero, modified 12 Years ago.

RE: Visualizing Localization Keys in Liferay: Plugins

Liferay Legend Posts: 1668 Join Date: 7/15/08 Recent Posts
Hey Olaf,

this is very cool, I think it will be very useful for translators! emoticon
thumbnail
Luis Mas, modified 12 Years ago.

RE: Visualizing Localization Keys in Liferay: Plugins

Regular Member Posts: 146 Join Date: 5/18/09 Recent Posts
Great contribution!!!
thumbnail
Jay Patel, modified 12 Years ago.

RE: Visualizing Localization Keys in Liferay: Plugins

Regular Member Posts: 118 Join Date: 2/24/10 Recent Posts
Great idea & awesome contribution...this will save a lot of time..rather searching key-value in properties files..
thumbnail
Olaf Kock, modified 4 Years ago.

RE: Visualizing Localization Keys in Liferay: Plugins

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts
Good news: After 8 years a new version of this plugin is available for 7.2. No more ext required, and the UI is still just as ugly as before (but functional). This time it signals some suspect lookups as well (see screenshots - I've opted for the whole browser window, you'll need to zoom in).

Code in github, check the README as well.
(Tested on DXP 7.2 SP1 and FP3)
Mem Leak, modified 4 Years ago.

RE: Visualizing Localization Keys in Liferay: Plugins

New Member Post: 1 Join Date: 12/28/19 Recent Posts
Good news
ildar sl, modified 4 Years ago.

RE: Visualizing Localization Keys in Liferay: Plugins

Regular Member Posts: 158 Join Date: 12/12/11 Recent Posts
Thank you!