RE: RE: how to use Internationalization in serviceImpl(service builder)

Scarletake Bwi, modified 3 Years ago. Expert Posts: 327 Join Date: 12/20/10 Recent Posts

hi

i'd like to know, is there passable to use LanguageUtil in serviceImpl class?

my request is send mail to some use and trigger by method of thread and serviceImpl class.

i know how to use in portlet or jsp

LanguageUtil.get(request, <key>, <default value>)

but in my BaseMessageListener or other thead, i do have request(ActoinRequest or RenderRequest)

how can i use LanguageUtil? or is there anyother way to use internationalization?

thank you in advance

 

in current, i use liferay ce 7.4.3.4

i put constent folder onder src/main/java, and use 

ResourceBundle rb = ResourceBundle.getBundle("constent.Language", currentLocale);
		System.out.println(rb.getString(<my key>));

 

 

thumbnail
Olaf Kock, modified 3 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts

LanguageUtil also has methods that take a Locale instead of a request

Scarletake Bwi, modified 3 Years ago. Expert Posts: 327 Join Date: 12/20/10 Recent Posts

hi Olaf

thank you.

but my question is, i cannot get the properties when it in src/main/resource.

in portlet, i can config in annotation @Component, but in other independent object, i don't know how to do.

thumbnail
Mohammed Yasin, modified 3 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts

Hi,

You can refer different module Language resources by adding "-liferay-aggregate-resource-bundles:module name to refer resourcebundle"  in your bnd file. Please refer below:

https://help.liferay.com/hc/en-us/articles/360029315011-Using-a-Language-Module#using-a-language-module-from-a-module