-
Notifications
You must be signed in to change notification settings - Fork 181
[i18n] Add support for 日本語 #9747
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
Open
driusan
wants to merge
1
commit into
aces:main
Choose a base branch
from
driusan:TranslateMenus
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Merged
This puts the infrastructure in place to translate strings in loris on the PHP side using the gettext library. Japanese is added as an example (mostly using machine translation which could probably use proof reading by a native speaker.) Each module has its own textdomain for strings that come from that module, as well as a "loris" textdomain for general LORIS terms (menu categories, common terms, etc). The translations for a module are in $MODULEDIR/locale and the loris textdomain is in $LORISROOT/locale. The module names, menu categories, and breadcrumb text are currently marked up as translateable strings. This is enough to ensure that the menus and breadcrumbs in LORIS get translated. A new LORIS middleware detects the preferred language by looking for: 1. A lang=? passed in the query parameter (this can be used for testing, but does not currently have any way in the GUI to select) 2. The User's preference under "my_preferences" 3. The HTTP request's Accept-Language header in that order and ensuring that it's a language supported by the project by looking for the language_code in the LORIS "language" table. The pot files at the root of the locale directories are translation templates to give to translators. The locale/$lang/LC_MESSAGES/$textdomain.po contain the translation mapping. The .mo files are the compiled version used by the software and can be generated by "make locales". (We may want to rethink the structure of the Makefile in the future to have `make $modulename` do both the locale and javascript compilation.) Projects may override strings by putting the (compiled) gettext .mo file in the $project/locale/ directory (which would also be a good place to store the .po files). These are generated with `msgfmt -o filename.mo inputfile.po` (msgfmt is included with gettext.) Note that the format of the locale directories must be: locale/$lang/LC_MESSAGES/$textdomain.mo. We do not have any control over that. (Other then the name of the first "locale" directory, but that seems pretty standard.) It's also worth noting that, from what I've read, the *server* must have the locale installed for gettext to support the translation, not just LORIS. I don't know why. It seems silly.
Couple questions to make sure I understand.
|
|
Just reread and realized I phrased 2. poorly. The |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Category: Feature
PR or issue that aims to introduce a new feature
Language: PHP
PR or issue that update PHP code
Module: acknowledgements
PR or issue related to acknowledgements module
Module: api_docs
PR or issue related to api_docs module
Module: battery_manager
PR or issue related to battery_manager module
Module: behavioural_qc
PR or issue related behavioural_qc module
Module: brainbrowser
PR or issue related to brainbrowser module
Module: bvl_feedback
PR or issue related to bvl_feedback module
Module: candidate_list
PR or issue related to candidate_list module
Module: candidate_parameters
PR or issue related to candidate_parameters module
Module: candidate_profile
PR or issue related to candidate_profile module
Module: configuration
PR or issue related to configuration module
Module: conflict_resolver
PR or issue related to conflict_resolver module
Module: create_timepoint
PR or issue related to create_timepoint module
Module: dashboard
PR or issue related to dashboard module
Module: data_release
PR or issue related to data_release module
Module: datadict
PR or issue related to (old) datadict module
Module: dataquery
PR or issue related to (new) dataquery module
Module: dicom_archive
PR or issue related to dicom_archive module
Module: dictionary
PR or issue related to (new) dictionary module
Module: document_repository
PR or issue related to documen_repository module
Module: dqt
PR or issue related to (old) dqt module
Module: electrophysiology_browser
PR or issue related to electrophysiology_browser module
Module: electrophysiology_uploader
PR or issue related to electrophysiology_uploader
Module: examiner
PR or issue related to examiner module
Module: genomic_browser
PR or issue related to genomic_browser module
Module: help_editor
PR or issue related to help_editor module
Module: imaging_browser
PR or issue related to imaging_browser module
Module: imaging_qc
PR or issue related to imaging_qc module
Module: imaging_uploader
PR or issue related to imaging_uploader module
Module: instrument_builder
PR or issue related to instrument_builder module
Module: instrument_list
PR or issue related to instrument_list module
Module: instrument_manager
PR or issue related to instrument_manager module
Module: instruments
PR or issue related to instruments module
Module: issue_tracker
PR or issue related to issue tracker module
Module: login
PR or issue related to login module
Module: media
PR or issue related to media module
Module: module_manager
PR or issue related to module_manager module
Module: mri_violations
PR or issue related to mri_violations module
Module: my_preferences
PR or issue related to my_preferences module
Module: new_profile
PR or issue related to new_profile module
Module: next_stage
PR or issue related to next_stage module
Module: oidc
PR or issue related to the oidc (OpenID Connect) module
Module: publication
PR or issue related to the publication module
Module: schedule_module
PR or issue related to the schedule_manager module
Module: server_processes_manager
PR or issue related to the server_processes_manger
Module: statistics
PR or issue related to statistics module
Module: survey_accounts
PR or issue related to the survey_accounts module
Module: timepoint_list
PR or issue related to the timepoint_list module
Module: user_accounts
PR or issue related to the user_accounts module
Multilingual
Any tasks related to making LORIS multilingual
Release: Add to release notes
PR whose changes should be highlighted in the release notes
State: Discussion required
PR or issue that requires the resolution of a discussion with the relevant parties to proceed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This puts the infrastructure in place to translate strings in loris on the PHP side using the gettext library. Japanese is added as an example (mostly using machine translation which could probably use proof reading by a native speaker.)
Each module has its own textdomain for strings that come from that module, as well as a "loris" textdomain for general LORIS terms (menu categories, common terms, etc). The translations for a module are in $MODULEDIR/locale and the loris textdomain is in $LORISROOT/locale.
The module names, menu categories, and breadcrumb text are currently marked up as translateable strings. This is enough to ensure that the menus and breadcrumbs in LORIS get translated.

A new LORIS middleware detects the preferred language by looking for:
in that order and ensuring that it's a language supported by the project by looking for the language_code in the LORIS "language" table.
The pot files at the root of the locale directories are translation templates to give to translators. The locale/$lang/LC_MESSAGES/$textdomain.po contain the translation mapping. The .mo files are the compiled version used by the software and can be generated by "make locales". (We may want to rethink the structure of the Makefile in the future to have
make $modulename
do both the locale and javascript compilation.)Projects may override strings by putting the (compiled) gettext .mo file in the $project/locale/ directory (which would also be a good place to store the .po files). These are generated with
msgfmt -o filename.mo inputfile.po
(msgfmt is included with gettext.)Note that the format of the locale directories must be: locale/$lang/LC_MESSAGES/$textdomain.mo. We do not have any control over that. (Other then the name of the first "locale" directory, but that seems pretty standard.)
It's also worth noting that, from what I've read, the server must have the locale installed for gettext to support the translation, not just LORIS. I don't know why. It seems silly.
Testing instructions
.po
file for another language for testing.)locale -a
to see which locales are available on your system.