From e6ef362c4b97189daeffe1ef5beafa66b555d12b Mon Sep 17 00:00:00 2001 From: Pius Osuji Date: Fri, 4 Oct 2024 22:52:50 +0100 Subject: [PATCH 1/4] Refactor some files to i18n format instead of hardcoded string literals --- .../components/NoAssignmentMessage.jsx | 32 +++-- .../my_exercises/components/Header.jsx | 31 ++-- .../components/resources/resources.jsx | 134 ++++++++++-------- config/locales/en.yml | 9 ++ 4 files changed, 126 insertions(+), 80 deletions(-) diff --git a/app/assets/javascripts/components/overview/my_articles/components/NoAssignmentMessage.jsx b/app/assets/javascripts/components/overview/my_articles/components/NoAssignmentMessage.jsx index ea87701b40..b2117a4dc5 100644 --- a/app/assets/javascripts/components/overview/my_articles/components/NoAssignmentMessage.jsx +++ b/app/assets/javascripts/components/overview/my_articles/components/NoAssignmentMessage.jsx @@ -1,21 +1,35 @@ -import React from 'react'; +import React from "react"; export default ({ course }) => { - const findingLink = course.type === 'FellowsCohort' ? '/training/professional-development/finding-your-article-professional' : '/training/students/finding-your-article'; - const evaluatingLink = course.type === 'FellowsCohort' ? '/training/professional-development/evaluating-articles-professional' : '/training/students/evaluating-articles'; + const findingLink = + course.type === "FellowsCohort" + ? "/training/professional-development/finding-your-article-professional" + : "/training/students/finding-your-article"; + const evaluatingLink = + course.type === "FellowsCohort" + ? "/training/professional-development/evaluating-articles-professional" + : "/training/students/evaluating-articles"; return (
-

You have not chosen an article to work on. When you have found an article to work on, use the button above to assign it.

+

{I18n.t("articles.not_choosen_article")}

diff --git a/app/assets/javascripts/components/overview/my_exercises/components/Header.jsx b/app/assets/javascripts/components/overview/my_exercises/components/Header.jsx index 0c2b2ad0a2..67c2c95cef 100644 --- a/app/assets/javascripts/components/overview/my_exercises/components/Header.jsx +++ b/app/assets/javascripts/components/overview/my_exercises/components/Header.jsx @@ -1,33 +1,34 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { HashLink as Link } from 'react-router-hash-link'; +import React from "react"; +import PropTypes from "prop-types"; +import { HashLink as Link } from "react-router-hash-link"; export const Header = ({ completed = false, course, remaining = [], text }) => (
-

- { text } - { - remaining.length - ? {remaining.length} additional exercises remaining. - : null - } +

+ {text} + {remaining.length ? ( + + {remaining.length} {I18n.t("training.remaining_exercise")} + + ) : null}

el.scrollIntoView({ block: 'center' })} - to={`/courses/${course.slug}/resources#exercises`} className="resources-link" + scroll={(el) => el.scrollIntoView({ block: "center" })} + to={`/courses/${course.slug}/resources#exercises`} + className="resources-link" > - View all exercises + {I18n.t("training.view_all_exercise")}
); Header.propTypes = { course: PropTypes.shape({ - slug: PropTypes.string.isRequired + slug: PropTypes.string.isRequired, }).isRequired, remaining: PropTypes.array, - text: PropTypes.string.isRequired + text: PropTypes.string.isRequired, }; export default Header; diff --git a/app/assets/javascripts/components/resources/resources.jsx b/app/assets/javascripts/components/resources/resources.jsx index 55f4275d7c..f72eca8896 100644 --- a/app/assets/javascripts/components/resources/resources.jsx +++ b/app/assets/javascripts/components/resources/resources.jsx @@ -1,24 +1,24 @@ -import React, { useEffect } from 'react'; -import { connect } from 'react-redux'; +import React, { useEffect } from "react"; +import { connect } from "react-redux"; -import { getWeeksArray } from '../../selectors'; -import Block from '../timeline/block'; -import TrainingModules from '../timeline/TrainingModules/TrainingModules'; -import Handouts from './handouts'; -import Templates from './templates'; -import Videos from './videos'; -import { BLOCK_KIND_RESOURCES } from '../../constants/timeline'; -import { getModulesAndBlocksFromWeeks } from '../util/helpers'; +import { getWeeksArray } from "../../selectors"; +import Block from "../timeline/block"; +import TrainingModules from "../timeline/TrainingModules/TrainingModules"; +import Handouts from "./handouts"; +import Templates from "./templates"; +import Videos from "./videos"; +import { BLOCK_KIND_RESOURCES } from "../../constants/timeline"; +import { getModulesAndBlocksFromWeeks } from "../util/helpers"; const moduleByExercises = (modules) => { const orderedSteps = [ - 'Complete your Bibliography', - 'Create in the sandbox', - 'Expand your Draft', - 'Move your Work', - 'Other Assigned Training Modules', - 'Discussions', - 'Exercises', + "Complete your Bibliography", + "Create in the sandbox", + "Expand your Draft", + "Move your Work", + "Other Assigned Training Modules", + "Discussions", + "Exercises", ]; const [ COMPLETE_YOUR_BIBLIOGRAPHY, @@ -27,28 +27,28 @@ const moduleByExercises = (modules) => { MOVE_YOUR_WORK, OTHER, DISCUSSIONS, - EXERCISES + EXERCISES, ] = orderedSteps; const mapping = { - 'wikipedia-essentials': COMPLETE_YOUR_BIBLIOGRAPHY, - 'evaluating-articles': COMPLETE_YOUR_BIBLIOGRAPHY, - 'how-to-edit': CREATE_IN_THE_SANDBOX, - 'drafting-in-sandbox': CREATE_IN_THE_SANDBOX, - 'drafting-in-sandbox-group': CREATE_IN_THE_SANDBOX, + "wikipedia-essentials": COMPLETE_YOUR_BIBLIOGRAPHY, + "evaluating-articles": COMPLETE_YOUR_BIBLIOGRAPHY, + "how-to-edit": CREATE_IN_THE_SANDBOX, + "drafting-in-sandbox": CREATE_IN_THE_SANDBOX, + "drafting-in-sandbox-group": CREATE_IN_THE_SANDBOX, sources: CREATE_IN_THE_SANDBOX, plagiarism: EXPAND_YOUR_DRAFT, - 'moving-to-mainspace': MOVE_YOUR_WORK, - 'moving-to-mainspace-group': MOVE_YOUR_WORK, - 'sources-and-plagiarism-discussion': DISCUSSIONS, - 'content-gap-discussion': DISCUSSIONS, - 'thinking-about-wikipedia-discussion': DISCUSSIONS, - 'evaluate-wikipedia-exercise': EXERCISES, - 'choose-topic-from-list-exercise': EXERCISES, - 'add-to-article-exercise': EXERCISES, - 'did-you-know-exercise': EXERCISES, - 'continue-improving-exercise': EXERCISES, - 'in-class-presentation-exercise': EXERCISES, - 'reflective-essay-exercise': EXERCISES + "moving-to-mainspace": MOVE_YOUR_WORK, + "moving-to-mainspace-group": MOVE_YOUR_WORK, + "sources-and-plagiarism-discussion": DISCUSSIONS, + "content-gap-discussion": DISCUSSIONS, + "thinking-about-wikipedia-discussion": DISCUSSIONS, + "evaluate-wikipedia-exercise": EXERCISES, + "choose-topic-from-list-exercise": EXERCISES, + "add-to-article-exercise": EXERCISES, + "did-you-know-exercise": EXERCISES, + "continue-improving-exercise": EXERCISES, + "in-class-presentation-exercise": EXERCISES, + "reflective-essay-exercise": EXERCISES, }; const categorized = modules.reduce((acc, block) => { @@ -65,22 +65,34 @@ const moduleByExercises = (modules) => { const Resources = ({ weeks, current_user, course }) => { // setting page title useEffect(() => { - document.title = `${course.title} - ${I18n.t('resources.label')}`; + document.title = `${course.title} - ${I18n.t("resources.label")}`; }, []); const trainingLibrarySlug = course.training_library_slug; let instructorModulesLink; if (current_user.isInstructor && Features.wikiEd) { - instructorModulesLink = Instructor orientation modules; + instructorModulesLink = ( + + {I18n.t("training.orientation_modules")} + + ); } const { blocks, modules } = getModulesAndBlocksFromWeeks(weeks); let additionalResources; - const additionalResourcesBlocks = blocks.filter(block => block.kind === BLOCK_KIND_RESOURCES); + const additionalResourcesBlocks = blocks.filter( + (block) => block.kind === BLOCK_KIND_RESOURCES + ); if (additionalResourcesBlocks) { additionalResources = (
- {additionalResourcesBlocks.map(block => )} + {additionalResourcesBlocks.map((block) => ( + + ))}
); } @@ -89,49 +101,59 @@ const Resources = ({ weeks, current_user, course }) => { const categorized = moduleByExercises(modules); assignedModules = categorized.map(([title, categorizedModules]) => { if (categorizedModules) { - return (); + return ( + + ); } return null; - } - ); + }); } let additionalModules; if (Features.wikiEd) { additionalModules = ( - Additional training modules + + {I18n.t("training.additional_training")} + ); } else { additionalModules = ( - {I18n.t('training.training_library')} + + {I18n.t("training.training_library")} + ); } return (
-

{I18n.t('resources.header')}

+

{I18n.t("resources.header")}

{assignedModules} {additionalModules} {instructorModulesLink}
{additionalResources} - { Features.wikiEd && } - { Features.wikiEd && } - { Features.wikiEd && } + {Features.wikiEd && } + {Features.wikiEd && } + {Features.wikiEd && ( + + )}
); }; -const mapStateToProps = state => ({ - weeks: getWeeksArray(state) +const mapStateToProps = (state) => ({ + weeks: getWeeksArray(state), }); export default connect(mapStateToProps)(Resources); diff --git a/config/locales/en.yml b/config/locales/en.yml index a7e2a1fb3e..97928ac57f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -247,6 +247,11 @@ en: tracked_articles: Tracked Articles view_articles: View Articles no_tracked_articles: This category has no tracked articles + not_choosen_article: You have not chosen an article to work on. When you have found an + article to work on, use the button above to assign it. + use_dashboard: How to use the Dashboard + how_to_find: How to find an article + evaluate_and_source: Evaluating articles and sources items: items: Items @@ -1384,6 +1389,8 @@ en: previous: < Previous table_of_contents: Table of Contents training_library: Training Library + additional_training: Additional training modules + orientation_modules: Instructor orientation modules logged_out: "You are logged out. You will not receive credit for completing this module unless you log in." done: Done! invalid: Sorry that slide does not exist! @@ -1402,6 +1409,8 @@ en: search_training_resources: Search for training resources no_training_resource_match_your_search: No training resource matches your search exercise_sandbox: Exercise Sandbox + remaining_exercise: additional exercises remaining. + view_all: View all exercises update_username: header: Update a changed username From 5786f8da2ababa6a4773ea4dce8732c0dcf1b412 Mon Sep 17 00:00:00 2001 From: Pius Osuji Date: Sat, 5 Oct 2024 12:41:01 +0100 Subject: [PATCH 2/4] Fix build --- .../components/NoAssignmentMessage.jsx | 34 +++---- .../my_exercises/components/Header.jsx | 20 ++-- .../components/resources/resources.jsx | 92 +++++++++---------- 3 files changed, 73 insertions(+), 73 deletions(-) diff --git a/app/assets/javascripts/components/overview/my_articles/components/NoAssignmentMessage.jsx b/app/assets/javascripts/components/overview/my_articles/components/NoAssignmentMessage.jsx index b2117a4dc5..298226a4d6 100644 --- a/app/assets/javascripts/components/overview/my_articles/components/NoAssignmentMessage.jsx +++ b/app/assets/javascripts/components/overview/my_articles/components/NoAssignmentMessage.jsx @@ -1,35 +1,35 @@ -import React from "react"; +import React from 'react'; export default ({ course }) => { const findingLink = - course.type === "FellowsCohort" - ? "/training/professional-development/finding-your-article-professional" - : "/training/students/finding-your-article"; + course.type === 'FellowsCohort' + ? '/training/professional-development/finding-your-article-professional' + : '/training/students/finding-your-article'; const evaluatingLink = - course.type === "FellowsCohort" - ? "/training/professional-development/evaluating-articles-professional" - : "/training/students/evaluating-articles"; + course.type === 'FellowsCohort' + ? '/training/professional-development/evaluating-articles-professional' + : '/training/students/evaluating-articles'; return (
-

{I18n.t("articles.not_choosen_article")}

+

{I18n.t('articles.not_choosen_article')}

diff --git a/app/assets/javascripts/components/overview/my_exercises/components/Header.jsx b/app/assets/javascripts/components/overview/my_exercises/components/Header.jsx index 67c2c95cef..cebb9425b8 100644 --- a/app/assets/javascripts/components/overview/my_exercises/components/Header.jsx +++ b/app/assets/javascripts/components/overview/my_exercises/components/Header.jsx @@ -1,24 +1,24 @@ -import React from "react"; -import PropTypes from "prop-types"; -import { HashLink as Link } from "react-router-hash-link"; +import React from 'react'; +import PropTypes from 'prop-types'; +import { HashLink as Link } from 'react-router-hash-link'; export const Header = ({ completed = false, course, remaining = [], text }) => ( -
-

+
+

{text} {remaining.length ? ( - {remaining.length} {I18n.t("training.remaining_exercise")} + {remaining.length} {I18n.t('training.remaining_exercise')} ) : null}

el.scrollIntoView({ block: "center" })} + exact='true' + scroll={(el) => el.scrollIntoView({ block: 'center' })} to={`/courses/${course.slug}/resources#exercises`} - className="resources-link" + className='resources-link' > - {I18n.t("training.view_all_exercise")} + {I18n.t('training.view_all_exercise')}
); diff --git a/app/assets/javascripts/components/resources/resources.jsx b/app/assets/javascripts/components/resources/resources.jsx index f72eca8896..f8c2bae6c4 100644 --- a/app/assets/javascripts/components/resources/resources.jsx +++ b/app/assets/javascripts/components/resources/resources.jsx @@ -1,24 +1,24 @@ -import React, { useEffect } from "react"; -import { connect } from "react-redux"; +import React, { useEffect } from 'react'; +import { connect } from 'react-redux'; -import { getWeeksArray } from "../../selectors"; -import Block from "../timeline/block"; -import TrainingModules from "../timeline/TrainingModules/TrainingModules"; -import Handouts from "./handouts"; -import Templates from "./templates"; -import Videos from "./videos"; -import { BLOCK_KIND_RESOURCES } from "../../constants/timeline"; -import { getModulesAndBlocksFromWeeks } from "../util/helpers"; +import { getWeeksArray } from '../../selectors'; +import Block from '../timeline/block'; +import TrainingModules from '../timeline/TrainingModules/TrainingModules'; +import Handouts from './handouts'; +import Templates from './templates'; +import Videos from './videos'; +import { BLOCK_KIND_RESOURCES } from '../../constants/timeline'; +import { getModulesAndBlocksFromWeeks } from '../util/helpers'; const moduleByExercises = (modules) => { const orderedSteps = [ - "Complete your Bibliography", - "Create in the sandbox", - "Expand your Draft", - "Move your Work", - "Other Assigned Training Modules", - "Discussions", - "Exercises", + 'Complete your Bibliography', + 'Create in the sandbox', + 'Expand your Draft', + 'Move your Work', + 'Other Assigned Training Modules', + 'Discussions', + 'Exercises', ]; const [ COMPLETE_YOUR_BIBLIOGRAPHY, @@ -30,25 +30,25 @@ const moduleByExercises = (modules) => { EXERCISES, ] = orderedSteps; const mapping = { - "wikipedia-essentials": COMPLETE_YOUR_BIBLIOGRAPHY, - "evaluating-articles": COMPLETE_YOUR_BIBLIOGRAPHY, - "how-to-edit": CREATE_IN_THE_SANDBOX, - "drafting-in-sandbox": CREATE_IN_THE_SANDBOX, - "drafting-in-sandbox-group": CREATE_IN_THE_SANDBOX, + 'wikipedia-essentials': COMPLETE_YOUR_BIBLIOGRAPHY, + 'evaluating-articles': COMPLETE_YOUR_BIBLIOGRAPHY, + 'how-to-edit': CREATE_IN_THE_SANDBOX, + 'drafting-in-sandbox': CREATE_IN_THE_SANDBOX, + 'drafting-in-sandbox-group': CREATE_IN_THE_SANDBOX, sources: CREATE_IN_THE_SANDBOX, plagiarism: EXPAND_YOUR_DRAFT, - "moving-to-mainspace": MOVE_YOUR_WORK, - "moving-to-mainspace-group": MOVE_YOUR_WORK, - "sources-and-plagiarism-discussion": DISCUSSIONS, - "content-gap-discussion": DISCUSSIONS, - "thinking-about-wikipedia-discussion": DISCUSSIONS, - "evaluate-wikipedia-exercise": EXERCISES, - "choose-topic-from-list-exercise": EXERCISES, - "add-to-article-exercise": EXERCISES, - "did-you-know-exercise": EXERCISES, - "continue-improving-exercise": EXERCISES, - "in-class-presentation-exercise": EXERCISES, - "reflective-essay-exercise": EXERCISES, + 'moving-to-mainspace': MOVE_YOUR_WORK, + 'moving-to-mainspace-group': MOVE_YOUR_WORK, + 'sources-and-plagiarism-discussion': DISCUSSIONS, + 'content-gap-discussion': DISCUSSIONS, + 'thinking-about-wikipedia-discussion': DISCUSSIONS, + 'evaluate-wikipedia-exercise': EXERCISES, + 'choose-topic-from-list-exercise': EXERCISES, + 'add-to-article-exercise': EXERCISES, + 'did-you-know-exercise': EXERCISES, + 'continue-improving-exercise': EXERCISES, + 'in-class-presentation-exercise': EXERCISES, + 'reflective-essay-exercise': EXERCISES, }; const categorized = modules.reduce((acc, block) => { @@ -65,15 +65,15 @@ const moduleByExercises = (modules) => { const Resources = ({ weeks, current_user, course }) => { // setting page title useEffect(() => { - document.title = `${course.title} - ${I18n.t("resources.label")}`; + document.title = `${course.title} - ${I18n.t('resources.label')}`; }, []); const trainingLibrarySlug = course.training_library_slug; let instructorModulesLink; if (current_user.isInstructor && Features.wikiEd) { instructorModulesLink = ( - - {I18n.t("training.orientation_modules")} + + {I18n.t('training.orientation_modules')} ); } @@ -85,7 +85,7 @@ const Resources = ({ weeks, current_user, course }) => { ); if (additionalResourcesBlocks) { additionalResources = ( -
+
{additionalResourcesBlocks.map((block) => ( { additionalModules = ( - {I18n.t("training.additional_training")} + {I18n.t('training.additional_training')} ); } else { additionalModules = ( - - {I18n.t("training.training_library")} + + {I18n.t('training.training_library')} ); } return ( -
-
-

{I18n.t("resources.header")}

-
+
+
+

{I18n.t('resources.header')}

+
{assignedModules} {additionalModules} {instructorModulesLink} From 1091cb45140fe347ccbd7238a432d44c6706e926 Mon Sep 17 00:00:00 2001 From: Pius Osuji Date: Mon, 7 Oct 2024 18:48:30 +0100 Subject: [PATCH 3/4] Fix build --- .../components/NoAssignmentMessage.jsx | 18 ++++++++--------- .../my_exercises/components/Header.jsx | 8 ++++---- .../components/resources/resources.jsx | 20 +++++++++---------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/app/assets/javascripts/components/overview/my_articles/components/NoAssignmentMessage.jsx b/app/assets/javascripts/components/overview/my_articles/components/NoAssignmentMessage.jsx index 298226a4d6..5cba1b0427 100644 --- a/app/assets/javascripts/components/overview/my_articles/components/NoAssignmentMessage.jsx +++ b/app/assets/javascripts/components/overview/my_articles/components/NoAssignmentMessage.jsx @@ -1,12 +1,10 @@ import React from 'react'; export default ({ course }) => { - const findingLink = - course.type === 'FellowsCohort' + const findingLink = course.type === 'FellowsCohort' ? '/training/professional-development/finding-your-article-professional' : '/training/students/finding-your-article'; - const evaluatingLink = - course.type === 'FellowsCohort' + const evaluatingLink = course.type === 'FellowsCohort' ? '/training/professional-development/evaluating-articles-professional' : '/training/students/evaluating-articles'; @@ -15,19 +13,19 @@ export default ({ course }) => {

{I18n.t('articles.not_choosen_article')}

diff --git a/config/locales/en.yml b/config/locales/en.yml index 97928ac57f..c722444456 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1409,7 +1409,7 @@ en: search_training_resources: Search for training resources no_training_resource_match_your_search: No training resource matches your search exercise_sandbox: Exercise Sandbox - remaining_exercise: additional exercises remaining. + remaining_exercise: "%{count} additional exercises remaining." view_all: View all exercises update_username: