-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LPD-41528 Add batch GET method to Language Override APIs #786
base: master
Are you sure you want to change the base?
LPD-41528 Add batch GET method to Language Override APIs #786
Conversation
The following guidelines have been set by the owner of this repository:
|
To conserve resources, the PR Tester does not automatically run for every pull. If your code changes were already tested in another pull, reference that pull in this pull so the test results can be analyzed. If your pull was never tested, comment "ci:test" to run the PR Tester for this pull. |
.../apps/frontend-js/frontend-js-web/src/main/resources/META-INF/resources/liferay/liferay.d.ts
Outdated
Show resolved
Hide resolved
The changes to our modules is fine. The other caching stuff I have no idea what's going on haha. I can look into that deeper on Monday |
@thiago-buarqque don't miss -> #786 (comment) |
...al/language/rest/internal/service/access/policy/LanguagePortalInstanceLifecycleListener.java
Outdated
Show resolved
Hide resolved
88afa88
to
e7a9e6b
Compare
After discussion with @izaera I will remove the javascript change and just leave the headless api for this PR. Then frontend infra Product Management can decide how to proceed with solutions to that aspect of the problem. |
@thiago-buarqque this change now only contains changes in portal-language-rest-* (and language keys) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @rotty3000, it's missing the implementation for testPostMessagesExportPage
return; | ||
} | ||
|
||
Map<Locale, String> map = ResourceBundleUtil.getLocalizationMap( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: rename to localizationMap
@@ -213,6 +213,11 @@ public void testPutMessage() throws Exception { | |||
Assert.assertTrue(false); | |||
} | |||
|
|||
@Test | |||
public void testPostMessagesExportPage() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing implementation for this
Not wanting to start another long discussion, but we decided to remove I mean, I get it could be used for legacy code, but I don't want to add a new public method to an old API to give the impression that we want people to keep using it in the future. I prefer to explore better options first. And when I say "I" it's me, not my product manager or team lead. In any case we will discuss this in the team and see what comes next... |
Let me explain myself: why using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good for me since the JS code has been removed.
Regarding the headless API I'll leave the review up to Thiago 👍
Why use Liferay.Language.get()? For consistency. JS code that is using that will work if it is served out of Liferay (through the servlet filter) or from a CX with no significant change. That's what we're hoping for with this, the platform taking care of the differences transparently, not requiring the developer to handle both scenarios manually. |
Yep, that would be the only reason and Ray and I discussed it yesterday but for that to happen we need more machinery because:
Said that, if the CXs provided a list of label keys to load (as we do internally for each JAR file with a Finally, take into account that whatever we do to make this work outside of Liferay will work in Liferay, which IMO is much better than using the LanguageFilter. What I mean is that if you (or the platform) request the labels through headless and put them in the Liferay.Language cache, you won't need the filter any more since it will work in all scenarios. The same would happen now (even in the absence of proper infrastructure) if you decided to retrieve your labels from the server and store them inside any localization facility your framework of choice provides, and it would probably integrate better with your framework than Liferay.Language 😉 |
So, for example, as I suggested @rotty3000 yesterday, when using React you can use things like this -> https://react.i18next.com/latest/i18nextprovider and this -> https://react.i18next.com/latest/i18next-instance and you get React-friendly translations. Why using Liferay-friendly translations when you can integrate them and hide them behind React-friendly translations if all your app is written in React? To me it doesn't make sense to plague your code with invocations to platform vendor's API when you can make it agnostic 🤷 |
I may be wrong, I haven't tried to create a full example with the links I've pasted, but it looks to me that loading a bunch of labels from a server and provide them to the framework you are using to render your UI is something most frameworks will support one way or another... |
@thiago-buarqque please take this PR and feel free to continue with it. I won't have time to continue to make changes to it. I was just trying to be helpful. |
@thiago-buarqque when you have some time, let's take advantage of the work Ray put in to add the Batch get method to language override. You can create a new PR that removes all of the JS stuff since that's outside of our team's scope. |
@rotty3000 @ethib137 Okay, I will work on this as soon as possible. There are some priorities to address right now. |
the JS parts are already removed! |
Guys, still no time to work on this, will do ASAP |
https://liferay.atlassian.net/browse/LPD-41528
Begin by enabling the feature flag:
feature.flag.LPD-27222=true
Next, somewhere, either in custom code or perhaps as an additional API in Liferay's libraries, define the following reusable function:
This function, in addition to this PR, constitutes the reusable portion.
Next in custom code, a developer would collect the language keys used by their application in a JSON array:
and finally, early in the initalization of their app, before any rendering occurs the following function (newly added by this PR) would be invoked:
With that, all existing invocations of
Liferay.Language.get('key')
will simply work.Use the following to test the api with curl:
result should be: