Tuesday, December 4, 2012

Liferay: beta languages

If you have used the internationalization built in in Liferay, you might have noticed if you hover over the flags, the name of the languages appears. You also might have noticed, the name indicates the language is 'in beta'. If you want to get rid of this, you can write a hook (or extend a hook you already have).

Of course, you need to know what page you have to adjust. The display of the language-portlet is located in $LIFERAY_HOME$/tomcat-version/webapps/ROOT/html/taglib/ui/language/page.jsp. Copy the page in your hook, and somewhere near the bottom, you'll find following code:

if (LanguageUtil.isBetaLocale(locales[i])) 
{
    message = message + " - Beta";
}

Remove it, and the beta indication is gone!

Monday, December 3, 2012

Special character encoding

If you have ever created a custom language bundle, you'll know special characters can be very annoying. When they're not displaying correctly, but instead showing a diamond with a question mark or a white rectangle, it's sometimes difficult and frustrating to find the origin of the problem.

When you're building a website that has to come with a language with a lot of special characters (French, German, ...), you can run these encoding problems. In fact, there only has to be one of those special characters anywhere in your site, and it'll be messed up. When working with resource bundles (.properties files),  I've found that these few steps often resolve a lot of issues, so try to follow these simple guidelines.

  • Make sure your general encoding is set to UTF-8. In Eclipse, you do this in Window -> Preferences -> General -> Workspace
  • Each file can have a seperate encoding as well. Check the properties of your .properties files. In Eclipse, you do this by right-clicking, then selecting Properties. Under Resource, you can set the encoding to UTF-8.
Redeploy your application with this correct settings, and your problems should dissolve! Bear in mind, though, that if you had an incorrect encoding first, switching to the correct encoding may break your file and replace the special characters by the 'not found' characters (diamond or rectangle). Check your file before deploying!