Developing Juzu portlets – Step 6: Let the whole world create new secrets

06-Juzu-tutorial-series

Previous steps:
Learn how to develop great Juzu portlets for eXo Platform!
Step 2: viewing and posting secrets
Step 3: Building a sexy secret wall
Step 4: adding Likes and Comments for Secret
Step 5: Saving Secrets in the JCR

We are close to the end, guys. In this step, we will make our JuZcret portlet understandable by the whole world! Ok, for this tutorial we will just manage the French and Vietnamese languages but when you understand the concept, feel free to add all the languages you want.

Internationalization and Localization

Internationalization

Internationalization is the process of developing software whose core design does not make assumptions based on a language. It means that all messages and labels in the application can be translated into all supported languages.
Note: Juzu supports i18n natively in its core. We just need to modify all the labels in all our templates. Next time, remember to do this as soon you start developing a template.

Update the editMode.gtmpl template:

The syntax for retrieving an i18nized message is &{label}. For instance we’ve replaced <h5>Configuration</h5> with <h5>&{label.configuration}</h5>.

We need to do this for all the labels in all JuZcret templates:

addsecret.gtmpl:

secretWall.gtmpl:

That’s it for internationalizing the templates.

Now, how can I manage the translation of &{label.configuration}?
It’s very simple and easy in Juzu. You just need to configure the path of your bundle in the portlet.xml and then create a Java resource bundle file (*.properties or *.xml) per language.

So, first update the portlet.xml file in the src/main/webapp/WEB-INF folder:

The resource bundle tells the portlet container to find the resource bundle files in /locale/portlet/juzcret_*.properties.

Localization

Localization is the process of customizing an app for a particular language. That includes translating the labels and messages into that language.
In this tutorial, we will limit support to French and Vietnamese.

Add the resource bundle files to this path /src/main/resources/locale/portlet/, as declared in portlet.xml:

juzcret.properties for the default language (English in eXo Platform)

juzcret_vi.properties for Vietnamese

juzcret_fr.properties for French

That’s all.
Recompile and deploy JuZcret eXo Platform as explained in a previous step of this tutorial:

Copy and paste the war file (i.e., replace the old one) in the web app folder of eXo Platform, start the server and open the JuZcret page created in step 1.

Now you can share secrets in Vietnamese:

1-add-secret-vietnamese

or look at the secret wall and add comments in French:

2-secret-wall-french

So, here we are. We have an international JuZcret application ready for sharing secrets with people all around the world.

Hum, do you think that we forgot to do some important things during the steps? Let’s fix this in the last step.

The final source of step 6 is available for downloading from GitHub.

Previous and next steps:
Learn how to develop great Juzu portlets for eXo Platform!
Step 2: viewing and posting secrets
Step 3: Building a sexy secret wall
Step 4: adding Likes and Comments for Secret
Step 5: Saving Secrets in the JCR
Step 6: Let the whole world create new secrets
Step 7: Finishing the job properly with unit test

Join the eXo tribe by registering for the community and get updates, tutorials, support, and access to the Platform and add-on downloads!

Make the most out of eXo Platform 4

Register to the next webinar and get a complete overview of what you can do with eXo Platform 4. Reserve your seat now!

Be part of the discussion, share your comments

comments

Keep in touch with the author

Tags: , , , , , , ,