This repository has been archived by the owner on Aug 3, 2024. It is now read-only.
Switch to manual Crowdin uploading and downloading #1640
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Important
Work in progress. Additional testing pending to ensure this PR is fully ready for review and merge.
Changes highlights
This commit adds two GitHub Actions workflow:
i18n-pull
i18n-pull downloads translations from Crowdin. It is run automatically every Monday at 7 AM GMT time. It builds the Crowdin project and then downloads all the files corresponding to the branch it is running for (for scheduled runs it is the default branch of the repository).
i18n-push
i18n-push runs the the extractor and uploads the source string files to Crowdin for translation. It is running for every push to the
master
branch and checks the changed files, trying to avoid unnecessary runs when none of the files changed contain translations.It can also be dispatched manually for every branch of the repository, which allows to create feature branches on Crowdin and give translators an early start. Translations for such branches can be downloaded by dispatching i18n-pull. They will also migrate automatically if the feature branch gets merged (see below).
i18n-cleanup
i18n-cleanup performs a cleanup of every repository branch deletion by deleting the translation branch on Crowdin as well Git pull branch. Deleting the translation branch after the merge allows Crowdin to migrate the translations to the other branch where updated strings now match (if no strings match, e.g., after PR rejection, then translations will just be deleted). Deletion of the pull branch closes the associated pull request which is most likely no longer relevant.
Since translations are now extracted automatically, there is no more need in index.json file being a part of the repository, which previously caused pains when dealing with pull requests, so it is removed now. Contibutors will have to run
pnpm intl:extract
manually now.Migration strategy
Please take extra care when migrating to this approach to avoid the loss of translations.
1 - Creating a Crowdin token
The first step is to create a token in order for Crowdin CLI to perform operations.
Navigate to the settings for the automated account on Crowdin, and then switch to API tab. Alternatively, use the link: https://crowdin.com/settings#api-key.
Click on "New Token"
Give token a meaningful name to distinguish its requests in security logs
In scopes select the following:
Click "Create"
Confirm your identity by signing in again
Save the access token somewhere temporarily, you will need it later
2 - Creating a GitHub token
In order for the download workflow to be able to create proper pull requests, it needs to puppeteer a user account. This is required for several reasons:
Other actions do not run on PRs created by actions
GitHub does not allow actions to create pull requests by default regardless the requested permissions in the workflow file. It requires enabling a dangerous permission in the organisation settings.
Bot's identity. Bot's cute.
To create a token:
Log in to the GitHub account that will be automated
Go to Settings > Developer Settings > Personal access tokens > Tokens (classic)
Click "Generate new token" and select "Generate new token (classic)" from the menu
Give token a meaningful name and reasonable expiration time
In scopes select
repo
scopeSave the token
3 - Setting up GitHub Actions secrets and variables
For workflows to work correctly, they need several variables. Assuming you completed the above steps, here's how you set them up.
Navigate to the modrinth/knossos repository
Switch to Settings tab
Go to Secrets and variables > Actions
Create the following repository secrets:
CROWDIN_PERSONAL_TOKEN
: [your Crowdin token]CROWDIN_GH_TOKEN
: [your GitHub automated account token]Create the following repository variables:
CROWDIN_PROJECT_ID
: [Crowdin project ID (Modrinth - 518556)]4 - Preparing Crowdin project
Because workflows will replace GitHub integration, that integration needs to be disabled before the merge to avoid conflics and accidental deletion of the translations due to 'deletion' of the source files.
Go to Modrinth Crowdin project
Switch to Integrations tab
Click on GitHub integration
Click on modrinth/knossos repository
Click "Delete integration"
Confirm deletion
5 - Merge
After following all the steps above you should be now ready to merge this pull request.
Make sure to check that actions do run after you merge it.