WISE-Community / WISE-Client

Client-side code for WISE
Other
3 stars 4 forks source link

Improved default language switching functionality #1958

Open VM8gkAs opened 5 days ago

VM8gkAs commented 5 days ago

Changes

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 commented 4 days ago

@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 commented 4 days ago

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.

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.