Message Boards

Liferay 7 - Ext plugin - Can I do it without?

Sébastien Lamaison, modified 6 Years ago.

Liferay 7 - Ext plugin - Can I do it without?

New Member Posts: 24 Join Date: 10/17/13 Recent Posts
Hi all.

A long time ago, on Liferay 6.0, we developed for one of our customer a portlet + some things in an ext plugin to allow administrators to manage translations directly from the website. The portlet allow them to modify translations in a database table, and the ext plugin classes where used to add the loading from this table into the languageMaps after loading "classics" translations from properties files.

Now, we're moving to Liferay 7, and so we need to migrate all of this. But... For what I saw until now, I'm not sure we can still do. Indeed :
- it's not possible to do ext-plugins anymore
- there is no ServiceWrapper we could override to implement what we need

Is there something I'm missing, or is there no way of doing what we want to?

Thanks in advance for your help.

Kind regards

Sébastien
thumbnail
David H Nebinger, modified 6 Years ago.

RE: Liferay 7 - Ext plugin - Can I do it without?

Liferay Legend Posts: 14919 Join Date: 9/2/06 Recent Posts
Sébastien Lamaison:
- it's not possible to do ext-plugins anymore


It is coming back in GA4 (so I'm told), but I would encourage you not to use it unless you are absolutely positive you need it. Once you've decided you do need it, I would also suggest that you go back through and find a path that gets you to your destination without the EXT.

- there is no ServiceWrapper we could override to implement what we need


There are still service wrappers, I don't know if this was a general statement about them or a reference to a specific one you were looking for.

Is there something I'm missing, or is there no way of doing what we want to?


Well, in the end you're basically talking about a custom resource bundle implementation. I don't know that Liferay is really an issue here at all.








Come meet me at the 2017 LSNA!
Sébastien Lamaison, modified 6 Years ago.

RE: Liferay 7 - Ext plugin - Can I do it without?

New Member Posts: 24 Join Date: 10/17/13 Recent Posts
Hi David.

First of all, thanks for your answer!

Regarding ext-plugins, I totally agree with you, and we're trying as far as possible to avoid it (anyway, we can't do you for the moment, so...).
That's why I looked to service wrappers, but I didn't find one that allow us to override the way Liferay "serves" the translations.
My interrogation about being missing something was about that, I was thinking maybe I missed a way to find service wrappers or extension points...

As suggested, I'll try thinking to another way of doing this.

Thanks again.

Kind regards

Sébastien
Sébastien Lamaison, modified 6 Years ago.

RE: Liferay 7 - Ext plugin - Can I do it without?

New Member Posts: 24 Join Date: 10/17/13 Recent Posts
Hi.

Back on this subject after a long time (summer holiday emoticon).
As discussed with David, I searched a way of doing it without EXT plugin ((thanks again for pushing me on this way !).

So, I used the "proper" way to override Liferay's language keys, by creating a ResourceBundle, as explained here : https://dev.liferay.com/fr/develop/tutorials/-/knowledge_base/7-0/overriding-language-keys#modifying-liferays-language-keys. Or rather, I created a set of ResourceBundles, as there are multiple languages.

The only little difference with the way explained is that I don't load the ResourceBundles from properties files included in the module, but from external files (so I'm able to modify them from my portlet, which is the goal).

Everything is working fine (my overrides are correctly loaded and displayed, update of properties files from my portlet works) BUT I'm not able to trigger the "reloading" of the corresponding ResourceBundle.
I followed the thread to find out that loading of the overrides is handle in class com.liferay.portal.language.LanguageResources (in nested class LanguageResourceServiceTrackerCustomizer to be accurate) but every classes that seems useful for my purpose are not exposed to external modules, so I can't manipulate them.

Does anyone knows if there is a way for my to trigger an event (or so), to tell Liferay's core to reload my ResourceBundle component?

Thanks in advance for your help.

Kind regards

Sébastien
thumbnail
David H Nebinger, modified 6 Years ago.

RE: Liferay 7 - Ext plugin - Can I do it without?

Liferay Legend Posts: 14919 Join Date: 9/2/06 Recent Posts
Sébastien Lamaison:
Does anyone knows if there is a way for my to trigger an event (or so), to tell Liferay's core to reload my ResourceBundle component?


No, I don't think it's expected that the RB will change dynamically at runtime. I also guess that there's some heavy caching going on to speed up key resolution.











Come meet me at Devcon 2017 or 2017 LSNA!
Sébastien Lamaison, modified 6 Years ago.

RE: Liferay 7 - Ext plugin - Can I do it without?

New Member Posts: 24 Join Date: 10/17/13 Recent Posts
I see your point, and yes, translation are "cached" in maps to be quickly retrieved when needed.

But I suppose it is still possible to update this at runtime, because it's the purpose of language overrides module. Indeed, what the module does is declare a ResourceBundle service, which triggers Liferay to "update" the map containing translation for the given locale.
Also, if I update my properties file (manually or through my module), and refresh the module (from Felix Gogo Shell or by re-deploying the same jar, even without changes in it), Liferay "correctly" handle the new ResouceBundle and updates its map.

So I guess my solution is not necessarily on the Liferay side, but maybe on the OSGI side. There's obviously a way to trigger an OSGI service update, the only remaining question is how to do it without redeploying the entire bundle....
thumbnail
Olaf Kock, modified 6 Years ago.

RE: Liferay 7 - Ext plugin - Can I do it without?

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts
Sébastien Lamaison:
So I guess my solution is not necessarily on the Liferay side, but maybe on the OSGI side. There's obviously a way to trigger an OSGI service update, the only remaining question is how to do it without redeploying the entire bundle....


I haven't tried this myself, but here's my take on it: You can use the ServiceRegistry manually, e.g. register and unregister services as needed. While Annotations help you doing this statically and safely (e.g. guaranteeing an "unregister" operation when the bundle is unregistered), you're on your own if you register manually - but it should be possible. The conditions under which you re-register your service should be up to you

Again the warning: I haven't tried this at all...
Sébastien Lamaison, modified 6 Years ago.

RE: Liferay 7 - Ext plugin - Can I do it without?

New Member Posts: 24 Join Date: 10/17/13 Recent Posts
Thanks Olaf.

That's exactly what I'm trying to do. I just have to figure out how to "interact" with the ServiceRegistry ...
I'll let you know when I find my way.
Gabriel Delhaye, modified 3 Years ago.

RE: Liferay 7 - Ext plugin - Can I do it without?

New Member Posts: 2 Join Date: 5/12/20 Recent Posts
Hello,
I am facing the same problem but using Liferay 6.2. Can you tell me how you manage to make it work in this version?
Thank you very much!
thumbnail
Christoph Rabel, modified 3 Years ago.

RE: Liferay 7 - Ext plugin - Can I do it without?

Liferay Legend Posts: 1554 Join Date: 9/24/09 Recent Posts
Which problem?
Ext plugins exist for 6.2, so I guess, you mean something else.
Gabriel Delhaye, modified 3 Years ago.

RE: Liferay 7 - Ext plugin - Can I do it without?

New Member Posts: 2 Join Date: 5/12/20 Recent Posts
I want to achieve the exact same thing as the author of the post. I just found a solution that does not require the use of an ext plugin (I patched 1 Liferay class, LanguageImpl).
So I don't need help anymore but I'm still curious on how he precisely manage to make it work. Maybe I can enhance my solution with his ideas.
For example, how to detect that the translations need to be reloaded?