'Upgrade LanguageUtil.get method
Good afternoon, I am new to liferay and I am trying to migrate the code of a portlet from 6.2 to 7.4, I need to know how to use the LanguageUtil.get() method in liferay 7.x, currently it is implemented like this in my JSP LanguageUtil.get(pageContext, "key"), but I get an error "PortletConfig get/format methods" I have tried some ways like LanguageUtil.get(themeDisplay.getLocale(), "key") but I can't get the error to go away, any suggestion or correct way is appreciated to do it.
Solution 1:[1]
In a JSP you'd often use <liferay-ui:message key="key"/>, to prevent too many code snippets in the JSP. With this, you'd have no upgrade efforts.
If you want to use LanguageUtil, with a specific ResourceBundle (e.g. the one that comes with the module that you're upgrading), you'll need the locale as well: ResourceBundleUtil.getBundle(locale, this.getClass().getClassLoader()) - you can get the relevant locale through pageContext or themeDisplay. Then use LanguageUtil.get(resourceBundle, key)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Olaf Kock |
