Skip to content

fix: translation on select problem type #1798

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
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

igobranco
Copy link
Contributor

@igobranco igobranco commented Apr 9, 2025

The select problem type and advanced problem types didn't function correctly with i18n/translation.

Description

This PR fixes the translations/i18n of the "Select problem type"; and following screen "Advanced problem type" selection; and the following screen that shows a description of the problem.

Next some screenshots with highlighted section fixed:

image

image

image

Supporting information

Any. Just private internal issues on NAU platform.

Testing instructions

make pull_translations

Add to your language json file, example for pt-pt locale src/i18n/messages/frontend-app-course-authoring/pt_PT.json:

  "authoring.problemeditor.problemtype.title.singleselect": "Seleção única",
  "authoring.problemeditor.problemtype.title.multiSelect": "Seleção múltipla",
  "authoring.problemeditor.problemtype.title.dropdown": "Lista pendente",
  "authoring.problemeditor.problemtype.title.numeric": "Entrada numérica",
  "authoring.problemeditor.problemtype.title.textInput": "Entrada de texto",
  "authoring.problemeditor.problemtype.title.advanced": "Problema avançado",
  "authoring.problemeditor.settings.showanswertype.always": "Sempre",
  "authoring.problemeditor.settings.showanswertype.answered": "Respondido",
  "authoring.problemeditor.settings.showanswertype.attempted": "Tentativa ou atraso",
  "authoring.problemeditor.settings.showanswertype.closed": "fechado",
  "authoring.problemeditor.settings.showanswertype.finished": "terminado",
  "authoring.problemeditor.settings.showanswertype.correct_or_past_due": "correcto_ou_atrasado",
  "authoring.problemeditor.settings.showanswertype.past_due": "vencido",
  "authoring.problemeditor.settings.showanswertype.never": "nunca",
  "authoring.problemeditor.settings.showanswertype.after_attempts": "após_tentativas",
  "authoring.problemeditor.settings.showanswertype.after_all_attempts": "após_todas_tentativas",
  "authoring.problemeditor.settings.showanswertype.after_all_attempts_or_correct": "após_todas_as_tentativas_ou_correcção",
  "authoring.problemeditor.settings.showanswertype.attempted_no_past_due": "tentativa_no_past_due",
  "authoring.problemeditor.settings.RandomizationTypes.always": "sempre",
  "authoring.problemeditor.settings.RandomizationTypes.never": "nunca",
  "authoring.problemeditor.settings.RandomizationTypes.onreset": "onreset",
  "authoring.problemeditor.settings.RandomizationTypes.perstudent": "por aluno",

  "authoring.problemeditor.problemtype.previewDescription.singleselect": "Os alunos devem selecionar a resposta correta a partir de uma lista de opções possíveis.",
  "authoring.problemeditor.problemtype.previewDescription.multiselect": "Os alunos devem selecionar todas as respostas corretas a partir de uma lista de opções possíveis.",
  "authoring.problemeditor.problemtype.previewDescription.dropdown": "Os alunos devem selecionar a resposta correta a partir de uma lista de opções possíveis",
  "authoring.problemeditor.problemtype.previewDescription.numeric": "Especificar uma ou mais respostas numéricas corretas, apresentadas num campo de resposta",
  "authoring.problemeditor.problemtype.previewDescription.textinput": "Especificar uma ou mais respostas de texto corretas, incluindo números e caracteres especiais, apresentadas num campo de resposta.",
  "authoring.problemeditor.problemtype.previewDescription.advanced": "Especificar um problema avançado.",

    
  "authoring.problemeditor.problemtype.description.singleselect": "Introduza as suas respostas de seleção única abaixo e selecione as opções corretas. Os alunos devem escolher uma resposta correta.",
  "authoring.problemeditor.problemtype.description.multiselect": "Introduza as suas respostas multi-selecionadas abaixo e selecione as opções corretas. Os alunos devem escolher todas as respostas corretas.",
  "authoring.problemeditor.problemtype.description.dropdown": "Introduza as respostas da lista pendente abaixo e selecione a opção correta. Os alunos devem selecionar uma resposta correta.",
  "authoring.problemeditor.problemtype.description.numeric": "Introduza as respostas numéricas corretas abaixo. Os alunos devem introduzir uma resposta correta.",
  "authoring.problemeditor.problemtype.description.textinput": "Introduza as suas respostas de texto abaixo e selecione as opções corretas. Os alunos devem introduzir uma resposta correta.",
  "authoring.problemeditor.problemtype.description.advanced": "Um tipo de problema avançado.",

  "authoring.problemeditor.settings.advanceProblems.blank": "Problema em branco",
  "authoring.problemeditor.settings.advanceProblems.circuitSchematic": "Construtor de esquemas de circuitos",
  "authoring.problemeditor.settings.advanceProblems.jsInput": "Visualização e classificação JavaScript personalizadas",
  "authoring.problemeditor.settings.advanceProblems.customGrader": "Entrada personalizada avaliada por Python",
  "authoring.problemeditor.settings.advanceProblems.image": "Entrada mapeada por imagem",
  "authoring.problemeditor.settings.advanceProblems.formula": "Entrada de expressão matemática",
  "authoring.problemeditor.settings.advanceProblems.problemWithHint": "Problema com a sugestão adaptativa",

  "authoring.problemeditor.settings.advanceProblems.status.empty": "",
  "authoring.problemeditor.settings.advanceProblems.status.notSupported": "Não suportado",
  "authoring.problemeditor.settings.advanceProblems.status.provisional": "Provisório",

Other information

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Apr 9, 2025
@openedx-webhooks
Copy link

openedx-webhooks commented Apr 9, 2025

Thanks for the pull request, @igobranco!

This repository is currently maintained by @openedx/2u-tnl.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Apr 9, 2025
@igobranco igobranco marked this pull request as draft April 9, 2025 17:39
The select problem type and advanced problem types didn't function correctly with i18n/translation.
@igobranco igobranco force-pushed the igobranco/fix-translation-select-problem-type branch from f790b02 to 173d73d Compare April 9, 2025 17:48
Copy link

codecov bot commented Apr 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.51%. Comparing base (fe36e65) to head (a1bd09f).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1798      +/-   ##
==========================================
+ Coverage   93.50%   93.51%   +0.01%     
==========================================
  Files        1128     1131       +3     
  Lines       22925    22970      +45     
  Branches     4953     4959       +6     
==========================================
+ Hits        21436    21481      +45     
  Misses       1413     1413              
  Partials       76       76              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Extract from problem.ts, its types and its messages.
The messages uses the types definition.
The problem file depends on both and reexport everything so we don't have to change all project.
@igobranco igobranco self-assigned this Apr 10, 2025
@igobranco igobranco marked this pull request as ready for review April 10, 2025 07:49
Copy link
Contributor

@brian-smith-tcril brian-smith-tcril left a comment

Choose a reason for hiding this comment

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

First and foremost thank you so much for finding the gaps in internationalization here!

After reading though this PR, the approach here isn't fully clear to me. I left a few comments with questions.

@@ -54,25 +55,29 @@ const AdvanceTypeSelect: React.FC<Props> = ({
className="px-4"
>
{Object.entries(AdvanceProblems).map(([type, data]) => {
if (data.status !== '') {
if (data.status !== AdvanceProblemsStatus.empty) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels odd to me for a couple reasons:

  • Internationalizing an empty string seems unnecessary
  • We aren't using intl here, so wouldn't this end up checking for the object instead of the string?

I'd think sticking to '' would be simpler and continue to work. Did you run into something that made that not work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it is kind of strange, but the status of AdvanceProblems is now a AdvanceProblemsStatus.

return (
<ActionRow className="border-primary-100 border-bottom m-0 py-3 w-100" key={type}>
<Form.Radio id={type} value={type}>
{intl.formatMessage(messages.advanceProblemTypeLabel, { problemType: data.title })}
{intl.formatMessage(messages.advanceProblemTypeLabel, {
problemType: intl.formatMessage(data.titleMessage),
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you elaborate on the title vs titleMessage stuff? I see down in problem.ts you've added titleMessage and set title to use the defaultMessage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea of titleMessage was to prevent having to create further code refactor on the references of the problem.ts file.
But still kind of using the existing design of Object Oriented idea of the ProblemTypes and AdvanceProblems.
And extracting the i18n to a proper defineMessages so the formatjs can detect them.
So, when you want to present them to the user, I just replace the title with titleMessage on a intl.formatMessage(...).

</Form.Radio>
<ActionRow.Spacer />
<OverlayTrigger
placement="right"
overlay={(
<Tooltip id={`tooltip-adv-${type}`}>
<div className="text-left">
{intl.formatMessage(messages.supportStatusTooltipMessage, { supportStatus: data.status.replace(' ', '_') })}
{intl.formatMessage(messages.supportStatusTooltipMessage, { supportStatus: data.status.defaultMessage.replace(' ', '_') })}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this using the default message instead of an internationalized version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because of the supportStatusTooltipMessage is a select, so to decide which one should be shown the key is the default value one i18n or Not_supported or Provisional. I prefer not to change too much the existing code.
The replace(' ', '_') probably is because the select from i18n don't allow the key to have whitespace.

https://github.com/fccn/frontend-app-authoring/blob/a1bd09fd7abeba421eadde96362caa48340289d5/src/editors/containers/ProblemEditor/components/SelectTypeModal/content/messages.ts#L30-L46

When I add the translation to pt-pt locale on src/i18n/messages/frontend-app-course-authoring/pt_PT.json:

"authoring.problemEditor.advanceProblem.supportStatus.tooltipMessage": "{supportStatus, select, Provisional {As ferramentas suportadas provisoriamente podem não ter a robustez de funcionalidade que os seus cursos exigem. O edX não tem controlo sobre a qualidade do software ou do conteúdo que pode ser fornecido utilizando estas ferramentas. Teste estas ferramentas cuidadosamente antes de as utilizar no seu curso, especialmente em secções com classificação. A documentação completa pode não estar disponível para as ferramentas suportadas provisoriamente, ou a documentação pode estar disponível a partir de outras fontes que não a edX.} Not_supported {As ferramentas sem suporte não são mantidas pela edX e podem ser descontinuadas no futuro. Não são recomendadas para utilização em cursos devido à não conformidade com um ou mais dos requisitos básicos, tais como testes, acessibilidade, internacionalização e documentação.} other { } }",

It shows correctly has:

image
image

@mphilbrick211 mphilbrick211 moved this from Needs Triage to In Eng Review in Contributions Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Status: In Eng Review
Development

Successfully merging this pull request may close these issues.

3 participants