留言板

Liferay 7 - How to load separated Language module for Web module

The Big,修改在7 年前。

Liferay 7 - How to load separated Language module for Web module

New Member 帖子: 10 加入日期: 15-8-13 最近的帖子
Dear everyone,

Here is the structure of my application:

my-application/
         my-application-web/
         my-admin-application-web/
         my-content-application-web/
         my-application-language/
         my-application-api/
         my-application-service/


In the Web module(my-application-web, my-admin-application-web, my-content-application-web), I want to load the resource bundle(Language properties) from the my-application-language.
I've been following this tutorial Localizing Your Application.
In the Web module/build.gradle file, I've imported the language module:

dependencies {
	compile project(':modules:my-application:my-application-language')
}


In the component of each Web module portlet, I have defined property "javax.portlet.resource-bundle=content.Language":

@Component(
	immediate = true,
	property = {
		"com.liferay.portlet.display-category=category.sample",
		"com.liferay.portlet.instanceable=true",
		"javax.portlet.display-name=my-admin-application-web Portlet",
		"javax.portlet.init-param.template-path=/",
		"javax.portlet.init-param.view-template=/view.jsp",
		"javax.portlet.resource-bundle=content.Language",
		"javax.portlet.security-role-ref=power-user,user"
	},
	service = Portlet.class
)
public class MyAdminApplicationWebmvcportletPortlet extends MVCPortlet {
}


But it did not workemoticon The Web module still load resource language properties inside itself(not my-application-language).

In my Web module, how to load the resource bundle(Language properties) from the my-application-language?

Best Regards.
thumbnail
Jamie Sammons,修改在7 年前。

RE: Liferay 7 - How to load separated Language module for Web module

Expert 帖子: 301 加入日期: 14-9-5 最近的帖子
You may need to use a Resource Bundle to get it working properly. Take a look at this blade sample for creating one: https://github.com/liferay/liferay-blade-samples/tree/master/liferay-gradle/blade.hook.resourcebundle

Hope that helps!
Jamie
The Big,修改在7 年前。

RE: Liferay 7 - How to load separated Language module for Web module

New Member 帖子: 10 加入日期: 15-8-13 最近的帖子
Jamie Sammons:

You may need to use a Resource Bundle to get it working properly. Take a look at this blade sample for creating one: https://github.com/liferay/liferay-blade-samples/tree/master/liferay-gradle/blade.hook.resourcebundle


Dear Jamie,
Thanks for your reply.

I tried created a Resource Bundle.

package com.sample.hook.resourcebundle;

import com.liferay.portal.kernel.util.AggregateResourceBundleLoader;
import com.liferay.portal.kernel.util.CacheResourceBundleLoader;
import com.liferay.portal.kernel.util.ClassResourceBundleLoader;
import com.liferay.portal.kernel.util.ResourceBundleLoader;

import java.util.ResourceBundle;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

@Component(
	immediate = true,
    property = {
            "bundle.symbolic.name=my.admin.application.web",
            "resource.bundle.base.name=content.Language",
            "servlet.context.name=my-admin-application-web"
    }
)
public class MyResourceBundleLoader implements ResourceBundleLoader{

	@Override
	public ResourceBundle loadResourceBundle(String languageId) {
		return _resourceBundleLoader.loadResourceBundle(languageId);
	}
	
	@Reference(target = "(bundle.symbolic.name=my.admin.application.web)")
	public void setResourceBundleLoader(ResourceBundleLoader resourceBundleLoader) {
		_resourceBundleLoader = new AggregateResourceBundleLoader(
				new CacheResourceBundleLoader(
						new ClassResourceBundleLoader("content.Language", MyResourceBundleLoader.class.getClassLoader())),
						resourceBundleLoader);
	}
	
	private AggregateResourceBundleLoader _resourceBundleLoader;
}

In the block code above:
	@Reference(target = "(bundle.symbolic.name=my.admin.application.web)")

The Resource Bundle target to only one module my.admin.application.web
Now I want to working with multiple modules. Following this guide Localizing Your Application(not overriding language properties).
But this guide is not clear. It's not working.

Please help me. Any support from everyone is great.

Thanks.
sedki jdaida,修改在7 年前。

RE: Liferay 7 - How to load separated Language module for Web module

Junior Member 帖子: 25 加入日期: 16-9-8 最近的帖子
hi , please i need a help i need to add new language like thailand language in liferay 7 . in liferay 6.2 it is very simple but in liferay 7 i don't find any solution
Anji E,修改在7 年前。

RE: Liferay 7 - How to load separated Language module for Web module

Junior Member 帖子: 49 加入日期: 14-11-18 最近的帖子
Even am facing Same problem that ,

I have created module project
-- MyApplication
-- My-web-user
-- My-services
-- My-app-lang --> Has all language properties


Given My-all-lang reference in My-web-user . Languages are not loading .
Anji E,修改在7 年前。

RE: Liferay 7 - How to load separated Language module for Web module

Junior Member 帖子: 49 加入日期: 14-11-18 最近的帖子
Hi Guys ,

Is this feature working in Liferay DXP ?
i.e Loading separate language module for web modules
thumbnail
David H Nebinger,修改在7 年前。

RE: Liferay 7 - How to load separated Language module for Web module

Liferay Legend 帖子: 14919 加入日期: 06-9-2 最近的帖子
I couldn't get it to work myself.

I noticed that DXP tends to use the lang-merge gradle task, so I don't know that they actually have it working either.

You might try opening a LESA ticket to see if Liferay has it working...
thumbnail
Fernando Fernandez,修改在6 年前。

RE: Liferay 7 - How to load separated Language module for Web module

Expert 帖子: 396 加入日期: 07-8-22 最近的帖子
Hi all,

A full year has passed. Anyone knows if this is working by now?

I'm starting a project on 7.0-ga5 that needs to have interchangeable form labels for the same language. I think the creation of a common lang module would be perfect for this use case, since it would allow me to change the interface labels just by installing a different bundle providing the same capability.

I tried to follow the tutorial in this article but it's not working. I'd like to understand if it's my fault or if this is still not implemented.

TIA

Fernando