Foros de discusión

Custom language keys in Liferay 7 fragment

Csaba Meszaros, modificado hace 7 años.

Custom language keys in Liferay 7 fragment

Junior Member Mensajes: 42 Fecha de incorporación: 10/10/13 Mensajes recientes
Hi. I need a detailed solution on how can I add custom language keys to the built-in login portlet's overridden create_account.jsp fragment.
So far, the only solution I made was to retrieve strings from a custom database table, but that is quite cumbersome.
I would really appreciate any working (that means tested) solution. Thanks!
thumbnail
Jamie Sammons, modificado hace 7 años.

RE: Custom language keys in Liferay 7 fragment (Respuesta)

Expert Mensajes: 297 Fecha de incorporación: 5/09/14 Mensajes recientes
Hello, you can find a sample here for Liferay 7 CE GA3: https://github.com/sammonsjl/liferay-samples-workspace/tree/master/modules

Be sure to refresh the original login module (refresh <module id> from the Gogo shell) after you deploy the fragment and resource modules. If that doesn't work you may have to stop the Liferay bundle, delete osgi/state and restart the Liferay bundle.
Csaba Meszaros, modificado hace 7 años.

RE: Custom language keys in Liferay 7 fragment

Junior Member Mensajes: 42 Fecha de incorporación: 10/10/13 Mensajes recientes
Thank you, I will try it!
Csaba Meszaros, modificado hace 7 años.

RE: Custom language keys in Liferay 7 fragment

Junior Member Mensajes: 42 Fecha de incorporación: 10/10/13 Mensajes recientes
Jamie Sammons:
Hello, you can find a sample here for Liferay 7 CE GA3: https://github.com/sammonsjl/liferay-samples-workspace/tree/master/modules

Be sure to refresh the original login module (refresh <module id> from the Gogo shell) after you deploy the fragment and resource modules. If that doesn't work you may have to stop the Liferay bundle, delete osgi/state and restart the Liferay bundle.


Unfortunatelly it doesn't work.
I made a new module project with resource bundle loader class and Language.properties file. I couldn't find the compileOnly group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1" dependency as well, so I left with version 2.5
the module i made is called hu-registration-resource, and basically everything else is the same as with your example, but the hu-registration-fragment module doesn't recognize the newly added custom string from the hu-registration-resource.
Csaba Meszaros, modificado hace 7 años.

RE: Custom language keys in Liferay 7 fragment

Junior Member Mensajes: 42 Fecha de incorporación: 10/10/13 Mensajes recientes
There are several unclear things:

@Component(
		immediate = true,
		property = {
			"bundle.symbolic.name=com.liferay.login.web",
			"resource.bundle.base.name=content.Language",
			"servlet.context.name=login-web"
		}
	)
public class LoginResourceBundleLoader implements ResourceBundleLoader {...

Where does this servlet.context.name=login-web come from?
Then,

Bundle-SymbolicName: com.liferay.login.web.fragment
Bundle-Version: 1.0.0
Fragment-Host: com.liferay.login.web;bundle-version="1.0.7"
Web-ContextPath = /login-web-fragment

This Web-ContextPath = /login-web-fragment, how do you know that this is correct?

And finally: can we have other bundle package names other than: com.liferay.login.web.resource ?

This OSGi way is a bit a woodoo-magic for me.
Csaba Meszaros, modificado hace 7 años.

RE: Custom language keys in Liferay 7 fragment

Junior Member Mensajes: 42 Fecha de incorporación: 10/10/13 Mensajes recientes
I managed to solve the problem thank you: I modified some things for my needs:
1. I made a module with custom name minthaka.registration.resource , and the bnd.bnd file looks like:

Bundle-Name: minthaka.registration.resource
Bundle-SymbolicName: minthaka.registration.resource
Bundle-Version: 1.0.0

And practically it works nearly OK. Just as it does in your example. There's another issue with this, but I am going to open another topic for that separatelly.