Skip to content

Commit 02a1800

Browse files
authored
Merge pull request #8 from Scientific-Python-Translations/docs/maintainers
Update maintainers docs
2 parents 395549a + df149a8 commit 02a1800

File tree

1 file changed

+133
-53
lines changed

1 file changed

+133
-53
lines changed

content/docs.md

Lines changed: 133 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ https://github.com/Scientific-Python-Translations/automations/.
1818
[Crowdin](https://scientific-python.crowdin.com/) provides GitHub integration
1919
tools to sync all translated content from the Crowdin web interface into project
2020
websites and vice-versa. However, a few adaptations are needed. The following
21-
steps describe what maintainers need to do to set up the integration. See [](#automations) for more details on this script.
21+
steps describe what maintainers need to do to set up the integration.
2222

2323
### Setting up Crowdin
2424

2525
Create a Crowdin project for your repository and turn on synchronization
26-
between Crowdin and your source repo. If you planning on using the
26+
between Crowdin and your source repo. If you are planning on using the
2727
[Scientific Python Crowdin workspace](https://scientific-python.crowdin.com/),
2828
please reach out to the
2929
[Scientific Python translations team on discord](https://discord.com/invite/vur45CbwMz)
@@ -32,10 +32,10 @@ for help. For more information, see
3232

3333
To prevent extra activity in the original source repository, we recommend
3434
creating a separate repository for the translations under
35-
https://github.com/scientific-python-translations with a GitHub action to sync
36-
the translations to the original repository (see
37-
[sync.yml](https://github.com/Scientific-Python-Translations/scipy.org-translations/blob/main/.github/workflows/sync.yml)
38-
for an example).
35+
https://github.com/scientific-python-translations. To get you started with the project
36+
repository we provide a [translations-cookiecutter](https://github.com/Scientific-Python-Translations/translations-cookiecutter) template.
37+
38+
This template includes the necessary workflows that will run periodically to keep the infrastructure in sync. See [](#automation-details) for more information.
3939

4040
### Announce your project to potential translators
4141

@@ -49,69 +49,149 @@ later.
4949
You can find potential translators by reaching out in the `#translation` channel
5050
on the [Scientific Python Discord server](https://discord.com/invite/vur45CbwMz).
5151

52-
### Merging translations
52+
### Crowdin integration
5353

5454
As translators work on the Crowdin platform, a Pull Request is automatically
5555
created in the project repository. This PR **should not** be merged, as it
5656
contains all translations for all languages (see
57-
[numpy/numpy.org#778](https://github.com/numpy/numpy.org/pull/778) for an
58-
example). If your website is set up through the Scientific Python Translations
59-
org, this PR will have the `do-not-merge` label applied to it.
60-
61-
After translations for a language are completed and ready to be deployed, you
62-
should:
63-
64-
1. Go to the repository corresponding to your project's sources under
65-
https://github.com/Scientific-Python-Translations
66-
2. Go to the Actions tab
67-
3. Manually trigger the "Create translations PR" workflow, with the language
68-
code for your language of interest as input.
57+
[Scientific-Python-Translations/scipy.org-translations#187](https://github.com/Scientific-Python-Translations/scipy.org-translations/pull/187) for an
58+
example). This PR will be opened againts the translations repository (e.g. Scientific-Python-Translations/scipy.org-translations). If your website is set up throughthe Scientific Python Translations
59+
org, this PR will should have the `do-not-merge` label applied to it to ensure the PR
60+
will not be merged accidentally.
6961

70-
<center><img alt="Screenshot of the Actions tab from GitHub, with the Create translations PR workflow highlighted." src="../images/create_translations.png" width=800/></center>
71-
72-
<center><img alt="Screenshot of the Run workflow dialog from GitHub, with an input field labeled Crowding language code for the language of interest" src="../images/run_workflow.png" width=800/></center>
62+
{{< admonition important >}}
63+
To prevent future conflicts with the GitHub/Crowdin integration, it is important
64+
that you configure Crowdin to have duplicate strings share the same translation.
65+
To do this, navigate to your project's Settings in Crowdin, select Import and under
66+
"Source strings" -> "Duplicates" choose "Hide (regular detection)".
7367

74-
After these steps, a PR will be created to your website repo with the
75-
translations for the language you selected (see
76-
[numpy/numpy.org#774](https://github.com/numpy/numpy.org/pull/774) for an example.) This PR should be
77-
merged when you are ready to publish the translations.
68+
<center><img alt="Screenshot of the Crowdin Settings showing the 'Hide (regular detection)' option." src="../images/duplicate_strings.png" width=800/></center>
7869

79-
### Cleaning up
70+
{{< /admonition >}}
8071

81-
After merging the translations PR, the Crowdin service branch (by default, named `l10n_main`) will have merge conflicts with `main`. To fix this, delete the Crowdin service branch. Crowdin will automatically recreate the service branch with merge conflicts resolved. This same process can also be used to resolve merge conflicts if translations are updated outside of Crowdin.
8272

8373
## Automation details
8474

85-
Once a GitHub repository has been synced to Crowdin using the Scientific Python
86-
set up, the
87-
[`create_branch_for_language.sh` script](https://github.com/Scientific-Python-Translations/automations/blob/main/scripts/create_branch_for_language.sh)
88-
is used to create a new branch including all (and only) commits from Crowdin's
89-
branch for a particular language of interest. This script is useful because:
75+
The following diagram illustrates how the different components of automation work takeing the scipy.org webiste as an example.
76+
77+
```mermaid
78+
flowchart TD
79+
B -.->|sync_translations.yml <br/> #40;PRs to add translations#41;| A
80+
A[Source repository <br/><br/> #40;scipy/scipy.org#41;] -->|sync_content.yml <br/> #40;PR to sync content - automerged#41;| B[Translation repository <br/><br/> #40;Scientific-Python-Translations/scipy.org-translations#41;]
81+
C[Crowdin <br/><br/> #40;scientific-python.crowdin.com#41;] -->|sync_translations.yml <br/> #40;PRs to add translations & contributors - automerged#41;| B
82+
A -->|Crowdin integration| C
83+
```
84+
85+
### Cookiecutter template
86+
87+
Use the cookiecutter template to generate a translation-ready repo:
88+
89+
```bash
90+
cookiecutter gh:Scientific-Python-Translations/translations-cookiecutter
91+
```
92+
93+
When prompted, enter the details for your project (e.g. project name, organization, base branch). The structure will include necessary metadata, content folders, and pre-commit configuration. See the [Cookiecutter repository](https://github.com/Scientific-Python-Translations/translations-cookiecutter) for more information.
94+
95+
### Sync content from the source repo
96+
97+
The [`sync_content.yml` github workflow](https://github.com/Scientific-Python-Translations/translations-cookiecutter/blob/main/%7B%7Bcookiecutter.__translations_repo_name%7D%7D/.github/workflows/sync_content.yml) is in charge of keeping the **original source content** in sync with the translations repository within the Scientific Python Translations organization.
98+
99+
This workflow uses the `content-sync` [Github action](https://github.com/Scientific-Python-Translations/content-sync).
100+
101+
### Example: Sync SciPy content
102+
103+
```yaml
104+
name: Sync Content
105+
on:
106+
schedule:
107+
- cron: '0 5 * * *'
108+
workflow_dispatch:
109+
jobs:
110+
sync:
111+
runs-on: ubuntu-latest
112+
steps:
113+
- name: Sync Scipy Content
114+
uses: Scientific-Python-Translations/content-sync@main
115+
with:
116+
source-repo: "scipy/scipy.org"
117+
source-folder: "scipy.org/content/en/"
118+
source-ref: "main"
119+
translations-repo: "Scientific-Python-Translations/scipy.org-translations"
120+
translations-folder: "scipy.org-translations/content/en/"
121+
translations-ref: "main"
122+
# These are provided by the Scientific Python Project and allow
123+
# automation with bots
124+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
125+
passphrase: ${{ secrets.PASSPHRASE }}
126+
token: ${{ secrets.TOKEN }}
127+
```
128+
129+
This ensures your translation repo always has the latest source material in English (the chosen source language). If the source content has changed since the latest workflow run,
130+
the translations bot will automatically create a Pull Request with signed commits and merge it automatically.
131+
132+
### Pull translations from Crowdin
133+
134+
The [`sync_translations.yml` github workflow](https://github.com/Scientific-Python-Translations/translations-cookiecutter/blob/main/%7B%7Bcookiecutter.__translations_repo_name%7D%7D/.github/workflows/sync_translations.yml) is in charge of keeping the **translated content** in sync with the translations repository within the Scientific Python Translations organization.
135+
136+
This workflow uses the `translations-sync` [Github action](https://github.com/Scientific-Python-Translations/translations-sync).
137+
138+
#### Example: Sync SciPy.org translations
139+
140+
```yaml
141+
name: Sync Translations
142+
on:
143+
# schedule:
144+
# - cron: '0 12 * * MON' # Every Monday at noon
145+
workflow_dispatch:
146+
jobs:
147+
build:
148+
runs-on: ubuntu-latest
149+
steps:
150+
- name: Sync Scipy translations
151+
uses: Scientific-Python-Translations/translations-sync@main
152+
with:
153+
# Provided by user
154+
crowdin-project: "scipy.org"
155+
source-repo: "scipy/scipy.org"
156+
source-folder: "scipy.org/content/en/"
157+
source-ref: "main"
158+
translations-repo: "Scientific-Python-Translations/scipy.org-translations"
159+
translations-folder: "scipy.org-translations/content/en/"
160+
translations-ref: "main"
161+
translation-percentage: "90"
162+
approval-percentage: "0"
163+
use-precommit: "true"
164+
create-toml-file: "true"
165+
# Provided by organization secrets
166+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
167+
passphrase: ${{ secrets.PASSPHRASE }}
168+
token: ${{ secrets.TOKEN }}
169+
crowdin-token: ${{ secrets.CROWDIN_TOKEN }}
170+
```
171+
172+
In the Crowdin interface, source strings are _translated_ and then _approved_ (which means a second translator has reviewed and approved the translation of this source string). Everytime this workflow runs, the translations bot will check for the available languages and check if they meet the translation percentage (90% by default) and approval percentage (0% by default). For every language that passes the criteria, which can be defined by the project mainatiners, a new Pull Request with signed commits will be created in the translations repository and the source repository.
173+
174+
To gather information on translators, an additional Pull Request will be created on the translations repository with a `translators.yml` file that lists the details such as username, fullname and avatar from the crowdin site.
175+
176+
All Pull Requests created by the Automations Bot on the translation repositories will be automatically merged.
90177

91-
1. Crowdin will keep commits for all the available languages under translation
92-
in the same branch. However, we prefer to be able to create pull requests for
93-
one language at a time to keep Pull Request reviews smaller and easier to manage.
178+
### Cleaning up
94179

95-
2. There are times when translations must be edited manually (outside of
96-
Crowdin) due to incorrect segmentation of the content into strings for
97-
translation. Crowdin's branch can only be edited through the Crowdin UI, and
98-
commits pushed to it outside of Crowdin will be lost when the branch is
99-
synced. By creating a new branch with only the commits we are interested in,
100-
we can bypass this limitation.
180+
After merging the translations PR, the Crowdin service branch (by default, named `l10n_main`) may have merge conflicts with `main`. To fix this, delete the Crowdin service branch. Crowdin will automatically recreate the service branch with merge conflicts resolved. This same process can also be used to resolve merge conflicts if translations are updated outside of Crowdin.
101181

102-
Ideally you will **not** have to run the `create_branch_for_language.sh` script
103-
directly, but can include it as part of your website deployment process (see,
104-
for example, [numpy/numpy.org#772](https://github.com/numpy/numpy.org/pull/772))
182+
### The translations bot
105183

106-
{{< admonition important >}}
107-
To prevent future conflicts with the GitHub/Crowdin integration, it is important
108-
that you configure Crowdin to have duplicate strings share the same translation.
109-
To do this, navigate to your project's Settings in Crowdin, select Import and under
110-
"Source strings" -> "Duplicates" choose "Hide (regular detection)".
184+
All automations and pull requests are performed by:
185+
[**@scientificpythontranslations**](https://github.com/scientificpythontranslations)
111186

112-
<center><img alt="Screenshot of the Crowdin Settings showing the 'Hide (regular detection)' option." src="../images/duplicate_strings.png" width=800/></center>
187+
Make sure to grant the bot appropriate repository permissions and exempt it from branch protection rules if needed.
113188

114-
{{< /admonition >}}
189+
### 📚 Additional resources
190+
191+
- [How to Translate Content](https://scientific-python-translations.github.io/translate/)
192+
- [FAQ](https://scientific-python-translations.github.io/faq/)
193+
- [Crowdin Setup](https://crowdin.com/)
194+
- [Scientific Python Discord – `#translation`](https://scientific-python.org/community/)
115195

116196
## Setting up a language switcher
117197

@@ -130,4 +210,4 @@ This work is in progress - follow [pydata/pydata-sphinx-theme#507](https://githu
130210
Translations may not always be up to date for items such as news items and
131211
release announcements. In this case, your project can decide what to do with
132212
these items (for example, keep them in English or hide them from the deployed
133-
site.)
213+
site.)

0 commit comments

Comments
 (0)