掲示板

How to get language property value inside javascript function ?

thumbnail
11年前 に Tejas Kanani によって更新されました。

How to get language property value inside javascript function ?

Liferay Master 投稿: 654 参加年月日: 09/01/06 最新の投稿
Hi,

I want to get language property value inside my javascript function, and after searching in forums found below code for the same.
Liferay.Language.get("key")

When I've used the above code in my Custom Plugins portlet, It just returning me the Key itself instead of the value from my Language_en.properties file. After some more googling found that it only works with portal level language property and not portlet level.

I am using Liferay 6.1.

Is anyone came across such issue and able to find a solution for this problem ?
Any pointer would be appreciated.

Thanks,
Tejas
11年前 に Oliver Bayer によって更新されました。

RE: How to get language property value inside javascript function ?

Liferay Master 投稿: 894 参加年月日: 09/02/18 最新の投稿
Hi Tejas,

you can override or add your language keys into the ext-environment (ext-impl, content). I know it's some sort of a hack but I think it's the quickest solution to get it working emoticon. Otherwise you should check if it's working in the current trunk, look out for maybe already created jira issues or you can try debugging...

Greets Oli
thumbnail
11年前 に Tejas Kanani によって更新されました。

RE: How to get language property value inside javascript function ?

Liferay Master 投稿: 654 参加年月日: 09/01/06 最新の投稿
Thanks Oliver for quick reply.

But I would like to avoid making changes in ext for simply displaying the language property for my custom portlet. As in future if i want to add any more property to my portlet, everytime I need to make changes in ext and rebuild it, which I want to avoid.

And I've also checked in JIRA and found one issue raised for the same. But its found closed without any useful solution.
http://issues.liferay.com/browse/LPS-14664

Anybody from Liferay Staff Member has any solution/updates for this issue ?

Thanks,
Tejas
11年前 に Ali Reza Akbarian によって更新されました。

RE: How to get language property value inside javascript function ?

New Member 投稿: 6 参加年月日: 12/04/07 最新の投稿
Hi Tejas

Try This :
LanguageUtil.get(locale, key);

Thanks.
10年前 に Shashant Panwar によって更新されました。

RE: How to get language property value inside javascript function ?

Junior Member 投稿: 28 参加年月日: 12/09/21 最新の投稿
Hi Tejas,
I hope you resolved the issue. But if not then try using Liferay.Language.get('key'); instead Liferay.Language.get("key"). I got the same issue which you got and resolved it with above solution.

Regards,
Shashant
6年前 に kranthi kumar によって更新されました。

RE: How to get language property value inside javascript function ?

New Member 投稿: 1 参加年月日: 17/11/08 最新の投稿
Thank you Tejas......
Your Approach is working fine in liferay dxp....
thumbnail
10年前 に Pankaj Kathiriya によって更新されました。

RE: How to get language property value inside javascript function ?

Liferay Master 投稿: 722 参加年月日: 10/08/05 最新の投稿
Use liferay-ui:message tag in js.

Sorry for brief ,sent from mobile.
10年前 に Shashant Panwar によって更新されました。

RE: How to get language property value inside javascript function ?

Junior Member 投稿: 28 参加年月日: 12/09/21 最新の投稿
Pankaj Kathiriya:
Use liferay-ui:message tag in js.

Sorry for brief ,sent from mobile.


Can you please paste the syntax, I tried but liferay-ui:message is not working for me in js. Finally I end up using Liferay.Language.get('key');

Regards,
Shashant
thumbnail
10年前 に Pankaj Kathiriya によって更新されました。

RE: How to get language property value inside javascript function ?

Liferay Master 投稿: 722 参加年月日: 10/08/05 最新の投稿
<script>
var message="<liferay-ui:message key='please-enter-a-valid-screen-name'/>";
</script>
10年前 に Sandeep Singh によって更新されました。

RE: How to get language property value inside javascript function ?

New Member 投稿: 4 参加年月日: 11/12/02 最新の投稿
Thanks Shashant this worked for " Liferay.Language.get('key'); "

Thanks,
Sandeep