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

Migration from webL10n to i18next #4459

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

ac-mmi
Copy link
Contributor

@ac-mmi ac-mmi commented Feb 24, 2025

@walterbender I have successfully migrated the internationalization system in Music Blocks from webL10n to i18next. I have tested the implementation, and it is working as expected. The only remaining task is to update the test suites, which are currently tailored for webL10n, to support the new i18next standards.

I made the following changes:

  • In loader.js: Added i18next initialization with i18nextHttpBackend to load translations from JSON files stored in the locales folder. This change allows the application to switch languages dynamically.
  • In Multiple JavaScript Files: Replaced instances of webL10n functionality with i18next's function for translations. This change was made across several files(activity.js,block.js,blocks.js,ActionBlocks.js,BooleanBlocks.js and more...)
  • Created locales Folder: Added a new folder named locales containing converted PO files into JSON format, supporting i18next's structure for managing translations.

Copy link

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

synthutils.test.js
SaveInterface.test.js
VolumeActions.test.js
musicutils.test.js
ToneActions.test.js
PitchActions.test.js
MeterActions.test.js
rubrics.test.js
turtle-singer.test.js
DrumActions.test.js
languagebox.test.js
DictActions.test.js
themebox.test.js
turtledefs.test.js
macros.test.js

@walterbender
Copy link
Member

I am not sure why you changed the _() function to t(). It is quite an invasive and seemingly unnecessary change.
Is there a standard way to convert the PO files to their JSON representation?
It seems (at least) the es file has some encoding issues.

@ac-mmi
Copy link
Contributor Author

ac-mmi commented Feb 24, 2025

@walterbender I switched from _() to t() because it's the standard function used by i18next. If preferred, I can alias _() to t() to minimize changes, make a wrapper function.
For the PO to JSON conversion, I used a custom Python script, ensuring comments were ignored and keys matched the original msgids. If there’s a preferred method, I’m open to adjustments.
I’ll check the encoding issues in the es file.

@ac-mmi
Copy link
Contributor Author

ac-mmi commented Feb 24, 2025

@walterbender If you were referring to encoding issues in es.po (if I assumed that correctly), I ran a thorough check on the PO files, including es.po, and didn't find any encoding issues using a custom script that detects unescaped quotes and encoding errors. The only issues found were in other files, like ayc.po, quz.po, and te.po, where unescaped double quotes were present.

@walterbender
Copy link
Member

I think keeping the _() wrapper is a good idea.
I am fine with a simple Python script for conversion of the PO files, but it would be good to test some of the more language-specific PO file features which we deliberately avoided with WebL10n, such as handling plurals and word order.
Please do look into the encoding issue. I only noticed it with ES but it could be elsewhere as well.

@walterbender
Copy link
Member

look t your es.json file and you'll see that it is no longer utf-8. It is some weird encoding.

"Are you sure you want to clear the workspace?": "¿Estás segura de que quieres borrar el espacio de trabajo?",

Should be:

"Are you sure you want to clear the workspace?": "¿Estás segura de que quieres borrar el espacio de trabajo?"",

Copy link

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

synthutils.test.js
VolumeActions.test.js
SaveInterface.test.js
musicutils.test.js
ToneActions.test.js
PitchActions.test.js
MeterActions.test.js
rubrics.test.js
turtle-singer.test.js
DrumActions.test.js
languagebox.test.js
DictActions.test.js
themebox.test.js
turtledefs.test.js
macros.test.js

@walterbender
Copy link
Member

Not sure what you are doing to fix the encodings, but it is not correct. There should not be any strings with "Â" in them. It is not a glyph used in Spanish.

Copy link

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

synthutils.test.js
VolumeActions.test.js
SaveInterface.test.js
musicutils.test.js
ToneActions.test.js
PitchActions.test.js
MeterActions.test.js
rubrics.test.js
DrumActions.test.js
turtle-singer.test.js
languagebox.test.js
DictActions.test.js
themebox.test.js
turtledefs.test.js
macros.test.js

@ac-mmi
Copy link
Contributor Author

ac-mmi commented Feb 24, 2025

@walterbender Could you please let me know the encoding format used in the PO files? This will help me improve the Python script for conversion and avoid similar issues in the future.

@walterbender
Copy link
Member

Everything should be utf-8

@omsuneri
Copy link
Member

@ac-mmi I saw many tests failures please try to resolve those along with the PR only.

@omsuneri
Copy link
Member

omsuneri commented Feb 24, 2025

@walterbender do we really need this change currently as I don't feel so
as this is part of one of the projects we have in GSOC let's wait till the best ideas we get as it is very early to decide the changes at this moment also @ac-mmi I feel we need a discussion before moving to i18n right now..

@omsuneri
Copy link
Member

@walterbender do we really need this change currently as I don't feel so currently
as this is part of one of the projects we have in GSOC let's wait till the best ideas we get as it is very early to decide the changes at this moment also @ac-mmi I feel we need a discussion before moving to i18n right now..

@walterbender
Copy link
Member

It needs work.

Copy link

✅ All Jest tests passed! This PR is ready to merge.

@ac-mmi
Copy link
Contributor Author

ac-mmi commented Feb 24, 2025

@walterbender i have made changes in the _() functionality catering to i18next functions and also passing the test suits of the repo

@walterbender
Copy link
Member

ES is still broken. Now all of the non-ASCII characters are just missing.
We need to discuss a number of other details, including how to handle the Kana/Kanji situation. And language detection in general.

Copy link

✅ All Jest tests passed! This PR is ready to merge.

@ac-mmi
Copy link
Contributor Author

ac-mmi commented Feb 25, 2025

@walterbender For language detection, we could detect user's browser or system language as a default.
I feel we should add a language selection screen(a drop-down list) at the start of the loading process to allow users to explicitly choose their preferred language. We could provide more specific language options like Japanese (Kana) and Japanese (Kanji)

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

Successfully merging this pull request may close these issues.

3 participants