-
Couldn't load subscription status.
- Fork 186
[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
Conversation
|
Couple questions to make sure I understand.
|
|
|
Just reread and realized I phrased 2. poorly. The |
|
This was discussed at the roadmap meeting and it was decided to merge it into the dev branch after creating the release branch for the release which is currently being tested. |
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.
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.
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.
This PR follows structure of #9747 and adds a similar infrastructure for the translation of the Menu bar to Hindi.
This builds on #9747 to add support for translating the "My Tasks" widgets on the LORIS dashboard. In the current code, an "s" is hardcoded to be added when count > 1, which doesn't work for other languages. The signature had to be updated to include a singular and plural label, as well as the text domain that the labels come from, since they come from the module providing the widget and not the dashboard. (The dngettext call also could not be done in the module, because the module doesn't have the count to know if it's plural.)
This PR follows structure of aces#9747 and adds a similar infrastructure for the translation of the Menu bar to Hindi.
This builds on aces#9747 to add support for translating the "My Tasks" widgets on the LORIS dashboard. In the current code, an "s" is hardcoded to be added when count > 1, which doesn't work for other languages. The signature had to be updated to include a singular and plural label, as well as the text domain that the labels come from, since they come from the module providing the widget and not the dashboard. (The dngettext call also could not be done in the module, because the module doesn't have the count to know if it's plural.)
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 $modulenamedo 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
.pofile for another language for testing.)locale -ato see which locales are available on your system.