Skip to content
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

Improved default language switching functionality #1958

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

VM8gkAs
Copy link
Contributor

@VM8gkAs VM8gkAs commented Sep 27, 2024

Changes

  • Added mat-radio-button that needs to be disabled.
  • Resolved the issue where a page refresh was required to edit after switching the default language.

Test

After changing the default language, it will switch to the new default language.
image

Other Issues

After switching to another language, defaultLanguage does not change.
In the file
src/assets/wise5/authoringTool/components/abstract-translatable-field/abstract-translatable-field.component.ts

protected defaultLanguage: Language = this.projectService.getLocale().getDefaultLanguage();

image

@hirokiterashima
Copy link
Member

hirokiterashima commented Sep 27, 2024

@VM8gkAs Thanks for the contribution.

Your changes should work as expected when the unit has not been translated into different languages.

However, an issue arises when the unit (originally authored in lang1) has already been translated (to lang2, for example), and you switch the default language (from lang1 to lang2). You'd expect the unit to load with text in lang2, but right now, this is not the case because of the way the code works. To get this to work, switching the default language from lang1 to lang2 needs to swap out the translatable strings in project.json (which was saved in lang1) with values in translations.[lang2].json and then create translations.[lang1].json and copy strings over from project.json.

Until we have this swapping logic implemented, we were thinking about showing a message informing the author about this limitation, and to discourage author from switching default language if the unit has already been translated into another language. What do you think?

@VM8gkAs
Copy link
Contributor Author

VM8gkAs commented Sep 28, 2024

Option 1:
Initially, all text in project.json is stored by default in translations.[def_lang].json.

Option 2:
When switching the default language, create or overwrite translations.[lang_old].json,
and attempt to load translations.[lang_new].json.

  • 2.A. When translations.[lang_new].json exists:
    Load translations.[lang_new].json and replace all text in project.json.
  • 2.B. When translations.[lang_new].json does not exist:
    Do not change any text in project.json.

Option 3:
When switching the default language, do not change any text in project.json.

I think showing a message to inform the author about the limitation is a good temporary solution. Since switching the default language is likely to occur in the early stages of project creation, sticking with Option 3 and adding a reminder is feasible.
If we want to implement switching to a language included in the Additional languages, it may take some time to complete Option 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants