Skip to content
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

WIP:Added Internationalization module #228

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

WIP:Added Internationalization module #228

wants to merge 8 commits into from

Conversation

vapadwal
Copy link
Member

@vapadwal vapadwal commented Apr 2, 2020

No description provided.

@vapadwal vapadwal added the help wanted Extra attention is needed label Apr 3, 2020
@vapadwal
Copy link
Member Author

vapadwal commented Apr 3, 2020

Need help in solving the kafka error @maihacke or @ravicm2

@maihacke
Copy link
Member

maihacke commented Apr 3, 2020

Need help in solving the kafka error @maihacke or @ravicm2

The issue has been fixed on develop,. Please merge the current devon4j/develop into this branch.

@vapadwal
Copy link
Member Author

vapadwal commented Apr 3, 2020

Need help in solving the kafka error @maihacke or @ravicm2

The issue has been fixed on develop,. Please merge the current devon4j/develop into this branch.

Thx @maihacke will take the latest from develop

@vapadwal vapadwal removed the help wanted Extra attention is needed label Apr 6, 2020
@vapadwal vapadwal requested a review from hohwille April 6, 2020 07:03
@vapadwal vapadwal changed the title WIP : Added Internationalization module Added Internationalization module Apr 6, 2020
Copy link
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for providing this PR. However, I think here we more or less took over an existing legacy feature without properly questioning if that feature makes sense at all this way.
To what I understood now, this module seems to add the ability to provide a service that exposes the Java i18n resource-bundles to JSON. My assumption is that this might be used to reuse them on the client side. If we look at the way devon4ng resp. Angular is dealing with i18n I would put this entire module in question.
Further it is lacking our general code-standards:

  • remove @author tags
  • add @since tags
  • remove pointless @interitDoc
  • add proper JavaDoc where missing
  • Autoformat the code to avoid pointless blank lines
  • I started the review and added some first review comments. However, I would question if we shoud do a full stop and actually dump this. I assume that nobody will ever use this code. If I am wrong please let me know and tell me your use-case.

* @return Json String
* @throws Exception
*/
String getResourceObject(String locale, String filter) throws Exception;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anti-Pattern: Do not declare API that throws Exception. We also have the best-practice in devon4j not to use checked exceptions:
https://github.com/devonfw/devon4j/blob/develop/documentation/guide-exceptions.asciidoc#exception-principles

* Gets the JSON string for specified locale and filter
*
* @param locale locale
* @param filter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is a filter here?
This JavaDoc is not helpful.

* @return
* @throws Exception
*/
String getResourceAsJson(String locale, String filter) throws Exception;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what is the difference between I18n and LocaleResourceFactory except the name of the method?
I do not get this and it seems kind of odd to me.

throw de;
} catch (Exception e) {
LOGGER.error("Exception in getResourcesAsJSONStringUsingMMM ", e);
throw e;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public String getResourceAsJson(String locale, String filter) throws Exception {

String strJSON = null;
HashMap<String, String> resourceMap = new HashMap<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (locale == null || locale.isEmpty() || !LocaleUtils.availableLocaleSet().contains(objLocale)) {
throw new UnknownLocaleException(I18nConstants.INVALID_LOCALE);
} else {
resourceMap = (HashMap<String, String>) I18nUtils.getResourcesGeneratedFromMMMAsMap(objLocale);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @throws Exception thrown by getResourcesGeneratedFromMMMAsMap
*/

public static Map<String, String> getResourcesGeneratedFromMMMAsMap(Locale locale) throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid CAPITALIZED segments in names but use camlCaseAlsoForAbbreviationsLikeMmm.
https://github.com/devonfw/devon4j/blob/develop/documentation/coding-conventions.asciidoc#naming

String subKey = filter.substring(0, indexOfDot);
JsonObject jsonObject = (JsonObject) objJSON.get(subKey);
count++;
strJSONKey = strJSONKey + "{\"" + subKey + "\":";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also seems an anti-pattern to me to generate JSON via "string-fiddling".
Is maybe gson the wrong choice here? I have not used it as there is a JEE standard JSON-P for it and we comitted to use JEE standards where suitable instead of using proprietary solutions:
https://github.com/devonfw/devon4j/blob/develop/documentation/guide-jee.asciidoc#jee

/**
* Opening bracket
*/
public static final String OPENING_BRACE = "{";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO such stuff does not belong here:

  1. it is an implementation pointlessly exposed to the public
  2. it has nothing to do with I18n but is due to the fact that we decided to use JSON serialization here.

@vapadwal vapadwal changed the title Added Internationalization module WIP:Added Internationalization module Apr 21, 2020
hohwille added a commit to hohwille/devon4j that referenced this pull request Sep 1, 2020
hohwille added a commit that referenced this pull request Sep 9, 2020
@hohwille hohwille changed the base branch from develop to master January 7, 2021 15:58
@maybeec maybeec marked this pull request as draft November 8, 2021 05:26
@baumeister25
Copy link

I agree to @hohwille to dump and close this PR. Does not look like someone is working on it anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants