掲示板

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

7年前 に The Big によって更新されました。

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

New Member 投稿: 10 参加年月日: 15/08/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
7年前 に Jamie Sammons によって更新されました。

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

Expert 投稿: 301 参加年月日: 14/09/05 最新の投稿
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
7年前 に The Big によって更新されました。

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

New Member 投稿: 10 参加年月日: 15/08/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.
7年前 に sedki jdaida によって更新されました。

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

Junior Member 投稿: 25 参加年月日: 16/09/08 最新の投稿
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
7年前 に Anji E によって更新されました。

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 .
7年前 に Anji E によって更新されました。

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
7年前 に David H Nebinger によって更新されました。

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

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
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
6年前 に Fernando Fernandez によって更新されました。

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

Expert 投稿: 396 参加年月日: 07/08/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