diff --git a/Makefile b/Makefile index d02c6e490e8..a2400808506 100755 --- a/Makefile +++ b/Makefile @@ -148,6 +148,8 @@ locales: msgfmt -o modules/login/locale/ja/LC_MESSAGES/login.mo modules/login/locale/ja/LC_MESSAGES/login.po msgfmt -o modules/media/locale/ja/LC_MESSAGES/media.mo modules/media/locale/ja/LC_MESSAGES/media.po msgfmt -o modules/module_manager/locale/ja/LC_MESSAGES/module_manager.mo modules/module_manager/locale/ja/LC_MESSAGES/module_manager.po + msgfmt -o modules/module_manager/locale/hi/LC_MESSAGES/module_manager.mo modules/module_manager/locale/hi/LC_MESSAGES/module_manager.po + npx i18next-conv -l hi -s modules/module_manager/locale/hi/LC_MESSAGES/module_manager.po -t modules/module_manager/locale/hi/LC_MESSAGES/module_manager.json msgfmt -o modules/mri_violations/locale/ja/LC_MESSAGES/mri_violations.mo modules/mri_violations/locale/ja/LC_MESSAGES/mri_violations.po msgfmt -o modules/my_preferences/locale/hi/LC_MESSAGES/my_preferences.mo modules/my_preferences/locale/hi/LC_MESSAGES/my_preferences.po 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 @@ -191,7 +193,7 @@ dataquery: modules/dataquery/locale/ja/LC_MESSAGES/dataquery.mo login: modules/login/locale/ja/LC_MESSAGES/login.mo target=login npm run compile -module_manager: modules/module_manager/locale/ja/LC_MESSAGES/module_manager.mo +module_manager: modules/module_manager/locale/ja/LC_MESSAGES/module_manager.mo modules/module_manager/locale/hi/LC_MESSAGES/module_manager.mo target=module_manager npm run compile mri_violations: modules/mri_violations/locale/ja/LC_MESSAGES/mri_violations.mo diff --git a/modules/module_manager/jsx/modulemanager.js b/modules/module_manager/jsx/modulemanager.js index 27835d3c059..b30c76d6f78 100644 --- a/modules/module_manager/jsx/modulemanager.js +++ b/modules/module_manager/jsx/modulemanager.js @@ -5,6 +5,9 @@ import Loader from 'Loader'; import FilterableDataTable from 'FilterableDataTable'; import swal from 'sweetalert2'; import {SelectElement} from 'jsx/Form'; +import {withTranslation} from 'react-i18next'; +import i18n from 'I18nSetup'; +import hiStrings from '../locale/hi/LC_MESSAGES/module_manager.json'; /** * Module Manager React Component @@ -63,18 +66,13 @@ class ModuleManagerIndex extends Component { * @return {string} a mapped value for the table cell at a given column */ mapColumn(column, cell) { - switch (column) { - case 'Active': - if (cell === 'Y') { - return 'Yes'; - } else if (cell === 'N') { - return 'No'; - } - // This shouldn't happen, it's a non-nullable - // enum in the backend. - return '?'; - default: return cell; + const {t} = this.props; + if (cell === 'Y') { + return t('Yes', {ns: 'loris'}); + } else if (cell === 'N') { + return t('No', {ns: 'loris'}); } + return cell; } /** @@ -85,6 +83,7 @@ class ModuleManagerIndex extends Component { * @param {number} id */ toggleActive(name, value, id) { + const {t} = this.props; fetch( this.props.BaseURL + '/module_manager/modules/' + name, { @@ -98,18 +97,24 @@ class ModuleManagerIndex extends Component { } ).then((response) => { if (response.status != 205) { - swal.fire('Error!', 'Could not update ' + name + '.', 'error'); + swal.fire( + t('Error!', {ns: 'loris'}), + t('Could not update', {ns: 'module_manager'}) + ' ' + name + '.', + 'error' + ); } else { const success = this.setModuleDisplayStatus(name, value); if (success === true) { swal.fire({ - title: 'Success!', - text: 'Updated ' + name + ' status! ' + - 'To apply changes the interface must be reloaded. Proceed?', + title: t('Success!', {ns: 'loris'}), + text: t('Updated', {ns: 'loris'}) + ' ' + name + ' ' + + t('status!', {ns: 'module_manager'}) + ' ' + + t('To apply changes the interface must be reloaded. Proceed?', + {ns: 'module_manager'}), type: 'success', showCancelButton: true, - confirmButtonText: 'Reload the page', - cancelButtonText: 'Continue', + confirmButtonText: t('Reload the page', {ns: 'module_manager'}), + cancelButtonText: t('Continue', {ns: 'module_manager'}), }).then((status) => { if (status.value) { window.location.href = this.props.BaseURL @@ -120,8 +125,8 @@ class ModuleManagerIndex extends Component { // If we get here something went very wrong, because somehow // a module was toggled that isn't in the table. swal.fire( - 'Error!', - 'Could not find module ' + id + '.', + t('Error!', {ns: 'loris'}), + t('Could not find module', {ns: 'module_manager'}) + ' ' + id + '.', 'error' ); } @@ -160,13 +165,22 @@ class ModuleManagerIndex extends Component { * @return {*} a formated table cell for a given column */ formatColumn(column, cell, row) { - if (column == 'Active' && this.props.hasEditPermission) { + const {t} = this.props; + const labelActive = t('Active', {ns: 'loris'}); + const labelName = t('Name', {ns: 'module_manager'}); + if ((column === 'Active' || column === labelActive) && + this.props.hasEditPermission) { + const moduleName = row[labelName] || row['Name']; return An error occured while loading the page.; + const {t} = this.props; + return ( +

{t('An error occured while loading the page.', {ns: 'loris'})}

+ ); } // Waiting for async data to load @@ -193,21 +210,22 @@ class ModuleManagerIndex extends Component { return ; } + const {t} = this.props; const fields = [ - {label: 'Name', show: true, filter: { + {label: t('Name', {ns: 'module_manager'}), show: true, filter: { name: 'Name', type: 'text', }}, - {label: 'Full Name', show: true, filter: { + {label: t('Full Name', {ns: 'module_manager'}), show: true, filter: { name: 'Full Name', type: 'text', }}, - {label: 'Active', show: true, filter: { + {label: t('Active', {ns: 'loris'}), show: true, filter: { name: 'Active', type: 'select', options: { - 'Y': 'Yes', - 'N': 'No', + 'Y': t('Yes', {ns: 'loris'}), + 'N': t('No', {ns: 'loris'}), }, }}, ]; @@ -226,13 +244,19 @@ ModuleManagerIndex.propTypes = { dataURL: PropTypes.string.isRequired, BaseURL: PropTypes.string, hasEditPermission: PropTypes.bool, + t: PropTypes.func, }; +const TranslatedModuleManagerIndex = withTranslation( + ['module_manager', 'loris'] +)(ModuleManagerIndex); + window.addEventListener('load', () => { + i18n.addResourceBundle('hi', 'module_manager', hiStrings); createRoot( document.getElementById('lorisworkspace') ).render( - , 2025. +# +msgid "" +msgstr "" +"Project-Id-Version: LORIS 27\n" +"Report-Msgid-Bugs-To: https://github.com/aces/Loris/issues\n" +"POT-Creation-Date: 2025-04-08 14:37-0400\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: hi\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "Module Manager" +msgstr "मॉड्यूल प्रबंधक" + +msgid "Name" +msgstr "नाम" + +msgid "Full Name" +msgstr "पूरा नाम" + +msgid "Could not update" +msgstr "अपडेट नहीं कर सका" + +msgid "status!" +msgstr "स्थिति!" + +msgid "To apply changes the interface must be reloaded. Proceed?" +msgstr "परिवर्तन लागू करने के लिए इंटरफ़ेस को पुनः लोड करना होगा। आगे बढ़ें?" + +msgid "Reload the page" +msgstr "पृष्ठ पुनः लोड करें" + +msgid "Continue" +msgstr "जारी रखें" + +msgid "Could not find module" +msgstr "मॉड्यूल नहीं मिला" + diff --git a/modules/module_manager/locale/module_manager.pot b/modules/module_manager/locale/module_manager.pot index 37c5ef59dc7..b1e3cad58a8 100644 --- a/modules/module_manager/locale/module_manager.pot +++ b/modules/module_manager/locale/module_manager.pot @@ -21,3 +21,27 @@ msgstr "" msgid "Module Manager" msgstr "" +msgid "Name" +msgstr "" + +msgid "Full Name" +msgstr "" + +msgid "Could not update" +msgstr "" + +msgid "status!" +msgstr "" + +msgid "To apply changes the interface must be reloaded. Proceed?" +msgstr "" + +msgid "Reload the page" +msgstr "" + +msgid "Continue" +msgstr "" + +msgid "Could not find module" +msgstr "" +