Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,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/next_stage/locale/ja/LC_MESSAGES/next_stage.mo modules/next_stage/locale/ja/LC_MESSAGES/next_stage.po
msgfmt -o modules/oidc/locale/ja/LC_MESSAGES/oidc.mo modules/oidc/locale/ja/LC_MESSAGES/oidc.po
Expand Down Expand Up @@ -141,6 +143,8 @@ login:
target=login npm run compile

module_manager:
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
target=module_manager npm run compile

mri_violations:
Expand Down
63 changes: 43 additions & 20 deletions modules/module_manager/jsx/modulemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import Loader from 'Loader';
import FilterableDataTable from 'FilterableDataTable';
import swal from 'sweetalert2';
import {SelectElement} from 'jsx/Form';
import i18n from 'I18nSetup';
import {withTranslation} from 'react-i18next';

import hiStrings from '../locale/hi/LC_MESSAGES/module_manager.json';

/**
* Module Manager React Component
Expand Down Expand Up @@ -63,12 +67,13 @@ class ModuleManagerIndex extends Component {
* @return {string} a mapped value for the table cell at a given column
*/
mapColumn(column, cell) {
const {t} = this.props;
switch (column) {
case 'Active':
case t('Active', {ns: 'module_manager'}):
if (cell === 'Y') {
return 'Yes';
return t('Yes', {ns: 'loris'});
} else if (cell === 'N') {
return 'No';
return t('No', {ns: 'loris'});
}
// This shouldn't happen, it's a non-nullable
// enum in the backend.
Expand All @@ -85,6 +90,7 @@ class ModuleManagerIndex extends Component {
* @param {number} id
*/
toggleActive(name, value, id) {
const {t} = this.props;
fetch(
this.props.BaseURL + '/module_manager/modules/' + name,
{
Expand All @@ -98,18 +104,23 @@ class ModuleManagerIndex extends Component {
}
).then((response) => {
if (response.status != 205) {
swal.fire('Error!', 'Could not update ' + name + '.', 'error');
swal.fire(
t('Error!', {ns: 'module_manager'}),
t('Could not update module', {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: 'module_manager'}),
text: t('Updated status', {ns: 'module_manager', name}) +
' ' + t('ReloadPrompt', {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
Expand All @@ -120,8 +131,9 @@ 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: 'module_manager'}),
t('Could not find module',
{ns: 'module_manager', id}),
'error'
);
}
Expand Down Expand Up @@ -160,13 +172,16 @@ 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;
if (column == t('Active',
{ns: 'module_manager'}) && this.props.hasEditPermission) {
return <td><SelectElement
name={row.Name}
id={row.Name}
label=''
emptyOption={false}
options={{'Y': 'Yes', 'N': 'No'}}
options={{'Y': t('Yes',
{ns: 'loris'}), 'N': t('No', {ns: 'loris'})}}
value={cell}
onUserInput={this.toggleActive}
noMargins={true}
Expand All @@ -184,8 +199,10 @@ class ModuleManagerIndex extends Component {
render() {
// If error occurs, return a message.
// XXX: Replace this with a UI component for 500 errors.
const {t} = this.props;
if (this.state.error) {
return <h3>An error occured while loading the page.</h3>;
return <h3>{t('An error occured while loading the page.',
{ns: 'loris'})}</h3>;
}

// Waiting for async data to load
Expand All @@ -194,20 +211,20 @@ class ModuleManagerIndex extends Component {
}

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: 'module_manager'}), show: true, filter: {
name: 'Active',
type: 'select',
options: {
'Y': 'Yes',
'N': 'No',
'Y': t('Yes', {ns: 'loris'}),
'N': t('No', {ns: 'loris'}),
},
}},
];
Expand All @@ -226,13 +243,19 @@ ModuleManagerIndex.propTypes = {
dataURL: PropTypes.string.isRequired,
BaseURL: PropTypes.string,
hasEditPermission: PropTypes.bool,
t: PropTypes.func.isRequired,
};

const TranslatedModuleManagerIndex =
withTranslation(['module_manager', 'loris'])(ModuleManagerIndex);

window.addEventListener('load', () => {
i18n.addResourceBundle('hi', 'module_manager', hiStrings);

createRoot(
document.getElementById('lorisworkspace')
).render(
<ModuleManagerIndex
<TranslatedModuleManagerIndex
dataURL={`${loris.BaseURL}/module_manager/?format=json`}
BaseURL={loris.BaseURL}
hasEditPermission={loris.userHasPermission('module_manager_edit')}
Expand Down
13 changes: 13 additions & 0 deletions modules/module_manager/locale/hi/LC_MESSAGES/module_manager.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Module Manager": "मॉड्यूल प्रबंधक",
"Error!": "त्रुटि!",
"Could not update ": "अद्यतन नहीं कर सका ",
"Success!": "सफलता!",
"Updated": "अद्यतन किया गया",
"status!": "स्थिति!",
"To apply changes the interface must be reloaded. Proceed?": "परिवर्तनों को लागू करने के लिए इंटरफ़ेस को पुनः लोड करना आवश्यक है। क्या आप आगे बढ़ना चाहते हैं?",
"Reload the page": "पृष्ठ पुनः लोड करें",
"Continue": "जारी रखें",
"Could not find module ": "मॉड्यूल नहीं मिला ",
"Full Name": "पूरा नाम"
}
55 changes: 55 additions & 0 deletions modules/module_manager/locale/hi/LC_MESSAGES/module_manager.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Default LORIS strings to be translated (English).
# Copy this to a language specific file and add translations to the
# new file.
# Copyright (C) 2025
# This file is distributed under the same license as the LORIS package.
# Dave MacFarlane <[email protected]>, 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\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 "Error!"
msgstr "त्रुटि!"

msgid "Could not update"
msgstr "मॉड्यूल {{name}} को अद्यतन नहीं किया जा सका।"

msgid "Success!"
msgstr "सफलता!"

msgid "Updated"
msgstr "{{name}} की स्थिति अद्यतन की गई!"

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 "मॉड्यूल {{id}} नहीं मिला।"

msgid "Full Name"
msgstr "पूरा नाम"

msgid "ReloadPrompt"
msgstr "परिवर्तनों को लागू करने के लिए इंटरफ़ेस को पुनः लोड करना आवश्यक है। क्या आप आगे बढ़ना चाहते हैं?"
32 changes: 32 additions & 0 deletions modules/module_manager/locale/module_manager.pot
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,35 @@ msgstr ""
msgid "Module Manager"
msgstr ""

msgid "Error!"
msgstr ""

msgid "Could not update"
msgstr ""

msgid "Success!"
msgstr ""

msgid "Updated"
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 ""

msgid "Full Name"
msgstr ""

msgid "ReloadPrompt"
msgstr ""
Loading