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
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions locale/hi/LC_MESSAGES/loris.po
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ msgstr "रद्द करें"
msgid "Success!"
msgstr "सफलता!"

msgid "Close"
msgstr "बंद करें"

# Common candidate terms
msgid "PSCID"
msgstr "पीएससीआईडी"
Expand Down
4 changes: 4 additions & 0 deletions locale/loris.pot
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ msgid "Cancel"
msgstr ""

msgid "Success!"
msgid "Close"
msgstr ""

# Common candidate terms
Expand Down Expand Up @@ -249,6 +250,9 @@ msgstr ""
msgid "Reset"
msgstr ""

msgid "Save"
msgstr ""

# Data table strings
msgid "{{pageCount}} rows displayed of {{totalCount}}."
msgstr ""
Expand Down
42 changes: 26 additions & 16 deletions modules/help_editor/jsx/helpEditorForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 ?? '');
Expand Down Expand Up @@ -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'}),
});
});
};
Expand All @@ -114,35 +120,36 @@ const HelpEditorForm = (props) => {

<SelectElement
name='instrument'
label='Instrument'
label={t('Instrument', {ns: 'help_editor'})}
emptyOption={true}
options={props.instrumentslist}
onUserInput={onUserInput}
value={instrument}
disabled={props.helpid !== null}
/>
<TextboxElement
label='Title'
label={t('Title', {ns: 'help_editor'})}
name='title'
value={title}
onUserInput={onUserInput}
/>
<TextareaElement
label='Content'
label={t('Content', {ns: 'help_editor'})}
rows={15}
name='content'
value={content}
onUserInput={onUserInput}
/>
<div className="col-sm-9 col-sm-offset-3">
<p><small>
Open the help dialog to preview the changes.
{t('Open the help dialog to preview the changes.',
{ns: 'help_editor'})}
</small></p>
<input
className="btn btn-sm btn-primary"
id="save-help"
name="fire_away"
value="Save"
value={t('Save', {ns: 'loris'})}
type="submit"
onClick={save}
/>
Expand All @@ -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));
33 changes: 23 additions & 10 deletions modules/help_editor/jsx/help_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 = <td>{cell}</td>;
switch (column) {
case 'Topic':
case t('Topic', {ns: 'help_editor'}):
url = loris.BaseURL + '/help_editor/edit_help_content/?helpID='
+ row['Help ID'];
result = <td><a href ={url}>{cell}</a></td>;
+ row[t('Help ID', {ns: 'help_editor'})];
result = <td><a href={url}>{cell}</a></td>;
break;
}

Expand All @@ -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 <h3>An error occured while loading the page.</h3>;
return <h3>{t('An error occured while loading the page.',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loris namespace

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes,
image

please point to the correct namespace @SKADE2303

{ns: 'loris'})}</h3>;
}

// Waiting for async data to load
Expand All @@ -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 (
Expand All @@ -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(
<HelpEditor
<TranslatedHelpEditor
Module="help_editor"
dataURL={loris.BaseURL + '/help_editor/?format=json'}
/>
Expand Down
35 changes: 35 additions & 0 deletions modules/help_editor/locale/help_editor.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
61 changes: 61 additions & 0 deletions modules/help_editor/locale/hi/LC_MESSAGES/help_editor.po
Original file line number Diff line number Diff line change
@@ -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 <[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 "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 "किसी विशिष्ट उपकरण के लिए सहायता सामग्री जोड़ना"
4 changes: 4 additions & 0 deletions modules/help_editor/php/edit_help_content.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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() ?? ""));
Expand Down
Loading