-
Notifications
You must be signed in to change notification settings - Fork 186
[module_manager] Add Translations to Module_Manager #10002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SKADE2303
wants to merge
4
commits into
aces:main
Choose a base branch
from
SKADE2303:TranslateModuleManager
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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. | ||
|
|
@@ -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, | ||
| { | ||
|
|
@@ -98,18 +104,25 @@ 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 ', {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', {ns: 'module_manager'}) + | ||
|
||
| 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 +133,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' | ||
| ); | ||
| } | ||
|
|
@@ -160,13 +174,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} | ||
|
|
@@ -184,8 +201,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 | ||
|
|
@@ -194,20 +213,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'}), | ||
| }, | ||
| }}, | ||
| ]; | ||
|
|
@@ -226,13 +245,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')} | ||
|
|
||
13 changes: 13 additions & 0 deletions
13
modules/module_manager/locale/hi/LC_MESSAGES/module_manager.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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": "पूरा नाम" | ||
| } |
52 changes: 52 additions & 0 deletions
52
modules/module_manager/locale/hi/LC_MESSAGES/module_manager.po
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # 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 "अद्यतन नहीं कर सका " | ||
|
|
||
| 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 "पूरा नाम" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between this and line 76/77?