Skip to content

Commit 6e52838

Browse files
author
Saket Hatwar
committed
Add Translations
1 parent 21a1d0d commit 6e52838

File tree

11 files changed

+495
-87
lines changed

11 files changed

+495
-87
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ locales:
120120
msgfmt -o modules/media/locale/ja/LC_MESSAGES/media.mo modules/media/locale/ja/LC_MESSAGES/media.po
121121
msgfmt -o modules/module_manager/locale/ja/LC_MESSAGES/module_manager.mo modules/module_manager/locale/ja/LC_MESSAGES/module_manager.po
122122
msgfmt -o modules/mri_violations/locale/ja/LC_MESSAGES/mri_violations.mo modules/mri_violations/locale/ja/LC_MESSAGES/mri_violations.po
123+
msgfmt -o modules/mri_violations/locale/hi/LC_MESSAGES/mri_violations.mo modules/mri_violations/locale/hi/LC_MESSAGES/mri_violations.po
124+
npx i18next-conv -l hi -s modules/mri_violations/locale/hi/LC_MESSAGES/mri_violations.po -t modules/mri_violations/locale/hi/LC_MESSAGES/mri_violations.json
123125
msgfmt -o modules/next_stage/locale/ja/LC_MESSAGES/next_stage.mo modules/next_stage/locale/ja/LC_MESSAGES/next_stage.po
124126
msgfmt -o modules/oidc/locale/ja/LC_MESSAGES/oidc.mo modules/oidc/locale/ja/LC_MESSAGES/oidc.po
125127
msgfmt -o modules/publication/locale/ja/LC_MESSAGES/publication.mo modules/publication/locale/ja/LC_MESSAGES/publication.po
@@ -160,6 +162,8 @@ module_manager:
160162
target=module_manager npm run compile
161163

162164
mri_violations:
165+
msgfmt -o modules/mri_violations/locale/hi/LC_MESSAGES/mri_violations.mo modules/mri_violations/locale/hi/LC_MESSAGES/mri_violations.po
166+
npx i18next-conv -l hi -s modules/mri_violations/locale/hi/LC_MESSAGES/mri_violations.po -t modules/mri_violations/locale/hi/LC_MESSAGES/mri_violations.json
163167
target=mri_violations npm run compile
164168

165169
issue_tracker:

locale/loris.pot

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,12 @@ msgstr ""
202202
msgid "Language"
203203
msgstr ""
204204

205+
msgid "Access denied"
206+
msgstr ""
207+
208+
msgid "No."
209+
msgstr ""
210+
205211
# Data table strings
206212
msgid "{{pageCount}} rows displayed of {{totalCount}}."
207213
msgstr ""
@@ -259,3 +265,4 @@ msgstr ""
259265

260266
msgid "In Progress"
261267
msgstr ""
268+

modules/mri_violations/jsx/mriViolationsIndex.js

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import FilterableDataTable from 'FilterableDataTable';
33
import React, {useEffect, useState} from 'react';
44
import PropTypes from 'prop-types';
55
import ProtocolModal from './protocolModal.js';
6+
import i18n from 'I18nSetup';
7+
import {withTranslation} from 'react-i18next';
8+
9+
import hiStrings from '../locale/hi/LC_MESSAGES/mri_violations.json';
610

711
/**
812
* Entry point for the MRI Violatons module.
@@ -17,6 +21,8 @@ function MRIViolationsIndex(props) {
1721
const [isError, setIsError] = useState(false);
1822
const [data, setData] = useState([]);
1923
const mapper = columnMapper(fieldOptions);
24+
const {t} = props;
25+
2026
const violationsModal = (violationModal !== false) ?
2127
<ProtocolModal
2228
onClose={() => setViolationModal(false)}
@@ -109,7 +115,8 @@ function MRIViolationsIndex(props) {
109115
let resolutionStatusStyle;
110116
let resolutionStatus;
111117

112-
if (column === 'Type of Problem' && cell === 'Protocol Violation') {
118+
if (column === t('Type of Problem', {ns: 'mri_violations'}) &&
119+
cell === t('Protocol Violation', {ns: 'mri_violations'})) {
113120
return (
114121
<td>
115122
<a href="#" onClick={
@@ -120,17 +127,17 @@ function MRIViolationsIndex(props) {
120127
TarchiveID: rowData['TarchiveID'],
121128
CandID: rowData.CandId,
122129
})
123-
}>Protocol Violation</a>
130+
}>{t('Protocol Violation', {ns: 'mri_violations'})}</a>
124131
</td>
125132
);
126133
}
127134

128135
if (
129-
column === 'Type of Problem' &&
130-
cell === 'Could not identify scan type'
136+
column === t('Type of Problem', {ns: 'mri_violations'}) &&
137+
cell === t('Could not identify scan type', {ns: 'mri_violations'})
131138
) {
132139
const seriesDescription = rowData[
133-
'Series Description or Scan Type'
140+
t('Series Description or Scan Type', {ns: 'mri_violations'})
134141
];
135142
return (
136143
<td>
@@ -259,74 +266,77 @@ function MRIViolationsIndex(props) {
259266
}
260267
return [
261268
{
262-
label: 'Patient Name', show: true, filter: {
269+
label: t('Patient Name', {ns: 'mri_violations'}), show: true, filter: {
263270
name: 'patientName',
264271
type: 'text',
265272
},
266273
},
267274
{
268-
label: 'Project', show: true, filter: {
275+
label: t('Project', {ns: 'loris'}), show: true, filter: {
269276
name: 'project',
270277
type: 'select',
271278
options: fieldoptions.projects,
272279
},
273280
},
274281
{
275-
label: 'Cohort', show: true, filter: {
282+
label: t('Cohort', {ns: 'loris'}), show: true, filter: {
276283
name: 'cohort',
277284
type: 'select',
278285
options: fieldoptions.cohorts,
279286
},
280287
},
281288
{
282-
label: 'Site', show: true, filter: {
289+
label: t('Site', {ns: 'loris'}), show: true, filter: {
283290
name: 'site',
284291
type: 'select',
285292
options: fieldoptions.sites,
286293
},
287294
},
288295
{
289-
label: 'Time Run', show: true, filter: {
296+
label: t('Time Run', {ns: 'mri_violations'}), show: true, filter: {
290297
name: 'timeRun',
291298
type: 'datetime',
292299
},
293300
},
294301
{
295-
label: 'Image File', show: true, filter: {
302+
label: t('Image File', {ns: 'mri_violations'}), show: true, filter: {
296303
name: 'mincFile',
297304
type: 'text',
298305
},
299306
},
300307
{
301-
label: 'Series Description or Scan Type', show: true, filter: {
308+
label: t('Series Description or Scan Type', {ns: 'mri_violations'}),
309+
show: true, filter: {
302310
name: 'seriesOrType',
303311
type: 'text',
304312
},
305313
},
306314
{
307-
label: 'Type of Problem', show: true, filter: {
315+
label: t('Type of Problem', {ns: 'mri_violations'}),
316+
show: true, filter: {
308317
name: 'typeOfProblem',
309318
type: 'select',
310319
options: problemtypes,
311320
},
312321
},
313322
{
314-
label: 'Resolution Status', show: true, filter: {
323+
label: t('Resolution Status', {ns: 'mri_violations'}),
324+
show: true, filter: {
315325
name: 'resolutionStatus',
316326
type: 'select',
317327
options: {
318-
'unresolved': 'Unresolved',
319-
'reran': 'Reran',
320-
'emailed': 'emailed site/pending',
321-
'inserted': 'Inserted',
322-
'rejected': 'Rejected',
323-
'inserted_flag': 'Inserted with flag',
324-
'other': 'Other',
328+
'unresolved': t('Unresolved', {ns: 'mri_violations'}),
329+
'reran': t('Reran', {ns: 'mri_violations'}),
330+
'emailed': t('emailed site/pending', {ns: 'mri_violations'}),
331+
'inserted': t('inserted', {ns: 'mri_violations'}),
332+
'rejected': t('rejected', {ns: 'mri_violations'}),
333+
'inserted_flag': t('inserted with flag', {ns: 'mri_violations'}),
334+
'other': t('other', {ns: 'mri_violations'}),
325335
},
326336
},
327337
},
328338
{
329-
label: 'Series UID', show: false, filter: {
339+
label: t('Series UID', {ns: 'mri_violations'}), show: false, filter: {
330340
name: 'seriesUID',
331341
type: 'text',
332342
},
@@ -338,7 +348,7 @@ function MRIViolationsIndex(props) {
338348
{label: 'PSCID', show: false},
339349

340350
// Add fake column for resolution dropdown
341-
{label: 'Select Resolution', show: true},
351+
{label: t('Select Resolution', {ns: 'mri_violations'}), show: true},
342352
];
343353
};
344354

@@ -348,7 +358,8 @@ function MRIViolationsIndex(props) {
348358
{!isLoaded ?
349359
<Loader/> :
350360
isError ?
351-
<h3>An error occurred while loading the page.</h3> :
361+
<h3>{t('An error occurred while loading the page.',
362+
{ns: 'mri_violations'})}</h3> :
352363
<FilterableDataTable
353364
name="violations"
354365
data={data}
@@ -368,6 +379,7 @@ MRIViolationsIndex.propTypes = {
368379
ModuleURL: PropTypes.string,
369380
SeriesUID: PropTypes.string,
370381
dataURL: PropTypes.string,
382+
t: PropTypes.func,
371383
};
372384

373385
/**
@@ -401,10 +413,16 @@ function columnMapper(fieldOptions) {
401413
}
402414

403415
window.addEventListener('load', () => {
416+
i18n.addResourceBundle('hi', 'mri_violations', hiStrings);
417+
418+
const ViolationsIndex = withTranslation(
419+
['mri_violations', 'loris']
420+
)(MRIViolationsIndex);
421+
404422
ReactDOM.createRoot(
405423
document.getElementById('lorisworkspace')
406424
).render(
407-
<MRIViolationsIndex
425+
<ViolationsIndex
408426
ModuleURL={`${loris.BaseURL}/mri_violations/`}
409427
dataURL={`${loris.BaseURL}/mri_violations/?format=json`}
410428
/>,

0 commit comments

Comments
 (0)