Search code examples
propertiesliferayportlettranslate

Liferay portlet adding properties contains translations without redeploy


I want to create and save file Language_mylang.properties contains my translations on line. But when I do it, Liferay doesn't see the changes and uses default language .properties file. Problem disappeares only after restart Liferay (redeploy my portlet). Does anybody know how add own properties file and achieve to Liferay see it, without redeploy ?

regards


Solution

  • If you stick to properties files, redeployment is a feature of the app server: It doesn't pick up any changes to files that you're changing in the running system without redeploy. JSPs are the one noteable difference, but you shouldn't rely on this feature to be available in production systems: It's rather a development time feature.

    That said, if you want to dynamically update Liferay's translation, you could look at the deployment processes or try to get to com.liferay.portal.language.LanguageResources, though this class is not available to plugins. You can try to access it with classloading magic (see com.liferay.portal.kernel.util.PortalClassInvoker, but prepare for ugly code (e.g. it's reflection-like) to dynamically update the translation.

    I'm sure there are other possibilities as well (they might even be better), but these are the first that I found.