-
Notifications
You must be signed in to change notification settings - Fork 183
[candidate_list] Translate candidate_list module #9797
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
base: main
Are you sure you want to change the base?
Conversation
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.
0a97362
to
4cc141e
Compare
}; | ||
|
||
window.addEventListener('load', () => { | ||
const args = QueryString.get(); | ||
i18n.addResourceBundle('ja', 'candidate_list', jaStrings); |
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.
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?
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.
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.
@@ -21,3 +21,20 @@ msgstr "" | |||
msgid "Access Profile" | |||
msgstr "" | |||
|
|||
msgid "Entity Type" |
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.
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.
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.
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.
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.