Search code examples
liferayportlettaglib

UI Message default value in Liferay portlet


Does anybody know, if in Liferay is possibility to use default value in ui message ? I mean I have two files .properties with translations, for example: en.properties:

welecome=Hallo everybody
someKey=

,and default.properites

welecome=Hallo everybody
someKey=value of some key

I want to achieve, that if I use:

<liferay-ui:message key="welcome" />
<liferay-ui:message key="someKey" />

with English language (where there is no translation for key 'someKey'), the displayed value will be:

Hallo everybody
value of some key

I mean, when there is no translation for some key, liferay portlet will use value from default properties file.

regards


Solution

  • With the standard naming conventions, you typically have files like Language.properties and Language_en.properties. When english language is displayed, but the entry is not contained in Language_en.properties, I expect the value from Language.properties to be shown.

    However, in your case you define someKey as an empty value, which means that it's defined as exactly this.

    Moreover, Liferay offers a "Language Builder" tool that you can run during development time (in the plugins-sdk just run ant build-lang. It will create configured language files automatically, automatically copying the values from the original file if they are not yet contained in the translated file.

    If you have api credentials for bing, it can also use these to get an automatically translated value for various languages, but I'm not a big fan of these. Actually, I'm quite annoyed by automatic translations.