Skip to content

[candidate_list] Translate candidate_list module#9797

Merged
driusan merged 7 commits intoaces:mainfrom
driusan:TranslateCandidateList
Jul 8, 2025
Merged

[candidate_list] Translate candidate_list module#9797
driusan merged 7 commits intoaces:mainfrom
driusan:TranslateCandidateList

Conversation

@driusan
Copy link
Collaborator

@driusan driusan commented May 16, 2025

This translates the candidate list module as an example of how to do localization of a loris module that is written in React with class based components.

JSON files are generated from the same .po files used by the PHP side of file, which are then imported into the i18next resources. They are generated at compile time with the i18next-conv package. Modules (in this case candidate_list) must call the addResourceBundle method of i18next to add the strings which are specific to their module.

This example uses the withTranslation HOC, but functional components can use the useTranslation hook instead.

Note that in this PR I only translated the strings from the candidate_list module itself used by the filters/headers to serve as an example. There are other strings which come from components in the jsx/ directory which are shared across all modules. Those will be in other PRs since they are a one-time effort for all modules.


window.addEventListener('load', () => {
const args = QueryString.get();
i18n.addResourceBundle('ja', 'candidate_list', jaStrings);
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this only get added if the user preference is japanese? if we were to add support for more languages, would each language bundle need to be added here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The resource bundle gets added for all users in the javascript but will only get used if the language is ja. We would need to add each language call here.

If we use a backend different loader than the json object resources way in i18next (ie if we used the http backend), there is an option to only load the used language, but since it's being compiled into the module's js here I don't think there's any reason to not just add the resources.

msgid "Access Profile"
msgstr ""

msgid "Entity Type"
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there a way to combine these so that we have the msgid, and then have all the listed translations? Or is this the standard way to do it? It just seems that it would be easier to maintain with the msgids written once, rather than repeated across files.

Copy link
Collaborator Author

@driusan driusan May 23, 2025

Choose a reason for hiding this comment

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

No, this is a standard way to do it. All the translations to the same language are grouped together, not all the different language translations for a given string.

@SKADE2303
Copy link
Contributor

Screenshot from 2025-06-26 22-37-36

Hey @driusan ! I was testing the PR out and noticed that some of the strings don't translate. I initially thought it might be a language issue so I tested it out using Hindi language as well. Could you kindly let me know if there is something I'm missing out for the translation of the marked strings?

@driusan
Copy link
Collaborator Author

driusan commented Jun 27, 2025

@SKADE2303 Thanks for testing this with another language! I'm able to reproduce so I'll look into it. "Access Profile" should definitely be translated, there seems to be a regression since #9747. I'll look into it and see about the other ones as well (I think the reason they're not being translated is because they're from core jsx components, not the module itself, but I can't remember if that was supposed to be done in this PR or not..)

@driusan driusan force-pushed the TranslateCandidateList branch from 5aa7297 to b8bffc0 Compare June 27, 2025 13:21
@driusan
Copy link
Collaborator Author

driusan commented Jun 27, 2025

@SKADE2303 It turns out there wasn't a regression but a typo in my language table (I had my language code set to ja-JP instead of ja_JP and it needs to match the systems..) now that I fixed it, it also turns out that that one breadcrumb was missed so it should be fixed in the latest commit.

The other strings are coming from core jsx components, rather than the module's, and I think should be done in another PR.

@driusan
Copy link
Collaborator Author

driusan commented Jun 27, 2025

@SKADE2303 if the Breadcrumb isn't fixed in the latest commit can you check your language table and that the hyphenation of the language_code matches your system's in locales -a?

@driusan
Copy link
Collaborator Author

driusan commented Jun 27, 2025

It ended up not being a huge amount of changes so I did the Filter/DataTable changes in this PR. It should be fully translated now (though you'll have to add a few more strings from the .pot to your Hindi translation..)

@racostas racostas assigned racostas and unassigned racostas Jul 4, 2025
@racostas racostas self-requested a review July 4, 2025 13:24
Copy link
Contributor

@racostas racostas left a comment

Choose a reason for hiding this comment

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

There are some integrations tests that seems to be failing but functionality looks good ! Here an image of my test in Spanish:
image

If you can please check what is falling with the test / merge this PR ? @SKADE2303 is currently working in other translations but this PR offers infrastructure for them.

Thanks !

@racostas racostas added the Event: GSOC PR or issue accepted for Google Summer of Code label Jul 4, 2025
@driusan driusan force-pushed the TranslateCandidateList branch from 3bd0e24 to 2975847 Compare July 4, 2025 14:51
@driusan driusan removed Module: battery_manager PR or issue related to battery_manager module Module: datadict PR or issue related to (old) datadict module Module: server_processes_manager PR or issue related to the server_processes_manger Module: user_accounts PR or issue related to the user_accounts module labels Jul 4, 2025
@driusan
Copy link
Collaborator Author

driusan commented Jul 4, 2025

@racostas I reverted the changes to the DataTable so I can move it to another PR.

It turns out that for the string to be translated all the entry points that use the DataTable need to be updated.

@github-actions github-actions bot added the Module: statistics PR or issue related to statistics module label Jul 4, 2025
@driusan driusan mentioned this pull request Jul 4, 2025
@racostas racostas self-requested a review July 7, 2025 18:52
Copy link
Contributor

@racostas racostas left a comment

Choose a reason for hiding this comment

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

Re-tested. LGTM, and better now that was divided in two.
This one is ready to be merge IMO, I will review now #9893

@racostas racostas added the Passed manual tests PR has been successfully tested by at least one peer label Jul 7, 2025
@racostas
Copy link
Contributor

racostas commented Jul 7, 2025

image

@racostas
Copy link
Contributor

racostas commented Jul 7, 2025

@driusan , I re-reviewed. Ready to be merged. I will review also #9893 (blocked by this one)

@racostas racostas added the State: Blocking PR should be prioritized because it is blocking the progress of another task label Jul 7, 2025
@driusan driusan merged commit adb9f85 into aces:main Jul 8, 2025
20 checks passed
jeffersoncasimir pushed a commit to jeffersoncasimir/Loris that referenced this pull request Aug 11, 2025
This translates the candidate list module as an example of how to do
localization of a loris module that is written in React with class based
components.

JSON files are generated from the same `.po` files used by the PHP side
of file, which are then imported into the i18next resources. They are
generated at compile time with the i18next-conv package. Modules (in
this case candidate_list) must call the addResourceBundle method of
i18next to add the strings which are specific to their module.

This example uses the withTranslation HOC, but functional components can
use the useTranslation hook instead.
driusan pushed a commit that referenced this pull request Sep 4, 2025
This PR translates Candidate_List according to the #9797 to Hindi.
The translation strings were added to the Hindi .po file and converted
into JSON using the i18next-conv tool at build time. The module
registers its localized strings using i18next.addResourceBundle.

* Resolves #9806
SKADE2303 added a commit to SKADE2303/Loris that referenced this pull request Sep 5, 2025
…9899)

This PR translates Candidate_List according to the aces#9797 to Hindi.
The translation strings were added to the Hindi .po file and converted
into JSON using the i18next-conv tool at build time. The module
registers its localized strings using i18next.addResourceBundle.

* Resolves aces#9806
driusan pushed a commit that referenced this pull request Oct 9, 2025
This provides the infrastructure for the translation of the module
new_profile to another language. The translation is done in a similar
method as #9797 .

* Resolves #9807
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Event: GSOC PR or issue accepted for Google Summer of Code Language: Javascript PR or issue that update Javascript code Language: PHP PR or issue that update PHP code Module: candidate_list PR or issue related to candidate_list module Module: statistics PR or issue related to statistics module Multilingual Any tasks related to making LORIS multilingual Passed manual tests PR has been successfully tested by at least one peer State: Blocking PR should be prioritized because it is blocking the progress of another task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants