From 87c11e3f971466a04dc6f2fedde9d7b9bdef7b21 Mon Sep 17 00:00:00 2001 From: Saket Hatwar Date: Mon, 8 Sep 2025 06:42:28 -0400 Subject: [PATCH 1/3] Add Translation --- Makefile | 6 +- modules/publication/jsx/projectFields.js | 73 +++++---- modules/publication/jsx/publicationIndex.js | 29 ++-- modules/publication/jsx/uploadForm.js | 22 +-- modules/publication/jsx/viewProject.js | 57 ++++--- .../locale/hi/LC_MESSAGES/publication.json | 42 ++++++ .../locale/hi/LC_MESSAGES/publication.po | 140 ++++++++++++++++++ modules/publication/locale/publication.pot | 117 +++++++++++++++ 8 files changed, 408 insertions(+), 78 deletions(-) create mode 100644 modules/publication/locale/hi/LC_MESSAGES/publication.json create mode 100644 modules/publication/locale/hi/LC_MESSAGES/publication.po diff --git a/Makefile b/Makefile index 762b4ea5c29..8c8606b222f 100755 --- a/Makefile +++ b/Makefile @@ -133,6 +133,8 @@ locales: msgfmt -o modules/next_stage/locale/es/LC_MESSAGES/next_stage.mo modules/next_stage/locale/es/LC_MESSAGES/next_stage.po msgfmt -o modules/oidc/locale/ja/LC_MESSAGES/oidc.mo modules/oidc/locale/ja/LC_MESSAGES/oidc.po msgfmt -o modules/publication/locale/ja/LC_MESSAGES/publication.mo modules/publication/locale/ja/LC_MESSAGES/publication.po + msgfmt -o modules/publication/locale/hi/LC_MESSAGES/publication.mo modules/publication/locale/hi/LC_MESSAGES/publication.po + npx i18next-conv -l hi -s modules/publication/locale/hi/LC_MESSAGES/publication.po -t modules/publication/locale/hi/LC_MESSAGES/publication.json msgfmt -o modules/schedule_module/locale/ja/LC_MESSAGES/schedule_module.mo modules/schedule_module/locale/ja/LC_MESSAGES/schedule_module.po msgfmt -o modules/server_processes_manager/locale/ja/LC_MESSAGES/server_processes_manager.mo modules/server_processes_manager/locale/ja/LC_MESSAGES/server_processes_manager.po msgfmt -o modules/statistics/locale/ja/LC_MESSAGES/statistics.mo modules/statistics/locale/ja/LC_MESSAGES/statistics.po @@ -184,7 +186,9 @@ candidate_parameters: modules/candidate_parameters/locale/ja/LC_MESSAGES/candida dashboard: modules/dashboard/locale/ja/LC_MESSAGES/dashboard.mo target=dashboard npm run compile -publication: modules/publication/locale/ja/LC_MESSAGES/publication.mo +publication: + msgfmt -o modules/publication/locale/hi/LC_MESSAGES/publication.mo modules/publication/locale/hi/LC_MESSAGES/publication.po + npx i18next-conv -l hi -s modules/publication/locale/hi/LC_MESSAGES/publication.po -t modules/publication/locale/hi/LC_MESSAGES/publication.json target=publication npm run compile server_processes_manager: modules/server_processes_manager/locale/ja/LC_MESSAGES/server_processes_manager.mo diff --git a/modules/publication/jsx/projectFields.js b/modules/publication/jsx/projectFields.js index 990a06b5827..b5a353a721c 100644 --- a/modules/publication/jsx/projectFields.js +++ b/modules/publication/jsx/projectFields.js @@ -11,6 +11,7 @@ import { SelectElement, DateElement, } from 'jsx/Form'; +import {withTranslation} from 'react-i18next'; /** * Email element component @@ -49,6 +50,7 @@ class EmailElement extends React.Component { * @return {JSX} - React markup for the component */ render() { + const {t} = this.props; let disabled = this.props.disabled ? 'disabled' : null; let required = this.props.required ? 'required' : null; let errorMessage = null; @@ -94,7 +96,7 @@ class EmailElement extends React.Component { onChange={this.props.toggleEmailNotify} value={this.props.addressee} /> - Send email notification? + {t('Send email notification?', {ns: 'loris'})} @@ -113,6 +115,7 @@ EmailElement.propTypes = { id: PropTypes.string, toggleEmailNotify: PropTypes.func, addressee: PropTypes.string, + t: PropTypes.func, }; EmailElement.defaultProps = { name: '', @@ -130,6 +133,8 @@ EmailElement.defaultProps = { }, }; +export const TranslatedEmailElement = withTranslation(['loris'])(EmailElement); + /** * Project form fields component * This class combines the common form elements between @@ -191,6 +196,7 @@ class ProjectFormFields extends React.Component { * @return {React.ReactElement[]} - Array of React markup for the component */ createFileFields() { + const {t} = this.props; let fileFields = []; // Create download link & edit fields for existing files if (this.props.files) { @@ -228,13 +234,13 @@ class ProjectFormFields extends React.Component { /> @@ -251,7 +257,7 @@ class ProjectFormFields extends React.Component { name={fileName} id={'publicationUploadEl_' + i} onUserInput={this.props.setFileData} - label="File to upload" + label={t('File to upload', {ns: 'publication'})} value={this.props.formData[fileName]} /> @@ -264,7 +270,7 @@ class ProjectFormFields extends React.Component {
@@ -302,7 +308,7 @@ class ProjectFormFields extends React.Component { function(c, i) { let name = 'collabEmail_' + c.name; collabEmails.push( - - For help finding variables of interest, consult - the Data Dictionary + {t('For help finding variables of interest, consult', {ns: 'publication'})} +   + {t('Data Dictionary', {ns: 'loris'})} ); let collabNames = []; @@ -433,14 +441,14 @@ class ProjectFormFields extends React.Component {
- {collabEmails} {fileFields}
); @@ -604,5 +612,6 @@ ProjectFormFields.propTypes = { allKWs: PropTypes.object, editMode: PropTypes.string, projectOptions: PropTypes.object, + t: PropTypes.func, }; -export default ProjectFormFields; +export default withTranslation(['publication'])(ProjectFormFields); diff --git a/modules/publication/jsx/publicationIndex.js b/modules/publication/jsx/publicationIndex.js index 2c33c9cd2d8..7129add2b57 100644 --- a/modules/publication/jsx/publicationIndex.js +++ b/modules/publication/jsx/publicationIndex.js @@ -6,6 +6,10 @@ import React from 'react'; import PropTypes from 'prop-types'; import {ButtonElement} from 'jsx/Form'; import StaticDataTable from 'jsx/StaticDataTable'; +import {withTranslation} from 'react-i18next'; + +import i18n from 'I18nSetup'; +import hiStrings from '../locale/hi/LC_MESSAGES/publication.json'; /** * Publication index component @@ -14,8 +18,8 @@ class PublicationIndex extends React.Component { /** * @constructor */ - constructor() { - super(); + constructor(props) { + super(props); loris.hiddenHeaders = [ 'Description', 'Publication ID', @@ -82,10 +86,11 @@ class PublicationIndex extends React.Component { * @return {JSX} - React markup for the component */ render() { + const {t} = this.props; if (!this.state.isLoaded) { return (
@@ -133,7 +133,8 @@ EmailElement.defaultProps = { }, }; -export const TranslatedEmailElement = withTranslation(['loris'])(EmailElement); +export const TranslatedEmailElement = withTranslation( + ['publication', 'loris'])(EmailElement); /** * Project form fields component @@ -403,9 +404,11 @@ class ProjectFormFields extends React.Component { let voiHelp = ( - {t('For help finding variables of interest, consult', {ns: 'publication'})} + {t('For help finding variables of interest, consult', + {ns: 'publication'})}   - {t('Data Dictionary', {ns: 'loris'})} + {t('Data Dictionary', + {ns: 'loris'})} ); let collabNames = []; @@ -516,7 +519,7 @@ class ProjectFormFields extends React.Component { {collabEmails}
@@ -200,7 +201,6 @@ PublicationIndex.propTypes = { }; document.addEventListener('DOMContentLoaded', () => { - i18n.addResourceBundle('hi', 'publication', hiStrings); const PIIndex = withTranslation(['publication', 'loris'])(PublicationIndex); createRoot(document.getElementById('lorisworkspace')).render( diff --git a/modules/publication/jsx/uploadForm.js b/modules/publication/jsx/uploadForm.js index df0111ca137..f824b4fc389 100644 --- a/modules/publication/jsx/uploadForm.js +++ b/modules/publication/jsx/uploadForm.js @@ -7,6 +7,9 @@ import { TextboxElement, } from 'jsx/Form'; import {withTranslation} from 'react-i18next'; +import i18n from 'I18nSetup'; +import hiStrings from '../locale/hi/LC_MESSAGES/publication.json'; +i18n.addResourceBundle('hi', 'publication', hiStrings); /** * Publication upload form component @@ -162,7 +165,8 @@ class PublicationUploadForm extends React.Component { if (Object.keys(this.state.formErrors).length > 0) { swal.fire( - t('Please fix any remaining form errors before submission', {ns: 'loris'}), + t('Please fix any remaining form errors before submission', + {ns: 'loris'}), '', 'error' ); @@ -194,7 +198,8 @@ class PublicationUploadForm extends React.Component { console.error(response.status); response.json().then((data) => { let message = (data && data.message) || ''; - swal.fire(t('Something went wrong!', {ns: 'loris'}), message, 'error'); + swal.fire(t('Something went wrong!', {ns: 'loris'}), + message, 'error'); }); return; } diff --git a/modules/publication/jsx/viewProject.js b/modules/publication/jsx/viewProject.js index b74a70d789c..9c5cd3bd07f 100644 --- a/modules/publication/jsx/viewProject.js +++ b/modules/publication/jsx/viewProject.js @@ -11,6 +11,7 @@ import { import {withTranslation} from 'react-i18next'; import i18n from 'I18nSetup'; import hiStrings from '../locale/hi/LC_MESSAGES/publication.json'; +i18n.addResourceBundle('hi', 'publication', hiStrings); /** * View project component @@ -52,7 +53,8 @@ class ViewProject extends React.Component { if (Object.keys(this.state.formErrors).length > 0) { swal.fire( - t('Please fix any remaining form errors before submission', {ns: 'publication'}), + t('Please fix any remaining form errors before submission', + {ns: 'publication'}), '', 'error' ); @@ -83,7 +85,8 @@ class ViewProject extends React.Component { if (!response.ok) { console.error(response.status); response.json().then((data) => { - let message = (data && data.message) || t('Something went wrong!', {ns: 'publication'}); + let message = (data && data.message) || t('Something went wrong!', + {ns: 'publication'}); swal.fire(t('Edit failed!', {ns: 'publication'}), message, 'error'); }); return; @@ -93,7 +96,9 @@ class ViewProject extends React.Component { }).catch((error) => { // Network error console.error(error); - swal.fire(t('Edit failed!', {ns: 'publication'}), t('Something went wrong!', {ns: 'publication'}), 'error'); + swal.fire(t('Edit failed!', {ns: 'publication'}), + t('Something went wrong!', + {ns: 'publication'}), 'error'); }); } @@ -171,7 +176,7 @@ class ViewProject extends React.Component { // Network error console.error(error); this.setState({ - error: t('An error occured while loading the page.', {ns: 'publication'}), + error: t('An error occured while loading the page.', {ns: 'loris'}), }); }); } @@ -264,7 +269,7 @@ class ViewProject extends React.Component { let keywordLinks; let voiLinks; let files; - i18n.addResourceBundle('hi', 'publication', hiStrings); + if (this.state.formData.collaborators.length > 0) { collabLinks = this.createMenuFilterLinks( @@ -314,7 +319,7 @@ class ViewProject extends React.Component { /> ; + ; } else { const statClassMap = { Pending: 'text-warning', @@ -525,7 +529,7 @@ class ViewProject extends React.Component { ); statusElement = ; if (status === 'Rejected') { @@ -592,4 +596,5 @@ ViewProject.propTypes = { t: PropTypes.func, }; -export default withTranslation(['publication'])(ViewProject); +export default withTranslation( + ['publication', 'loris'])(ViewProject); diff --git a/modules/publication/jsx/viewProjectIndex.js b/modules/publication/jsx/viewProjectIndex.js index 496664e33b0..344bc9f4c5a 100644 --- a/modules/publication/jsx/viewProjectIndex.js +++ b/modules/publication/jsx/viewProjectIndex.js @@ -1,8 +1,11 @@ import {createRoot} from 'react-dom/client'; import ViewProject from './viewProject'; +import i18n from 'I18nSetup'; +import hiStrings from '../locale/hi/LC_MESSAGES/publication.json'; const args = QueryString.get(document.currentScript.src); document.addEventListener('DOMContentLoaded', () => { + i18n.addResourceBundle('hi', 'publication', hiStrings); const viewProject = (
diff --git a/modules/publication/locale/hi/LC_MESSAGES/publication.json b/modules/publication/locale/hi/LC_MESSAGES/publication.json deleted file mode 100644 index 09994cb9794..00000000000 --- a/modules/publication/locale/hi/LC_MESSAGES/publication.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "Publications": "प्रकाशन", - "Loading": "लोड हो रहा है", - "Browse": "ब्राउज़ करें", - "Clear Filters": "फ़िल्टर साफ़ करें", - "File to upload": "अपलोड करने के लिए फ़ाइल", - "Upload": "अपलोड करें", - "Are you sure?": "क्या आप सुनिश्चित हैं?", - "Cancel": "रद्द करें", - "Submit": "जमा करें", - "Title": "शीर्षक", - "Year": "वर्ष", - "Authors": "लेखक", - "Journal": "जर्नल", - "DOI": "डीओआई", - "Action": "क्रिया", - "Please fix any remaining form errors before submission": "कृपया सबमिट करने से पहले शेष फॉर्म त्रुटियों को ठीक करें", - "Something went wrong!": "कुछ गलत हो गया!", - "Submission Successful!": "सबमिशन सफल रहा!", - "Propose Project": "एक प्रोजेक्ट प्रस्तावित करें", - "Propose a new project": "एक नया प्रोजेक्ट प्रस्तावित करें", - "Edit failed!": "संपादन विफल रहा!", - "Edit Successful!": "संपादन सफल रहा!", - "Download": "डाउनलोड करें", - "Citation": "उद्धरण", - "Version": "संस्करण", - "Collaborators": "सहयोगी", - "Keywords": "कुंजीशब्द", - "Variables of Interest": "रुचि के चर", - "Description": "विवरण", - "Publishing status": "प्रकाशन स्थिति", - "Date published": "प्रकाशित तिथि", - "Link": "लिंक", - "Lead Investigator": "मुख्य अन्वेषक", - "Lead Investigator Email": "मुख्य अन्वेषक ईमेल", - "Status": "स्थिति", - "Reason for rejection": "अस्वीकृति का कारण", - "Pending": "लंबित", - "Approved": "स्वीकृत", - "Rejected": "अस्वीकृत", - "For help finding variables of interest, consult": "रुचि वाले वेरिएबल खोजने में सहायता के लिए, परामर्श करें" -} \ No newline at end of file diff --git a/modules/publication/locale/hi/LC_MESSAGES/publication.po b/modules/publication/locale/hi/LC_MESSAGES/publication.po index d6c1872de82..da9848269f0 100644 --- a/modules/publication/locale/hi/LC_MESSAGES/publication.po +++ b/modules/publication/locale/hi/LC_MESSAGES/publication.po @@ -27,9 +27,6 @@ msgstr "लोड हो रहा है" msgid "Browse" msgstr "ब्राउज़ करें" -msgid "Clear Filters" -msgstr "फ़िल्टर साफ़ करें" - msgid "File to upload" msgstr "अपलोड करने के लिए फ़ाइल" @@ -72,7 +69,7 @@ msgstr "कुछ गलत हो गया!" msgid "Submission Successful!" msgstr "सबमिशन सफल रहा!" -msgid "Propose Project" +msgid "Propose a Project" msgstr "एक प्रोजेक्ट प्रस्तावित करें" msgid "Propose a new project" @@ -138,3 +135,50 @@ msgstr "अस्वीकृत" msgid "For help finding variables of interest, consult" msgstr "रुचि वाले वेरिएबल खोजने में सहायता के लिए, परामर्श करें" +msgid "Date Proposed" +msgstr "प्रस्तावित तिथि" + +msgid "Approval Status" +msgstr "स्वीकृति स्थिति" + +msgid "Project" +msgstr "परियोजना" + +msgid "Project Proposal Creator" +msgstr "परियोजना प्रस्ताव निर्माता" + +msgid "Publication ID" +msgstr "प्रकाशन आईडी" + +msgid "Published" +msgstr "प्रकाशित" + +msgid "In Progress" +msgstr "प्रगति पर" + +msgid "View Project" +msgstr "परियोजना देखें" + +msgid "LORIS Users with Edit Permission" +msgstr "संपादन अनुमति वाले LORIS उपयोगकर्ता" + +msgid "Type of Variables of Interest" +msgstr "रुचि वाले वेरिएबल का प्रकार" + +msgid "Propose Project" +msgstr "परियोजना प्रस्तावित करें" + +msgid "Send email notification?" +msgstr "ईमेल अधिसूचना भेजें?" + +msgid "Add User" +msgstr "उपयोगकर्ता जोड़ें" + +msgid "Add Collaborator" +msgstr "सहयोगी जोड़ें" + +msgid "Add Keyword" +msgstr "कीवर्ड जोड़ें" + +msgid "Add Variable of Interest" +msgstr "रुचि वाला वेरिएबल जोड़ें" diff --git a/modules/publication/locale/publication.pot b/modules/publication/locale/publication.pot index a7e2ab3865b..3dff9eba5d4 100644 --- a/modules/publication/locale/publication.pot +++ b/modules/publication/locale/publication.pot @@ -27,9 +27,6 @@ msgstr "" msgid "Browse" msgstr "" -msgid "Clear Filters" -msgstr "" - msgid "File to upload" msgstr "" @@ -72,7 +69,7 @@ msgstr "" msgid "Submission Successful!" msgstr "" -msgid "Propose Project" +msgid "Propose a Project" msgstr "" msgid "Propose a new project" @@ -137,3 +134,51 @@ msgstr "" msgid "For help finding variables of interest, consult" msgstr "" + +msgid "Date Proposed" +msgstr "" + +msgid "Approval Status" +msgstr "" + +msgid "Project" +msgstr "" + +msgid "Project Proposal Creator" +msgstr "" + +msgid "Publication ID" +msgstr "" + +msgid "Published" +msgstr "" + +msgid "In Progress" +msgstr "" + +msgid "View Project" +msgstr "" + +msgid "LORIS Users with Edit Permission" +msgstr "" + +msgid "Type of Variables of Interest" +msgstr "" + +msgid "Propose Project" +msgstr "" + +msgid "Send email notification?" +msgstr "" + +msgid "Add User" +msgstr "" + +msgid "Add Collaborator" +msgstr "" + +msgid "Add Keyword" +msgstr "" + +msgid "Add Variable of Interest" +msgstr "" diff --git a/modules/publication/php/publication.class.inc b/modules/publication/php/publication.class.inc index 30852448bf2..c32b5af53ef 100644 --- a/modules/publication/php/publication.class.inc +++ b/modules/publication/php/publication.class.inc @@ -130,21 +130,21 @@ class Publication extends \NDB_Menu_Filter_Form $this->query = $query; $this->headers = [ - 'Title', - 'Lead Investigator', - 'Date Proposed', - 'Approval Status', - 'Project', - 'Journal', - 'Link', - 'Publishing Status', - 'Date published', - 'Project Proposal Creator', - 'Description', - 'Collaborators', - 'Variables Of Interest', - 'Keywords', - 'Publication ID', + dgettext("publication", "Title"), + dgettext("publication", "Lead Investigator"), + dgettext("publication", "Date Proposed"), + dgettext("publication", "Approval Status"), + dgettext("publication", "Project"), + dgettext("publication", "Journal"), + dgettext("publication", "Link"), + dgettext("publication", "Publishing Status"), + dgettext("publication", "Date published"), + dgettext("publication", "Project Proposal Creator"), + dgettext("publication", "Description"), + dgettext("publication", "Collaborators"), + dgettext("publication", "Variables Of Interest"), + dgettext("publication", "Keywords"), + dgettext("publication", "Publication ID"), ]; $this->validFilters = [ @@ -198,58 +198,61 @@ class Publication extends \NDB_Menu_Filter_Form $this->addBasicText( 'title', - 'Title' + dgettext("publication", "Title") ); $this->addSelect( 'approvalStatus', - 'Approval Status', + dgettext("publication", "Approval Status"), $statusOptions ); // filters by name $this->addBasicText( 'leadInvestigator', - 'Lead Investigator' + dgettext("publication", "Lead Investigator") ); //also filters by name $this->addBasicText( 'collaborators', - 'Collaborators' + dgettext("publication", "Collaborators") ); $this->addBasicText( 'keywords', - 'Keywords' + dgettext("publication", "Keywords") ); $this->addBasicText( 'variablesOfInterest', - 'Variables of Interest' + dgettext("publication", "Variables of Interest") ); $this->addBasicText( 'journal', - 'Journal' + dgettext("publication", "Journal") ); $this->addSelect( 'project', - 'Project', + dgettext("publication", "Project"), $projectOptions ); $this->addBasicText( 'link', - 'Link' + dgettext("publication", "Link") ); + $pubPublished = dgettext("publication", "Published"); + $pubInProgress = dgettext("publication", "In Progress"); + $this->addSelect( 'publishingStatus', - 'Publishing Status', + dgettext("publication", "Publishing Status"), [ - 'Published' => 'Published', - 'In Progress' => 'In Progress' + $pubPublished => $pubPublished, + $pubInProgress => $pubInProgress, ] ); } diff --git a/modules/publication/php/view_project.class.inc b/modules/publication/php/view_project.class.inc index ff56092eb7f..a621ca345a5 100644 --- a/modules/publication/php/view_project.class.inc +++ b/modules/publication/php/view_project.class.inc @@ -112,7 +112,7 @@ class View_Project extends \NDB_Form return new \LORIS\BreadcrumbTrail( new \LORIS\Breadcrumb($label, "/$this->name"), new \LORIS\Breadcrumb( - 'View Project', + dgettext("publication", "View Project"), "/publication/view_project?id=" . $_GET['id'] ) ); From f8fc607cb396ac16762638477b2788d9d593a28e Mon Sep 17 00:00:00 2001 From: T Saket Hatwar <112693309+SKADE2303@users.noreply.github.com> Date: Tue, 4 Nov 2025 02:41:42 +0530 Subject: [PATCH 3/3] lint --- modules/publication/jsx/viewProject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/publication/jsx/viewProject.js b/modules/publication/jsx/viewProject.js index 667235cf0eb..a9101246779 100644 --- a/modules/publication/jsx/viewProject.js +++ b/modules/publication/jsx/viewProject.js @@ -92,7 +92,7 @@ class ViewProject extends React.Component { return; } - swal.fire(t('Edit Successful!', + swal.fire(t('Edit Successful!', {ns: 'publication'}), '', 'success').then(() => { window.location.replace(loris.BaseURL + '/publication/'); });