Skip to content

Commit 459814a

Browse files
authored
[behavioral_qc] Translate behavioural_qc module (#10047)
This is responsible for translating the module behavioural_qc to different languages. Currently only 'Hindi' language is supported but other languages can be added as required.
1 parent de7053d commit 459814a

File tree

10 files changed

+219
-92
lines changed

10 files changed

+219
-92
lines changed

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ locales:
8686
msgfmt -o modules/api_docs/locale/ja/LC_MESSAGES/api_docs.mo modules/api_docs/locale/ja/LC_MESSAGES/api_docs.po
8787
msgfmt -o modules/battery_manager/locale/ja/LC_MESSAGES/battery_manager.mo modules/battery_manager/locale/ja/LC_MESSAGES/battery_manager.po
8888
msgfmt -o modules/behavioural_qc/locale/ja/LC_MESSAGES/behavioural_qc.mo modules/behavioural_qc/locale/ja/LC_MESSAGES/behavioural_qc.po
89+
msgfmt -o modules/behavioural_qc/locale/hi/LC_MESSAGES/behavioural_qc.mo modules/behavioural_qc/locale/hi/LC_MESSAGES/behavioural_qc.po
90+
npx i18next-conv -l hi -s modules/behavioural_qc/locale/hi/LC_MESSAGES/behavioural_qc.po -t modules/behavioural_qc/locale/hi/LC_MESSAGES/behavioural_qc.json
8991
msgfmt -o modules/brainbrowser/locale/ja/LC_MESSAGES/brainbrowser.mo modules/brainbrowser/locale/ja/LC_MESSAGES/brainbrowser.po
9092
msgfmt -o modules/bvl_feedback/locale/ja/LC_MESSAGES/bvl_feedback.mo modules/bvl_feedback/locale/ja/LC_MESSAGES/bvl_feedback.po
9193
msgfmt -o modules/candidate_list/locale/fr/LC_MESSAGES/candidate_list.mo modules/candidate_list/locale/fr/LC_MESSAGES/candidate_list.po
@@ -218,7 +220,11 @@ server_processes_manager: modules/server_processes_manager/locale/ja/LC_MESSAGES
218220
conflict_resolver:
219221
target=conflict_resolver npm run compile
220222

223+
behavioural_qc:
224+
msgfmt -o modules/behavioural_qc/locale/hi/LC_MESSAGES/behavioural_qc.mo modules/behavioural_qc/locale/hi/LC_MESSAGES/behavioural_qc.po
225+
npx i18next-conv -l hi -s modules/behavioural_qc/locale/hi/LC_MESSAGES/behavioural_qc.po -t modules/behavioural_qc/locale/hi/LC_MESSAGES/behavioural_qc.json
226+
target=behavioural_qc npm run compile
221227
my_preferences: modules/my_preferences/locale/ja/LC_MESSAGES/my_preferences.mo modules/my_preferences/locale/hi/LC_MESSAGES/my_preferences.mo
222228
npx i18next-conv -l ja -s modules/my_preferences/locale/ja/LC_MESSAGES/my_preferences.po -t modules/my_preferences/locale/ja/LC_MESSAGES/my_preferences.json --compatibilityJSON v4
223229
npx i18next-conv -l hi -s modules/my_preferences/locale/hi/LC_MESSAGES/my_preferences.po -t modules/my_preferences/locale/hi/LC_MESSAGES/my_preferences.json --compatibilityJSON v4
224-
target=my_preferences npm run compile
230+
target=my_preferences npm run compile

locale/hi/LC_MESSAGES/loris.po

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,10 @@ msgstr "प्रगति पर"
396396
msgid "Complete"
397397
msgstr "पूर्ण"
398398

399-
msgid "Instruments"
400-
msgstr "उपकरण"
399+
msgid "Instrument"
400+
msgid_plural "Instruments"
401+
msgstr[0] "उपकरण"
402+
msgstr[1] "उपकरण"
401403

402404
msgid "Partial"
403405
msgstr "आंशिक"

modules/behavioural_qc/jsx/behaviouralQCIndex.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import IncompleteForms from './tabs_content/incompleteForms';
1010
import DataConflicts from './tabs_content/dataConflicts';
1111
import BehaviouralFeedback from './tabs_content/behaviouralFeedback';
1212

13+
import hiStrings from '../locale/hi/LC_MESSAGES/behavioural_qc.json';
1314
/**
1415
* Behavioural Quality Control.
1516
*
@@ -20,10 +21,14 @@ import BehaviouralFeedback from './tabs_content/behaviouralFeedback';
2021
* @version 1.0.0
2122
*/
2223
const BehaviouralQC = (props) => {
24+
const {t} = props;
2325
const tabList = [
24-
{id: 'tabIncompleteForms', label: 'Incomplete Forms'},
25-
{id: 'tabDataConflicts', label: 'Data Conflicts'},
26-
{id: 'tabBehaviouralFeedback', label: 'Behavioural Feedback'},
26+
{id: 'tabIncompleteForms', label: t('Incomplete Forms',
27+
{ns: 'behavioural_qc'})},
28+
{id: 'tabDataConflicts', label: t('Data Conflicts',
29+
{ns: 'behavioural_qc'})},
30+
{id: 'tabBehaviouralFeedback', label: t('Behavioural Feedback',
31+
{ns: 'behavioural_qc'})},
2732
];
2833

2934
/**
@@ -49,13 +54,15 @@ const BehaviouralQC = (props) => {
4954
};
5055
BehaviouralQC.propTypes = {
5156
baseURL: PropTypes.string.isRequired,
57+
t: PropTypes.func, // ADD THIS
5258
};
5359

5460
/**
5561
* Render Behavioural Quality Control on page load.
5662
*/
5763
window.addEventListener('load', () => {
5864
i18n.addResourceBundle('ja', 'behavioural_qc', {});
65+
i18n.addResourceBundle('hi', 'behavioural_qc', hiStrings);
5966
const Index = withTranslation(
6067
['behavioural_qc', 'loris']
6168
)(BehaviouralQC);

modules/behavioural_qc/jsx/tabs_content/behaviouralFeedback.js

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
33
import Loader from 'jsx/Loader';
44
import FilterableDataTable from 'jsx/FilterableDataTable';
5+
import {withTranslation} from 'react-i18next';
56

67
/**
78
* Behavioural Feedback Component.
@@ -80,83 +81,80 @@ class BehaviouralFeedback extends Component {
8081
* @return {*} a formatted table cell for a given column
8182
*/
8283
formatColumn(column, cell, rowData, rowHeaders) {
83-
let reactElement;
84-
switch (column) {
85-
case 'PSCID':
86-
reactElement = (
84+
const {t} = this.props;
85+
const labelPSCID = t('PSCID', {ns: 'loris'});
86+
const labelDCCID = t('DCCID', {ns: 'loris'});
87+
const labelBVL = t('Feedback Level', {ns: 'behavioural_qc'});
88+
const labelInstrument = t('Instrument', {ns: 'loris', count: 1});
89+
const labelTestName = t('Test Name', {ns: 'behavioural_qc'});
90+
const labelVisit = t('Visit', {ns: 'loris'});
91+
92+
// PSCID column (match English or translated)
93+
if (column === 'PSCID' || column === labelPSCID) {
94+
return (
8795
<td>
88-
<a href={this.props.baseURL +
89-
'/' +
90-
rowData['DCCID']
91-
}>
92-
{rowData['PSCID']}
96+
<a
97+
href={this.props.baseURL + '/' + rowData[labelDCCID]}
98+
>
99+
{rowData[labelPSCID]}
93100
</a>
94101
</td>
95102
);
96-
break;
97-
case 'DCCID':
98-
reactElement = (
103+
}
104+
105+
// DCCID column
106+
if (column === 'DCCID' || column === labelDCCID) {
107+
return (
99108
<td>
100-
<a href={this.props.baseURL +
101-
'/' +
102-
rowData['DCCID']
103-
}>
104-
{rowData['DCCID']}
109+
<a href={this.props.baseURL + '/' + rowData[labelDCCID]}>
110+
{rowData[labelDCCID]}
105111
</a>
106112
</td>
107113
);
108-
break;
109-
case 'Feedback Level':
114+
}
115+
116+
// Feedback Level column — build link depending on row data
117+
if (column === 'Feedback Level' || column === labelBVL) {
110118
let bvlLink = '';
111119
let bvlLevel = '';
112-
if (rowData['Instrument']) {
120+
if (rowData[labelInstrument]) {
113121
bvlLink = this.props.baseURL +
114-
'/instruments/' +
115-
rowData['Test Name'] +
116-
'/?candID=' +
117-
rowData['DCCID'] +
118-
'&sessionID=' +
119-
rowData['sessionID'] +
120-
'&commentID=' +
121-
rowData['commentID'];
122-
// Open feedback panel
123-
bvlLink += '&showFeedback=true';
124-
bvlLevel ='Instrument : ' + rowData['Instrument'];
125-
} else if (rowData['Visit']) {
122+
'/instruments/' +
123+
rowData[labelTestName] +
124+
'/?candID=' + rowData[labelDCCID] +
125+
'&sessionID=' + rowData['sessionID'] +
126+
'&commentID=' + rowData['commentID'] +
127+
'&showFeedback=true';
128+
bvlLevel = labelInstrument + ' : '
129+
+ rowData[labelInstrument];
130+
} else if (rowData[labelVisit]) {
126131
bvlLink = this.props.baseURL +
127-
'/instrument_list/' +
128-
'?candID=' +
129-
rowData['DCCID'] +
130-
'&sessionID=' +
131-
rowData['sessionID'];
132-
// Open feedback panel
133-
bvlLink += '&showFeedback=true';
134-
bvlLevel ='Visit : ' + rowData['Visit'];
132+
'/instrument_list/?candID=' + rowData[labelDCCID] +
133+
'&sessionID=' + rowData['sessionID'] +
134+
'&showFeedback=true';
135+
bvlLevel = labelVisit + ' : '
136+
+ rowData[labelVisit];
135137
} else {
136-
bvlLink = this.props.baseURL +
137-
'/' + rowData['DCCID'];
138-
// Open feedback panel
139-
bvlLink += '/?showFeedback=true';
140-
bvlLevel ='Profile : ' + rowData['PSCID'];
138+
bvlLink = this.props.baseURL + '/' + rowData[labelDCCID]
139+
+ '/?showFeedback=true';
140+
bvlLevel = t('Profile', {ns: 'behavioural_qc'}) + ' : '
141+
+ rowData[labelPSCID];
141142
}
142-
reactElement = (
143+
return (
143144
<td>
144145
<a href={bvlLink}>{bvlLevel}</a>
145146
</td>
146147
);
147-
break;
148-
default:
149-
reactElement = (
150-
<td>{cell}</td>
151-
);
152148
}
153-
return reactElement;
149+
150+
return <td>{cell}</td>;
154151
}
155152

156153
/**
157154
* @return {JSX} the feedback form to render.
158155
*/
159156
render() {
157+
const {t} = this.props;
160158
// Waiting for async data to load.
161159
if (!this.state.isLoaded) {
162160
return <Loader/>;
@@ -167,7 +165,7 @@ class BehaviouralFeedback extends Component {
167165
// The fields configured for display/hide.
168166
let fields = [
169167
{
170-
label: 'Instrument',
168+
label: t('Instrument', {ns: 'loris', count: 1}),
171169
show: false,
172170
filter: {
173171
name: 'Instrument',
@@ -179,23 +177,23 @@ class BehaviouralFeedback extends Component {
179177
},
180178
},
181179
{
182-
label: 'DCCID',
180+
label: t('DCCID', {ns: 'loris'}),
183181
show: true,
184182
filter: {
185183
name: 'DCCID',
186184
type: 'text',
187185
},
188186
},
189187
{
190-
label: 'PSCID',
188+
label: t('PSCID', {ns: 'loris'}),
191189
show: true,
192190
filter: {
193191
name: 'PSCID',
194192
type: 'text',
195193
},
196194
},
197195
{
198-
label: 'Visit',
196+
label: t('Visit', {ns: 'loris'}),
199197
show: false,
200198
filter: {
201199
name: 'Visit',
@@ -204,7 +202,7 @@ class BehaviouralFeedback extends Component {
204202
},
205203
},
206204
{
207-
label: 'Project',
205+
label: t('Project', {ns: 'loris', count: 1}),
208206
show: false,
209207
filter: {
210208
name: 'Project',
@@ -213,7 +211,7 @@ class BehaviouralFeedback extends Component {
213211
},
214212
},
215213
{
216-
label: 'Cohort',
214+
label: t('Cohort', {ns: 'loris', count: 1}),
217215
show: false,
218216
filter: {
219217
name: 'Cohort',
@@ -222,7 +220,7 @@ class BehaviouralFeedback extends Component {
222220
},
223221
},
224222
{
225-
label: 'Site',
223+
label: t('Site', {ns: 'loris', count: 1}),
226224
show: false,
227225
filter: {
228226
name: 'Site',
@@ -243,19 +241,19 @@ class BehaviouralFeedback extends Component {
243241
show: false,
244242
},
245243
{
246-
label: 'Feedback Level',
244+
label: t('Feedback Level', {ns: 'behavioural_qc'}),
247245
show: true,
248246
},
249247
{
250-
label: 'Test Name',
248+
label: t('Test Name', {ns: 'behavioural_qc'}),
251249
show: false,
252250
},
253251
{
254-
label: 'Field Name',
252+
label: t('Field Name', {ns: 'behavioural_qc'}),
255253
show: false,
256254
},
257255
{
258-
label: 'Feedback Status',
256+
label: t('Feedback Status', {ns: 'behavioural_qc'}),
259257
show: true,
260258
},
261259
];
@@ -280,6 +278,8 @@ BehaviouralFeedback.propTypes = {
280278
display: PropTypes.bool,
281279
data: PropTypes.object,
282280
baseURL: PropTypes.string.isRequired,
281+
t: PropTypes.func,
283282
};
284283

285-
export default BehaviouralFeedback;
284+
export default withTranslation(
285+
['behavioural_qc', 'loris'])(BehaviouralFeedback);

0 commit comments

Comments
 (0)