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

Multilingual Emails #8044

Merged
merged 25 commits into from
Jun 19, 2024
Merged

Conversation

tylerjmchugh
Copy link
Contributor

Emails are currently sent in the UI language of the sender regardless of the preferences of the receiver.

This PR implements a framework for generating multilingual emails including:

  • A configuration field in settings>feedback to specify which languages to send emails in.
  • Another configuration field to specify the "translation follows" text at the start of the email. (Can include multiple languages).

Email messages for all specified languages will be concatenated with a separator.
If the settings fields are left empty, default back to the UI language.

Related feature request: #7966

image

Checklist

  • I have read the contribution guidelines
  • Pull request provided for main branch, backports managed with label
  • Good housekeeping of code, cleaning up comments, tests, and documentation
  • Clean commit history broken into understandable chucks, avoiding big commits with hundreds of files, cautious of reformatting and whitespace changes
  • Clean commit messages, longer verbose messages are encouraged
  • API Changes are identified in commit messages
  • Testing provided for features or enhancements using automatic tests
  • User documentation provided for new features or enhancements in manual
  • Build documentation provided for development instructions in README.md files
  • Library management using pom.xml dependency management. Update build documentation with intended library use and library tutorials or documentation

@ianwallen ianwallen added this to the 4.4.5 milestone May 16, 2024
Copy link
Contributor

@ianwallen ianwallen left a comment

Choose a reason for hiding this comment

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

Tested locally and works as expected.

I'm not sure if some of the new files are in the preferred location - I will let others comment on if some of the new files should be placed in different location.

@tylerjmchugh tylerjmchugh marked this pull request as ready for review May 16, 2024 18:45
@fxprunayre
Copy link
Member

I'm not sure if some of the new files are in the preferred location - I will let others comment on if some of the new files should be placed in different location.

LGTM.

@josegar74
Copy link
Member

josegar74 commented May 17, 2024

Tested with the default configuration (no languages configured), I get a NullPointerException when submitting a metadata to review:

https://github.com/geonetwork/core-geonetwork/pull/8044/files#diff-8ffe27a26ea5dc5d13d71bdc2dfbd7afd4aaea80037f18bf304d9754aaaf7818R182

It fails internally in

https://github.com/geonetwork/core-geonetwork/pull/8044/files#diff-1c4dbe5c43914f0b170604f63ec220e17bdf72b3dd6b6a4951c8c13583c50336R309


It happens also when configuring the languages in the settings.

…lingual-emails

# Conflicts:
#	core/src/main/java/org/fao/geonet/kernel/search/EsSearchManager.java
#	core/src/main/java/org/fao/geonet/util/XslUtil.java
#	index/src/main/java/org/fao/geonet/index/es/EsRestClient.java
@tylerjmchugh
Copy link
Contributor Author

Tested with the default configuration (no languages configured), I get a NullPointerException when submitting a metadata to review:

https://github.com/geonetwork/core-geonetwork/pull/8044/files#diff-8ffe27a26ea5dc5d13d71bdc2dfbd7afd4aaea80037f18bf304d9754aaaf7818R182

It fails internally in

https://github.com/geonetwork/core-geonetwork/pull/8044/files#diff-1c4dbe5c43914f0b170604f63ec220e17bdf72b3dd6b6a4951c8c13583c50336R309

Reproduced the first issue and it seems to be fixed after merging the changes from #8042.

It happens also when configuring the languages in the settings.

I am however unable to reproduce the issue while configuring the languages.

@josegar74 josegar74 modified the milestones: 4.4.5, 4.4.6 Jun 3, 2024
Copy link
Member

@josegar74 josegar74 left a comment

Choose a reason for hiding this comment

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

Changes look good, the error is solved.

Please wait to merge it until 4.4.5 is released.

} catch (MissingResourceException e) {
failedToFindASpecificTextTemplate = true;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
}
}
if ((failedToFindASpecificSubjectTemplate) && (failedToFindASpecificTextTemplate)) break;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added loop breaking logic in latest push

@ianwallen ianwallen merged commit 1fd8b52 into geonetwork:main Jun 19, 2024
6 checks passed
@geonetworkbuild
Copy link
Collaborator

The backport to 4.2.x failed:

The process '/usr/bin/git' failed with exit code 1
stderr
error: could not apply c7c49917de... Add spring bean to initialize feedback email locales from settings field
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config advice.mergeConflict false"

stdout
Auto-merging core/src/main/java/org/fao/geonet/kernel/setting/Settings.java
Auto-merging web-ui/src/main/resources/catalog/locales/en-admin.json
Auto-merging web/src/main/webapp/WEB-INF/classes/setup/sql/data/data-db-default.sql
Auto-merging web/src/main/webapp/WEB-INF/classes/setup/sql/migrate/v4211/migrate-default.sql
[backport-8044-to-4.2.x 8b60cecc19] Add settings fields for localized emails
 Author: tylerjmchugh <Tyler.McHugh@dfo-mpo.gc.ca>
 Date: Wed May 15 15:26:53 2024 -0400
 4 files changed, 11 insertions(+)
Auto-merging core/src/main/resources/config-spring-geonetwork.xml
CONFLICT (content): Merge conflict in core/src/main/resources/config-spring-geonetwork.xml

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-4.2.x 4.2.x
# Navigate to the new working tree
cd .worktrees/backport-4.2.x
# Create a new branch
git switch --create backport-8044-to-4.2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick 146f1846bc4a660175911d637aaa3747878acd95,c7c49917de61879bc6ea2b445548259b784bf585,80a7d267b665062cbe40a497aeaad96af7a664a0,acf4147484bd09d9619059c36a3689a47e6ac741,88f20681d008692b2b03f843a7440107ad4778c4,3fab7c320f280cbc11e5898b56ca3f16d4ed77a9,da0f5450d6dd0cec45e96c093e267a2a78916761,cc8310172a9811c474716503fc36a372999c05be,3d6b6cee7a70f7cca377a5fdbf881bf823e85165,9988d7d8a0fe1edcbdeb6f180cb7faa1f90ceacf,c94dd7b6b6301084cac0943561e20e7b947ff381,461e4c5112929420ae2ea0409cff56f8c2d6271d,a8f4d1126e1d5aa7a431fbfb0e53eee76a148a0e,bd1dc23c6dfef3b6da210e15f9b1f1a50d3b2578,3f5a3af79fd74049a48b36b9f614d0522a9460bd,2a56de3a52f2e1c5683756f7cb480aee93bf03c2,4319bb67c4e786649744ef01d8fb4dfe89cdf55a,ae96904af72a3fef40fb8deeded6f56d2d28b746,6c4f65307ea3c50c3233a03be2661115ad7c446e,cbcdf2dd39fe347d32a0f4f4709788082a9a2782,b3c45475304024437b79bbca28a645b268822fca,54719604fc2d586fae3401cb346a7979c2100d81,c2599a4c7f35d3b1c5d22bdab867c9d8b35168f5,5e8d4b54236621c12ec4d8c6474b79c8e8e5fbf4,4d6825fa78439641bb6ffc6fcd19a28386fa1e1c
# Push it to GitHub
git push --set-upstream origin backport-8044-to-4.2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-4.2.x

Then, create a pull request where the base branch is 4.2.x and the compare/head branch is backport-8044-to-4.2.x.

ianwallen pushed a commit that referenced this pull request Jun 20, 2024
* Add settings fields for localized emails

* Add spring bean to initialize feedback email locales from settings field

* Modify settings manager to update feedback locales when the settings fields are saved

* Create classes for localized emails, their components, and the components' parameters

* Implement lang in getIndexField

* Localize workflow status emails

* Localize metadata publication emails

* Localize user feedback emails

* Localize RegisterApi emails

* Localize PasswordApi emails

* Localize WatchListNotifier emails

* Localize MailApi emails

* Update migration script to only insert settings fields if not present

* Add static enum imports for readability

* Log a warning when a locale is invalid or missing

* Update log modules and messages

* Trim language codes defined in settings to handle spaces after commas

* Rename translation follows label to translation follows text for consistency

* Add back resource bundle 'messages' that was unused before merging main

* Add logic to break from loop when email subject and text messages fail
ianwallen pushed a commit that referenced this pull request Jun 20, 2024
* Add settings fields for localized emails

* Add spring bean to initialize feedback email locales from settings field

* Modify settings manager to update feedback locales when the settings fields are saved

* Create classes for localized emails, their components, and the components' parameters

* Implement lang in getIndexField

* Localize workflow status emails

* Localize metadata publication emails

* Localize user feedback emails

* Localize RegisterApi emails

* Localize PasswordApi emails

* Localize WatchListNotifier emails

* Localize MailApi emails

* Update migration script to only insert settings fields if not present

* Add static enum imports for readability

* Log a warning when a locale is invalid or missing

* Update log modules and messages

* Trim language codes defined in settings to handle spaces after commas

* Rename translation follows label to translation follows text for consistency

* Add back resource bundle 'messages' that was unused before merging main

* Add logic to break from loop when email subject and text messages fail
ianwallen pushed a commit that referenced this pull request Jun 20, 2024
* Add settings fields for localized emails

* Add spring bean to initialize feedback email locales from settings field

* Modify settings manager to update feedback locales when the settings fields are saved

* Create classes for localized emails, their components, and the components' parameters

* Implement lang in getIndexField

* Localize workflow status emails

* Localize metadata publication emails

* Localize user feedback emails

* Localize RegisterApi emails

* Localize PasswordApi emails

* Localize WatchListNotifier emails

* Localize MailApi emails

* Update migration script to only insert settings fields if not present

* Add static enum imports for readability

* Log a warning when a locale is invalid or missing

* Update log modules and messages

* Trim language codes defined in settings to handle spaces after commas

* Rename translation follows label to translation follows text for consistency

* Add back resource bundle 'messages' that was unused before merging main

* Add logic to break from loop when email subject and text messages fail
ianwallen added a commit that referenced this pull request Jun 20, 2024
* Add settings fields for localized emails

* Add spring bean to initialize feedback email locales from settings field

* Modify settings manager to update feedback locales when the settings fields are saved

* Create classes for localized emails, their components, and the components' parameters

* Implement lang in getIndexField

* Localize workflow status emails

* Localize metadata publication emails

* Localize user feedback emails

* Localize RegisterApi emails

* Localize PasswordApi emails

* Localize WatchListNotifier emails

* Localize MailApi emails

* Update migration script to only insert settings fields if not present

* Add static enum imports for readability

* Log a warning when a locale is invalid or missing

* Update log modules and messages

* Trim language codes defined in settings to handle spaces after commas

* Rename translation follows label to translation follows text for consistency

* Add back resource bundle 'messages' that was unused before merging main

* Add logic to break from loop when email subject and text messages fail

Co-authored-by: tylerjmchugh <163562062+tylerjmchugh@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants