Skip to content

Commit 970bfb8

Browse files
author
Dave MacFarlane
committed
[candidate_list] Translate candidate_list module
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.
1 parent 55bdc0d commit 970bfb8

File tree

11 files changed

+513
-38
lines changed

11 files changed

+513
-38
lines changed

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
.PHONY: clean dev all check checkstatic unittests phpdev jslatest testdata fastdev jsdev
1+
.PHONY: clean dev all check checkstatic unittests phpdev jslatest testdata fastdev jsdev locales
22

3-
all: VERSION
3+
all: locales VERSION
44
composer install --no-dev
55
npm ci
66
npm run build
@@ -12,7 +12,7 @@ VERSION: .
1212
phpdev:
1313
composer install
1414

15-
dev: phpdev jsdev fastdev
15+
dev: locales phpdev jsdev fastdev
1616

1717
jsdev:
1818
npm ci
@@ -59,6 +59,7 @@ testdata:
5959

6060
locales:
6161
msgfmt -o locale/ja/LC_MESSAGES/loris.mo locale/ja/LC_MESSAGES/loris.po
62+
npx i18next-conv -l ja -s locale/ja/LC_MESSAGES/loris.po -t locale/ja/LC_MESSAGES/loris.json
6263
msgfmt -o modules/new_profile/locale/ja/LC_MESSAGES/new_profile.mo modules/new_profile/locale/ja/LC_MESSAGES/new_profile.po
6364
msgfmt -o modules/acknowledgements/locale/ja/LC_MESSAGES/acknowledgements.mo modules/acknowledgements/locale/ja/LC_MESSAGES/acknowledgements.po
6465
msgfmt -o modules/api_docs/locale/ja/LC_MESSAGES/api_docs.mo modules/api_docs/locale/ja/LC_MESSAGES/api_docs.po
@@ -67,6 +68,7 @@ locales:
6768
msgfmt -o modules/brainbrowser/locale/ja/LC_MESSAGES/brainbrowser.mo modules/brainbrowser/locale/ja/LC_MESSAGES/brainbrowser.po
6869
msgfmt -o modules/bvl_feedback/locale/ja/LC_MESSAGES/bvl_feedback.mo modules/bvl_feedback/locale/ja/LC_MESSAGES/bvl_feedback.po
6970
msgfmt -o modules/candidate_list/locale/ja/LC_MESSAGES/candidate_list.mo modules/candidate_list/locale/ja/LC_MESSAGES/candidate_list.po
71+
npx i18next-conv -l ja -s modules/candidate_list/locale/ja/LC_MESSAGES/candidate_list.po -t modules/candidate_list/locale/ja/LC_MESSAGES/candidate_list.json
7072
msgfmt -o modules/candidate_parameters/locale/ja/LC_MESSAGES/candidate_parameters.mo modules/candidate_parameters/locale/ja/LC_MESSAGES/candidate_parameters.po
7173
msgfmt -o modules/candidate_profile/locale/ja/LC_MESSAGES/candidate_profile.mo modules/candidate_profile/locale/ja/LC_MESSAGES/candidate_profile.po
7274
msgfmt -o modules/configuration/locale/ja/LC_MESSAGES/configuration.mo modules/configuration/locale/ja/LC_MESSAGES/configuration.po
@@ -131,6 +133,8 @@ issue_tracker:
131133
target=issue_tracker npm run compile
132134

133135
candidate_list:
136+
msgfmt -o modules/candidate_list/locale/ja/LC_MESSAGES/candidate_list.mo modules/candidate_list/locale/ja/LC_MESSAGES/candidate_list.po
137+
npx i18next-conv -l ja -s modules/candidate_list/locale/ja/LC_MESSAGES/candidate_list.po -t modules/candidate_list/locale/ja/LC_MESSAGES/candidate_list.json
134138
target=candidate_list npm run compile
135139

136140
candidate_parameters:

jsx/I18nSetup.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import i18n from 'i18next';
2+
import {initReactI18next} from 'react-i18next';
3+
4+
import jaResources from '../locale/ja/LC_MESSAGES/loris.json';
5+
6+
const resources = {
7+
ja: {
8+
loris: jaResources,
9+
},
10+
};
11+
12+
i18n
13+
.use(initReactI18next) // passes i18n down to react-i18next
14+
.init({
15+
resources,
16+
// debug: true,
17+
partialBundledLanguages: true,
18+
lng: loris.user.langpref ?? 'en',
19+
interpolation: {
20+
escapeValue: false, // react already safes from xss
21+
},
22+
// Modules add to this with addResourceBundle
23+
ns: ['loris'],
24+
defaultNS: 'loris',
25+
fallbackNS: [],
26+
});
27+
export default i18n;

locale/ja/LC_MESSAGES/loris.po

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,52 @@ msgstr "はい"
116116
msgid "No"
117117
msgstr "いいえ"
118118

119+
# Filters
120+
msgid "Selection Filter"
121+
msgstr "'選択フィルター"
122+
123+
msgid "Show Filters"
124+
msgstr "フィルターを表示"
125+
126+
msgid "Hide Filters"
127+
msgstr "フィルターを非表示"
128+
129+
msgid "Clear Filters"
130+
msgstr "フィルターをクリア"
131+
132+
# Common candidate terms
133+
msgid "PSCID"
134+
msgstr "プロジェクト識別子"
135+
136+
msgid "DCCID"
137+
msgstr "候補者識別子"
138+
139+
msgid "Visit Label"
140+
msgstr "ラベルを訪問"
141+
142+
msgid "Site"
143+
msgstr "サイト"
144+
145+
msgid "Project"
146+
msgstr "プロジェクト"
147+
148+
msgid "Cohort"
149+
msgstr "コホート"
150+
151+
msgid "Date of registration"
152+
msgstr "入学日"
153+
154+
msgid "Participant Status"
155+
msgstr "参加者ステータス"
156+
157+
msgid "DoB"
158+
msgstr "生年月日"
159+
160+
msgid "Sex"
161+
msgstr "性別"
162+
163+
msgid "Feedback"
164+
msgstr "フィードバック"
165+
166+
msgid "Scans"
167+
msgstr "スキャン"

locale/loris.pot

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,39 @@ msgstr ""
116116
msgid "No"
117117
msgstr ""
118118

119+
# Common candidate terms
120+
msgid "PSCID"
121+
msgstr ""
122+
123+
msgid "DCCID"
124+
msgstr ""
125+
126+
msgid "Visit Label"
127+
msgstr ""
128+
129+
msgid "Site"
130+
msgstr ""
131+
132+
msgid "Project"
133+
msgstr ""
134+
135+
msgid "Cohort"
136+
msgstr ""
137+
138+
msgid "Date of registration"
139+
msgstr ""
140+
141+
msgid "Participant Status"
142+
msgstr ""
143+
144+
msgid "DoB"
145+
msgstr ""
146+
147+
msgid "Sex"
148+
msgstr ""
149+
150+
msgid "Feedback"
151+
msgstr ""
152+
153+
msgid "Scans"
154+
msgstr ""

0 commit comments

Comments
 (0)