Foren

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

The Big, geändert vor 7 Jahren.

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

New Member Beiträge: 10 Beitrittsdatum: 13.08.15 Neueste Beiträge
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, geändert vor 7 Jahren.

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

Expert Beiträge: 297 Beitrittsdatum: 05.09.14 Neueste Beiträge
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, geändert vor 7 Jahren.

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

New Member Beiträge: 10 Beitrittsdatum: 13.08.15 Neueste Beiträge
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, geändert vor 7 Jahren.

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

Junior Member Beiträge: 25 Beitrittsdatum: 08.09.16 Neueste Beiträge
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, geändert vor 7 Jahren.

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

Junior Member Beiträge: 49 Beitrittsdatum: 18.11.14 Neueste Beiträge
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, geändert vor 7 Jahren.

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

Junior Member Beiträge: 49 Beitrittsdatum: 18.11.14 Neueste Beiträge
Hi Guys ,

Is this feature working in Liferay DXP ?
i.e Loading separate language module for web modules
thumbnail
David H Nebinger, geändert vor 7 Jahren.

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

Liferay Legend Beiträge: 14916 Beitrittsdatum: 02.09.06 Neueste Beiträge
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, geändert vor 6 Jahren.

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

Expert Beiträge: 396 Beitrittsdatum: 22.08.07 Neueste Beiträge
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