diff --git a/Makefile b/Makefile index ae8037c67e6..3689ce1e5ea 100755 --- a/Makefile +++ b/Makefile @@ -123,6 +123,8 @@ locales: msgfmt -o modules/examiner/locale/ja/LC_MESSAGES/examiner.mo modules/examiner/locale/ja/LC_MESSAGES/examiner.po msgfmt -o modules/genomic_browser/locale/ja/LC_MESSAGES/genomic_browser.mo modules/genomic_browser/locale/ja/LC_MESSAGES/genomic_browser.po msgfmt -o modules/help_editor/locale/ja/LC_MESSAGES/help_editor.mo modules/help_editor/locale/ja/LC_MESSAGES/help_editor.po + msgfmt -o modules/help_editor/locale/hi/LC_MESSAGES/help_editor.mo modules/help_editor/locale/hi/LC_MESSAGES/help_editor.po + npx i18next-conv -l hi -s modules/help_editor/locale/hi/LC_MESSAGES/help_editor.po -t modules/help_editor/locale/hi/LC_MESSAGES/help_editor.json msgfmt -o modules/imaging_browser/locale/ja/LC_MESSAGES/imaging_browser.mo modules/imaging_browser/locale/ja/LC_MESSAGES/imaging_browser.po npx i18next-conv -l ja -s modules/imaging_browser/locale/ja/LC_MESSAGES/imaging_browser.po -t modules/imaging_browser/locale/ja/LC_MESSAGES/imaging_browser.json --compatibilityJSON v4 msgfmt -o modules/imaging_qc/locale/ja/LC_MESSAGES/imaging_qc.mo modules/imaging_qc/locale/ja/LC_MESSAGES/imaging_qc.po diff --git a/locale/hi/LC_MESSAGES/loris.po b/locale/hi/LC_MESSAGES/loris.po index e19c9f495a2..7b7b5489119 100644 --- a/locale/hi/LC_MESSAGES/loris.po +++ b/locale/hi/LC_MESSAGES/loris.po @@ -155,6 +155,9 @@ msgstr "रद्द करें" msgid "Success!" msgstr "सफलता!" +msgid "Close" +msgstr "बंद करें" + # Common candidate terms msgid "PSCID" msgstr "पीएससीआईडी" diff --git a/locale/loris.pot b/locale/loris.pot index 139852bb837..ed6b5e6a172 100644 --- a/locale/loris.pot +++ b/locale/loris.pot @@ -155,6 +155,7 @@ msgid "Cancel" msgstr "" msgid "Success!" +msgid "Close" msgstr "" # Common candidate terms @@ -249,6 +250,9 @@ msgstr "" msgid "Reset" msgstr "" +msgid "Save" +msgstr "" + # Data table strings msgid "{{pageCount}} rows displayed of {{totalCount}}." msgstr "" diff --git a/modules/help_editor/jsx/helpEditorForm.js b/modules/help_editor/jsx/helpEditorForm.js index 7c758663363..3d5243d5b9b 100644 --- a/modules/help_editor/jsx/helpEditorForm.js +++ b/modules/help_editor/jsx/helpEditorForm.js @@ -6,6 +6,9 @@ import Help from 'jsx/Help'; import swal from 'sweetalert2'; import {TextboxElement, TextareaElement} from 'jsx/Form'; import {SelectElement} from 'jsx/Form'; +import {withTranslation} from 'react-i18next'; +import i18n from 'I18nSetup'; +import hiStrings from '../locale/hi/LC_MESSAGES/help_editor.json'; /** * Help Editor Form Page. @@ -20,6 +23,7 @@ import {SelectElement} from 'jsx/Form'; */ const HelpEditorForm = (props) => { + const {t} = props; const [title, setTitle] = useState(props.title ?? ''); const [content, setContent] = useState(props.content ?? ''); const [instrument, setInstrument] = useState(props.instrument ?? ''); @@ -72,31 +76,33 @@ const HelpEditorForm = (props) => { method: 'POST', body: formData, }).then((response) => { - console.log(response); - if (response.status !== 200) { swal.fire({ - title: 'Content update unsuccessful.', - text: 'Help content cannot be added to an instrument ' + title: t('Content update unsuccessful.', + {ns: 'help_editor'}), + text: t('Help content cannot be added to an instrument ' + 'that has already been registered.', + {ns: 'help_editor'}), type: 'error', - confirmButtonText: 'Try again', + confirmButtonText: t('Try again', {ns: 'help_editor'}), }); console.error(response.status); return; } swal.fire({ - title: 'Content update successful!', + title: t('Content update successful!', + {ns: 'help_editor'}), type: 'success', - confirmButtonText: 'Close', + confirmButtonText: t('Close', {ns: 'loris'}), }); }).catch((error) => { console.error(error); swal.fire({ - title: 'Content update unsuccessful.', - text: 'Something went wrong', + title: t('Content update unsuccessful.', + {ns: 'help_editor'}), + text: t('Something went wrong', {ns: 'help_editor'}), type: 'error', - confirmButtonText: 'Try again', + confirmButtonText: t('Try again', {ns: 'help_editor'}), }); }); }; @@ -114,7 +120,7 @@ const HelpEditorForm = (props) => { { disabled={props.helpid !== null} /> { />

- Open the help dialog to preview the changes. + {t('Open the help dialog to preview the changes.', + {ns: 'help_editor'})}

@@ -164,6 +171,9 @@ HelpEditorForm.propTypes = { url: PropTypes.string, instrument: PropTypes.string, instrumentslist: PropTypes.objectOf(PropTypes.string), + t: PropTypes.func, }; -window.RHelpEditorForm = React.createFactory(HelpEditorForm); +i18n.addResourceBundle('hi', 'help_editor', hiStrings); +window.RHelpEditorForm = React.createFactory( + withTranslation(['help_editor'])(HelpEditorForm)); diff --git a/modules/help_editor/jsx/help_editor.js b/modules/help_editor/jsx/help_editor.js index 5446836f967..8a3d09d6393 100644 --- a/modules/help_editor/jsx/help_editor.js +++ b/modules/help_editor/jsx/help_editor.js @@ -3,6 +3,10 @@ import Loader from 'Loader'; import PropTypes from 'prop-types'; import {createRoot} from 'react-dom/client'; import React from 'react'; +import i18n from 'I18nSetup'; +import hiStrings from '../locale/hi/LC_MESSAGES/help_editor.json'; +import {withTranslation} from 'react-i18next'; + /** * Help Editor Archive Page. @@ -67,13 +71,14 @@ class HelpEditor extends React.Component { * @return {*} a formatted table cell for a given column */ formatColumn(column, cell, row) { + const {t} = this.props; let url; let result = {cell}; switch (column) { - case 'Topic': + case t('Topic', {ns: 'help_editor'}): url = loris.BaseURL + '/help_editor/edit_help_content/?helpID=' - + row['Help ID']; - result = {cell}; + + row[t('Help ID', {ns: 'help_editor'})]; + result = {cell}; break; } @@ -86,10 +91,12 @@ class HelpEditor extends React.Component { * @return {JSX} - React markup for the component */ render() { + const {t} = this.props; // If error occurs, return a message. // XXX: Replace this with a UI component for 500 errors. if (this.state.error) { - return

An error occured while loading the page.

; + return

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

; } // Waiting for async data to load @@ -104,19 +111,20 @@ class HelpEditor extends React.Component { ); }; const actions = [ - {label: 'Adding help content for a specific instrument', action: addHelp}, + {label: t('Adding help content for a specific instrument', + {ns: 'help_editor'}), action: addHelp}, ]; const fields = [ - {label: 'Help ID', show: false}, - {label: 'Topic', show: true, filter: { + {label: t('Help ID', {ns: 'help_editor'}), show: false}, + {label: t('Topic', {ns: 'help_editor'}), show: true, filter: { name: 'topic', type: 'text', }}, - {label: 'Content', show: true, filter: { + {label: t('Content', {ns: 'help_editor'}), show: true, filter: { name: 'content', type: 'text', }}, - {label: 'Instrument', show: true}, + {label: t('Instrument', {ns: 'loris'}), show: true}, ]; return ( @@ -133,13 +141,18 @@ class HelpEditor extends React.Component { HelpEditor.propTypes = { dataURL: PropTypes.string.isRequired, + t: PropTypes.func, }; +const TranslatedHelpEditor = withTranslation( + ['help_editor'])(HelpEditor); + window.addEventListener('load', () => { + i18n.addResourceBundle('hi', 'help_editor', hiStrings); createRoot( document.getElementById('lorisworkspace') ).render( - diff --git a/modules/help_editor/locale/help_editor.pot b/modules/help_editor/locale/help_editor.pot index 5cde67162bc..d17e9bcbc4b 100644 --- a/modules/help_editor/locale/help_editor.pot +++ b/modules/help_editor/locale/help_editor.pot @@ -21,3 +21,38 @@ msgstr "" msgid "Help Editor" msgstr "" +msgid "Edit Help Content" +msgstr "" + +msgid "Help ID" +msgstr "" + +msgid "Topic" +msgstr "" + +msgid "Content" +msgstr "" + +msgid "Title" +msgstr "" + +msgid "Open the help dialog to preview the changes." +msgstr "" + +msgid "Content update successful!" +msgstr "" + +msgid "Content update unsuccessful." +msgstr "" + +msgid "Something went wrong" +msgstr "" + +msgid "Try again" +msgstr "" + +msgid "Help content cannot be added to an instrument that has already been registered." +msgstr "" + +msgid "Adding help content for a specific instrument" +msgstr "" \ No newline at end of file diff --git a/modules/help_editor/locale/hi/LC_MESSAGES/help_editor.po b/modules/help_editor/locale/hi/LC_MESSAGES/help_editor.po new file mode 100644 index 00000000000..048cb32b761 --- /dev/null +++ b/modules/help_editor/locale/hi/LC_MESSAGES/help_editor.po @@ -0,0 +1,61 @@ +# 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 , 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 "Help Editor" +msgstr "सहायता संपादक" + +msgid "Edit Help Content" +msgstr "सहायता सामग्री संपादित करें" + +msgid "Help ID" +msgstr "सहायता आईडी" + +msgid "Topic" +msgstr "विषय" + +msgid "Content" +msgstr "सामग्री" + +msgid "Title" +msgstr "शीर्षक" + +msgid "Open the help dialog to preview the changes." +msgstr "परिवर्तनों का पूर्वावलोकन करने के लिए सहायता संवाद खोलें।" + +msgid "Content update successful!" +msgstr "सामग्री सफलतापूर्वक अपडेट की गई!" + +msgid "Close" +msgstr "बंद करें" + +msgid "Content update unsuccessful." +msgstr "सामग्री अपडेट असफल रहा।" + +msgid "Something went wrong" +msgstr "कुछ गलत हो गया" + +msgid "Try again" +msgstr "पुनः प्रयास करें" + +msgid "Help content cannot be added to an instrument that has already been registered." +msgstr "एक ऐसे इंस्ट्रूमेंट में हेल्प कंटेंट नहीं जोड़ा जा सकता है जो पहले से पंजीकृत हो चुका है।" + +msgid "Adding help content for a specific instrument" +msgstr "किसी विशिष्ट उपकरण के लिए सहायता सामग्री जोड़ना" \ No newline at end of file diff --git a/modules/help_editor/php/edit_help_content.class.inc b/modules/help_editor/php/edit_help_content.class.inc index d61c9e30b9b..c5be78f71b8 100644 --- a/modules/help_editor/php/edit_help_content.class.inc +++ b/modules/help_editor/php/edit_help_content.class.inc @@ -158,6 +158,10 @@ class Edit_Help_Content extends \NDB_Form } } + $data['edit_help_text'] = dgettext('help_editor', 'Edit Help Content'); + $data['display_title'] = !empty($data['title']) ? $data['title'] : + $data['edit_help_text']; + $this->tpl_data = $data; return (new \LORIS\Http\Response()) ->withBody(new \LORIS\Http\StringStream($this->display() ?? ""));