Skip to content

Commit

Permalink
feat(i18n): enhanced i18n support (OHIF#3761)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelpisarev authored Dec 11, 2023
1 parent 5a5c4f5 commit d14a8f0
Show file tree
Hide file tree
Showing 55 changed files with 318 additions and 113 deletions.
7 changes: 4 additions & 3 deletions extensions/default/src/getPanelModule.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { WrappedPanelStudyBrowser, PanelMeasurementTable } from './Panels';
import i18n from 'i18next';

// TODO:
// - No loading UI exists yet
Expand All @@ -22,7 +23,7 @@ function getPanelModule({ commandsManager, extensionManager, servicesManager })
name: 'seriesList',
iconName: 'tab-studies',
iconLabel: 'Studies',
label: 'Studies',
label: i18n.t('SidePanel:Studies'),
component: WrappedPanelStudyBrowser.bind(null, {
commandsManager,
extensionManager,
Expand All @@ -33,8 +34,8 @@ function getPanelModule({ commandsManager, extensionManager, servicesManager })
name: 'measure',
iconName: 'tab-linear',
iconLabel: 'Measure',
label: 'Measurements',
secondaryLabel: 'Measurements',
label: i18n.t('SidePanel:Measurements'),
secondaryLabel: i18n.t('SidePanel:Measurements'),
component: wrappedMeasurementPanel,
},
];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ButtonEnums } from '@ohif/ui';
import i18n from 'i18next';

const RESPONSE = {
NO_NEVER: -1,
Expand Down Expand Up @@ -26,24 +27,24 @@ function promptBeginTracking({ servicesManager, extensionManager }, ctx, evt) {

function _askTrackMeasurements(uiViewportDialogService, viewportId) {
return new Promise(function (resolve, reject) {
const message = 'Track measurements for this series?';
const message = i18n.t('MeasurementTable:Track measurements for this series?');
const actions = [
{
id: 'prompt-begin-tracking-cancel',
type: ButtonEnums.type.secondary,
text: 'No',
text: i18n.t('Common:No'),
value: RESPONSE.CANCEL,
},
{
id: 'prompt-begin-tracking-no-do-not-ask-again',
type: ButtonEnums.type.secondary,
text: 'No, do not ask again',
text: i18n.t('MeasurementTable:No, do not ask again'),
value: RESPONSE.NO_NEVER,
},
{
id: 'prompt-begin-tracking-yes',
type: ButtonEnums.type.primary,
text: 'Yes',
text: i18n.t('Common:Yes'),
value: RESPONSE.SET_STUDY_AND_SERIES,
},
];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import i18n from 'i18next';

const RESPONSE = {
NO_NEVER: -1,
CANCEL: 0,
Expand Down Expand Up @@ -32,17 +34,17 @@ function promptTrackNewStudy({ servicesManager, extensionManager }, ctx, evt) {

function _askTrackMeasurements(UIViewportDialogService, viewportId) {
return new Promise(function (resolve, reject) {
const message = 'Track measurements for this series?';
const message = i18n.t('MeasurementTable:Track measurements for this series?');
const actions = [
{ type: 'cancel', text: 'No', value: RESPONSE.CANCEL },
{ type: 'cancel', text: i18n.t('MeasurementTable:No'), value: RESPONSE.CANCEL },
{
type: 'secondary',
text: 'No, do not ask again for this series',
text: i18n.t('MeasurementTable:No, do not ask again'),
value: RESPONSE.NO_NOT_FOR_SERIES,
},
{
type: 'primary',
text: 'Yes',
text: i18n.t('MeasurementTable:Yes'),
value: RESPONSE.SET_STUDY_AND_SERIES,
},
];
Expand Down
5 changes: 3 additions & 2 deletions extensions/measurement-tracking/src/getPanelModule.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Types } from '@ohif/core';
import { PanelMeasurementTableTracking, PanelStudyBrowserTracking } from './panels';
import i18n from 'i18next';

// TODO:
// - No loading UI exists yet
Expand All @@ -11,7 +12,7 @@ function getPanelModule({ commandsManager, extensionManager, servicesManager }):
name: 'seriesList',
iconName: 'tab-studies',
iconLabel: 'Studies',
label: 'Studies',
label: i18n.t('SidePanel:Studies'),
component: PanelStudyBrowserTracking.bind(null, {
commandsManager,
extensionManager,
Expand All @@ -23,7 +24,7 @@ function getPanelModule({ commandsManager, extensionManager, servicesManager }):
name: 'trackedMeasurements',
iconName: 'tab-linear',
iconLabel: 'Measure',
label: 'Measurements',
label: i18n.t('SidePanel:Measurements'),
component: PanelMeasurementTableTracking.bind(null, {
commandsManager,
extensionManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ function TrackedCornerstoneViewport(props) {
patientAge: PatientAge || '',
MRN: PatientID || '',
thickness: SliceThickness ? `${parseFloat(SliceThickness).toFixed(2)}` : '',
thicknessUnits: 'mm',
thicknessUnits: t('mm'),
spacing:
SpacingBetweenSlices !== undefined
? `${parseFloat(SpacingBetweenSlices).toFixed(2)}mm`
? `${parseFloat(SpacingBetweenSlices).toFixed(2)}${t('mm')}`
: '',
scanner: ManufacturerModelName || '',
},
Expand Down Expand Up @@ -312,6 +312,7 @@ function _getNextMeasurementUID(
}

function _getStatusComponent(isTracked) {
const { t } = useTranslation('TrackedCornerstoneViewport');
const trackedIcon = isTracked ? 'status-tracked' : 'status-untracked';

return (
Expand All @@ -330,15 +331,11 @@ function _getStatusComponent(isTracked) {
<span className="text-common-light text-base">
{isTracked ? (
<>
Series is
<span className="font-bold text-white"> tracked</span> and can be viewed <br />{' '}
in the measurement panel
{t('Series is tracked and can be viewed in the measurement panel')}
</>
) : (
<>
Measurements for
<span className="font-bold text-white"> untracked </span>
series <br /> will not be shown in the <br /> measurements panel
{t('Measurements for untracked series will not be shown in the measurements panel')}
</>
)}
</span>
Expand Down
3 changes: 2 additions & 1 deletion modes/basic-dev-mode/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import toolbarButtons from './toolbarButtons.js';
import { hotkeys } from '@ohif/core';
import { id } from './id';
import i18n from 'i18next';

const configs = {
Length: {},
Expand Down Expand Up @@ -45,7 +46,7 @@ function modeFactory({ modeConfiguration }) {
return {
id,
routeName: 'dev',
displayName: 'Basic Dev Viewer',
displayName: i18n.t('Modes:Basic Dev Viewer'),
/**
* Lifecycle hooks
*/
Expand Down
3 changes: 2 additions & 1 deletion modes/basic-test-mode/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { id } from './id';
import initToolGroups from './initToolGroups';
import moreTools from './moreTools';
import moreToolsMpr from './moreToolsMpr';
import i18n from 'i18next';

// Allow this mode by excluding non-imaging modalities such as SR, SEG
// Also, SM is not a simple imaging modalities, so exclude it.
Expand Down Expand Up @@ -63,7 +64,7 @@ function modeFactory() {
// We should not be.
id,
routeName: 'basic-test',
displayName: 'Basic Test Mode',
displayName: i18n.t('Modes:Basic Test Mode'),
/**
* Lifecycle hooks
*/
Expand Down
3 changes: 2 additions & 1 deletion modes/longitudinal/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { id } from './id';
import initToolGroups from './initToolGroups';
import moreTools from './moreTools';
import moreToolsMpr from './moreToolsMpr';
import i18n from 'i18next';

// Allow this mode by excluding non-imaging modalities such as SR, SEG
// Also, SM is not a simple imaging modalities, so exclude it.
Expand Down Expand Up @@ -69,7 +70,7 @@ function modeFactory({ modeConfiguration }) {
// We should not be.
id,
routeName: 'viewer',
displayName: 'Basic Viewer',
displayName: i18n.t('Modes:Basic Viewer'),
/**
* Lifecycle hooks
*/
Expand Down
3 changes: 2 additions & 1 deletion modes/microscopy/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { hotkeys } from '@ohif/core';
import i18n from 'i18next';

import { id } from './id';
import toolbarButtons from './toolbarButtons';
Expand Down Expand Up @@ -41,7 +42,7 @@ function modeFactory({ modeConfiguration }) {
// We should not be.
id,
routeName: 'microscopy',
displayName: 'Microscopy',
displayName: i18n.t('Modes:Microscopy'),

/**
* Lifecycle hooks
Expand Down
3 changes: 2 additions & 1 deletion modes/segmentation/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { hotkeys } from '@ohif/core';
import { id } from './id';
import toolbarButtons from './toolbarButtons';
import initToolGroups from './initToolGroups';
import i18n from 'i18next';

const ohif = {
layout: '@ohif/extension-default.layoutTemplateModule.viewerLayout',
Expand Down Expand Up @@ -44,7 +45,7 @@ function modeFactory({ modeConfiguration }) {
* Mode name, which is displayed in the viewer's UI in the workList, for the
* user to select the mode.
*/
displayName: 'Segmentation',
displayName: i18n.t('Modes:Segmentation'),
/**
* Runs when the Mode Route is mounted to the DOM. Usually used to initialize
* Services and other resources.
Expand Down
3 changes: 2 additions & 1 deletion modes/tmtv/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { id } from './id.js';
import initToolGroups, { toolGroupIds } from './initToolGroups.js';
import setCrosshairsConfiguration from './utils/setCrosshairsConfiguration.js';
import setFusionActiveVolume from './utils/setFusionActiveVolume.js';
import i18n from 'i18next';

const { MetadataProvider } = classes;

Expand Down Expand Up @@ -38,7 +39,7 @@ function modeFactory({ modeConfiguration }) {
// We should not be.
id,
routeName: 'tmtv',
displayName: 'Total Metabolic Tumor Volume',
displayName: i18n.t('Modes:Total Metabolic Tumor Volume'),
/**
* Lifecycle hooks
*/
Expand Down
2 changes: 1 addition & 1 deletion platform/app/src/routes/WorkList/WorkList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ function WorkList({
onClick={() => {}}
data-cy={`mode-${mode.routeName}-${studyInstanceUid}`}
>
{t(`Modes:${mode.displayName}`)}
{mode.displayName}
</LegacyButton>
</Link>
)
Expand Down
3 changes: 2 additions & 1 deletion platform/core/src/utils/formatDate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import moment from 'moment';
import i18n from 'i18next';

/**
* Format date
Expand All @@ -7,7 +8,7 @@ import moment from 'moment';
* @param {string} format Desired date format
* @returns {string} Formatted date
*/
export default (date, format = 'DD-MMM-YYYY') => {
export default (date, format = i18n.t('Common:localDateFormat','DD-MMM-YYYY')) => {
// moment(undefined) returns the current date, so return the empty string instead
return date ? moment(date).format(format) : '';
};
5 changes: 4 additions & 1 deletion platform/i18n/src/locales/en-US/Common.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
"Layout": "Layout",
"LOAD": "LOAD",
"Measurements": "Measurements",
"mm": "mm",
"More": "More",
"Next": "Next",
"No": "No",
"NoStudyDate": "No Study Date",
"Play": "Play",
"Previous": "Previous",
Expand All @@ -14,5 +16,6 @@
"Series": "Series",
"Show": "Show",
"Stop": "Stop",
"StudyDate": "Study Date"
"StudyDate": "Study Date",
"Yes": "Yes"
}
8 changes: 8 additions & 0 deletions platform/i18n/src/locales/en-US/ErrorBoundary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Context": "Context",
"Error Message": "Error Message",
"Something went wrong": "Something went wrong",
"in": "in",
"Sorry, something went wrong there. Try again.": "Sorry, something went wrong there. Try again.",
"Stack Trace": "Stack Trace"
}
6 changes: 6 additions & 0 deletions platform/i18n/src/locales/en-US/HotkeysValidators.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"Field can't be empty": "Field can't be empty",
"Hotkey is already in use": "\"{{action}}\" is already using the \"{{pressedKeys}}\" shortcut.",
"It's not possible to define only modifier keys (ctrl, alt and shift) as a shortcut": "It's not possible to define only modifier keys (ctrl, alt and shift) as a shortcut",
"Shortcut combination is not allowed": "{{pressedKeys}} shortcut combination is not allowed"
}
4 changes: 3 additions & 1 deletion platform/i18n/src/locales/en-US/MeasurementTable.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"Delete": "Delete",
"Description": "Description",
"MAX": "MAX",
"Measurements": "Measurements",
"No, do not ask again": "No, do not ask again",
"NonTargets": "NonTargets",
"Relabel": "Relabel",
"Targets": "Targets",
"Measurements": "Measurements"
"Track measurements for this series?": "Track measurements for this series?"
}
1 change: 1 addition & 0 deletions platform/i18n/src/locales/en-US/Messages.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"Display Set Messages": "Display Set Messages",
"1": "No valid instances found in series.",
"2": "Display set has missing position information.",
"3": "Display set is not a reconstructable 3D volume.",
Expand Down
8 changes: 8 additions & 0 deletions platform/i18n/src/locales/en-US/Modes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Basic Dev Viewer": "Basic Dev Viewer",
"Basic Test Mode": "Basic Test Mode",
"Basic Viewer": "Basic Viewer",
"Microscopy": "Microscopy",
"Segmentation": "Segmentation",
"Total Metabolic Tumor Volume": "Total Metabolic Tumor Volume"
}
18 changes: 18 additions & 0 deletions platform/i18n/src/locales/en-US/SegmentationTable.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"Active": "Active",
"Add new segmentation": "Add new segmentation",
"Add segment": "Add segment",
"Add segmentation": "Add segmentation",
"Delete": "Delete",
"Display inactive segmentations": "Display inactive segmentations",
"Export DICOM SEG": "Export DICOM SEG",
"Download DICOM SEG": "Download DICOM SEG",
"Download DICOM RTSTRUCT": "Download DICOM RTSTRUCT",
"Fill": "Fill",
"Inactive segmentations": "Inactive segmentations",
"Opacity": "Opacity",
"Outline": "Outline",
"Rename": "Rename",
"Segmentation": "Segmentation",
"Size": "Size"
}
3 changes: 3 additions & 0 deletions platform/i18n/src/locales/en-US/StudyItem.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Tracked series": "{{trackedSeries}} Tracked series"
}
14 changes: 8 additions & 6 deletions platform/i18n/src/locales/en-US/StudyList.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
"ClearFilters": "Clear Filters",
"Description": "Description",
"Empty": "Empty",
"Filter list to 100 studies or less to enable sorting": "Filter the list to 100 studies or less to enable sorting",
"Instances": "Instances",
"MRN": "MRN",
"NumOfStudiesHiggerThan100Message": "Filter the list to 100 studies or less to enable sorting",
"Modality": "Modality",
"MRN": "MRN",
"Next": "Next >",
"No studies available": "No studies available",
"Number of studies": "Number of studies",
"Page": "Page",
"PatientName": "Patient Name",
"Previous": "< Back",
"Page": "Page",
"Next": "Next >",
"Results per page": "Results per page",
"Number of studies": "Studies",
"StudyDate": "Study Date",
"StudyList": "Study List"
"StudyList": "Study List",
"Upload": "Upload"
}
5 changes: 5 additions & 0 deletions platform/i18n/src/locales/en-US/ThumbnailTracked.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"Series is tracked": "Series is tracked",
"Series is untracked": "Series is untracked",
"Viewport": "Viewport"
}
4 changes: 4 additions & 0 deletions platform/i18n/src/locales/en-US/TooltipClipboard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Copied": "Copied",
"Failed to copy": "Failed to copy"
}
Loading

0 comments on commit d14a8f0

Please sign in to comment.