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.
1. 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.
2. Click on "New Token"
3. Give token a meaningful name to distinguish its requests in security
logs
4. In scopes select the following:
- Projects
- Projects (List, Get, Create, Edit)
- Source files & strings
- Translations
5. Click "Create"
6. Confirm your identity by signing in again
7. 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:
1. Log in to the GitHub account that will be automated
2. Go to Settings > Developer Settings > Personal access tokens
> Tokens (classic)
3. Click "Generate new token" and select "Generate new token (classic)"
from the menu
4. Give token a meaningful name and reasonable expiration time
5. In scopes select `repo` scope
6. Save 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.
1. Navigate to the modrinth/knossos repository
2. Switch to Settings tab
3. Go to Secrets and variables > Actions
4. Create the following repository secrets:
- `CROWDIN_PERSONAL_TOKEN`: [your Crowdin token]
- `CROWDIN_GH_TOKEN`: [your GitHub automated account token]
5. 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.
1. Go to Modrinth Crowdin project
2. Switch to Integrations tab
3. Click on GitHub integration
4. Click on modrinth/knossos repository
5. Click "Delete integration"
6. 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.