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

I18n refactor commands #408

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

Conversation

rekt-hard
Copy link
Contributor

@rekt-hard rekt-hard commented Oct 22, 2024

❤️ Thank you for your contribution!

Description

This PR tackles i18n management for the UI. This is done to have the same workflow as the backend and be consistent throughout the package. Additionally, non-mandatory files are removed, manual work is reduced and the workflow should be easier to understand.

Most important files for these changes are .js files. Changes in .po, .pot and .json files are for cleanup and providing the current extraction for English.

  • Since Transifex is used to manage translations, all we have to provide is a .pot file as a source. This will be pushed to Transifex.
  • English is the default language and will not be provided by Transifex, so this is generated on extraction.
  • When pulling from Transifex, .po files will be generated/updated.
  • On package release
    • All available language files (.po) are compiled into .json files.
    • An auto-generated file imports all compiled translations and provides them for export.
    • These translations are then used by the application for lookup.
    • These compiled files (.json) do not have to be checked into version control. Only exception is English, as this is the default language.

It would make sense to move the adaptations of the publish workflow to the reusable workflows repository (https://github.com/inveniosoftware/workflows/blob/master/.github/workflows/pypi-publish.yml). This will require to provide the translations path as an input as is done here:

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Frontend

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

* Since Transifex is used to manage translations, all we have
  to provide is a .pot file as a source. This will be pushed
  to Transifex.
* English is the default language, so this is generated on extraction.
* When pulling from Transifex, .po files will be generated/updated.
* On package release, all available language files (.po) are  compiled
  into .json files. These are then used by the application for lookup.
@@ -44,7 +10,7 @@
},
"scripts": {
"extract_messages": "i18next-scanner --config i18next-scanner.config.js '../../js/**/*.{js,jsx}'",
"postextract_messages": "i18next-conv -l en -s ./messages/en/translations.json -t ./translations.pot",
"postextract_messages": "i18next-conv -l en -s ./messages/en/translations.json -t ./translations.pot && i18next-conv -l en -s ./messages/en/translations.json -t ./messages/en/messages.po",
Copy link
Contributor Author

@rekt-hard rekt-hard Oct 22, 2024

Choose a reason for hiding this comment

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

This will generate the .pot file for Transifex as well as the English .po file for the compilation process later.

Comment on lines +29 to +48

# setup node
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE-VERSION }}

- name: Install deps for frontend translations
working-directory: ./invenio_requests/assets/semantic-ui/translations/invenio_requests
# installing from package-lock.json
run: |
npm ci
npm list

# compile frontend messages
- name: Compile frontend messages
working-directory: ./invenio_requests/assets/semantic-ui/translations/invenio_requests
run: |
npm run compile_catalog

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It may make sense to move all of this to the reusable pypi publish workflow of inveniosoftware. More info can be found in the description of this PR.

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.

1 participant