Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Change the User Language Programatically
Hi Guys,Please let me know how can i change the User Language Programatically in Portlet controller, in Liferay 7.2.
I tried with the below code snippet but its not working in Liferay 7.2,
session.setAttribute("org.apache.struts.action.LOCALE", locale);
I tried with the below code snippet but its not working in Liferay 7.2,
session.setAttribute("org.apache.struts.action.LOCALE", locale);
Hi Syed Ali,
Try to update cookie as well,
If you are trying to update language for signed user and want to persist that language for future then also update it in user profile. Please find reference here https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portal/action/UpdateLanguageAction.java line 87.
Try to update cookie as well,
session.setAttribute(WebKeys.LOCALE, locale);
LanguageUtil.updateCookie(request, response, locale);
If you are trying to update language for signed user and want to persist that language for future then also update it in user profile. Please find reference here https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portal/action/UpdateLanguageAction.java line 87.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™