You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: data/blog/main/how-sync-translations.md
+22-21
Original file line number
Diff line number
Diff line change
@@ -5,31 +5,31 @@ date: May 21, 2024
5
5
tags: translation
6
6
slug: how-sync-translations
7
7
8
-
One of the challenges of maintaining translations is keeping up with the changes to the original document as the project evolves and new releases are made.
8
+
One of the challenges of maintaining different translations of documentation for an open source project is keeping up with the changes to the documentation in its original language as the project evolves and new releases are issued and updates are made.
9
9
10
-
In the case of the Flask documentation, there is the additional challenge of working in separate repositories.
10
+
As I learned during a recent open source sprint organized at PyCon US 2024, in the case of Flask’s documentation, there is an additional challenge of working in separate repositories for each language the documentation is translated into.
11
11
12
-
This post will document a simple process that the contributors and maintainers of the different language translations can use to keep their repositories up to date with the latest version of the Flask English documentation.
12
+
This post will document a simple process that the contributors and maintainers of the different language translations can use to keep their repositories up to date with the latest version of Flask’s documentation in English.
13
13
14
14
## Set up your local environment
15
15
16
-
First, fork the translation repository for the language you will be working on from the Flask CWG GitHub organization into your personal Github space. If you need, you can find more information about forking in the GitHub documentation [here](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo).
16
+
First, fork the translation repository for the language you will be working on from the Flask CWG GitHub organization into your personal GitHub space. If you need, you can find more information about forking in the GitHub documentation [here](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo).
17
17
18
-
Once the forked repository is created, clone it on your computer. If you are not familiar with this step, more details are available in the GitHub documentation [here](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository).
18
+
Once the forked repository has been created, clone it on your computer. If you are not familiar with this step, more details are available in the GitHub documentation [here](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository).
19
19
20
-
At this point you will have the latest version of the translation for the language you are working on.
20
+
At this point, you will have the latest version of the translation for the language you are working on.
21
21
22
22
## Add the main Flask repository as a new git remote
23
23
24
-
A quick note: the command outputs you will see below, show details like tags and commit hashes from the time this post was written, when you execute them, you will probably see different values.
24
+
_Quick note: The command outputs you will see below show details like tags and commit hashes from the time this post was written. When you execute them, you will probably see different values._
25
25
26
-
To access the original English documentation, you will need to set a new git remote repository pointing to the main flask repository:
26
+
To access the original English documentation, you will need to set a new git remote repository that points to the main Flask repository:
@@ -66,21 +66,21 @@ $ git checkout -b update-docs main
66
66
Switched to a new branch 'update-docs'
67
67
```
68
68
69
-
And deleting the current English documentation `.rst` files in the translation repository (this step is necessary to ensure we don't keep old files that may have been removed in the English version):
69
+
Then, delete the current English documentation .rst files in the translation repository (this step is necessary to ensure we don't keep old files that may have been removed in the English version):
70
70
71
71
```shell
72
72
$ rm -r ./docs/*.rst
73
73
```
74
74
75
-
The Flask CWG in discussion with the Flask project maintainershas decided to keep the translations synchronized with the documentation of the latest released version of Flask. To find the last version of the English documentation, locate the latest release tag:
75
+
In discussion with the Flask project maintainers, the Flask CWG has decided to keep the translations synchronized with the documentation of the latest released version of Flask. To find the most recent version of the English documentation, locate the latest release tag:
76
76
77
77
```shell
78
78
$ git tag --sort=-taggerdate | head -n 1
79
79
3.0.3
80
80
81
81
```
82
82
83
-
Once you know the right tag, you can checkout the right version of the documentation folder into your new branch:
83
+
Once you have the right tag, you can checkout the right version of the documentation folder into your new branch:
84
84
85
85
```shell
86
86
$ git checkout 3.0.3 ./docs/
@@ -116,15 +116,15 @@ git commit -m 'Updated the English documentation'
116
116
117
117
```
118
118
119
-
Next, to make sure you keep up with the documentation building requirements, also update the requirements folder.
119
+
Next, to ensure you keep up with the documentation building requirements, update the requirements folder as well.
120
120
121
121
```shell
122
122
git checkout 3.0.3 ./requirements/
123
123
Updated 0 paths from a7d387fa
124
124
125
125
```
126
126
127
-
In this case no files were updated ("Updated 0 paths"), but if the requirements change, we will need those changes as well.
127
+
In this case, no files were updated ("Updated 0 paths"). But, if the requirements change, we will need those changes as well.
128
128
129
129
## Prepare a virtual environment to build the documentation
## Recreate the translation templates (`.pot` files)
151
151
152
-
Before you can update the translation files for the language you are working on, you need to recreate the translation template files with the latest version of the documentation you just copied. This is an intermediate step and you will not be working on these files directly, they are stored in the `./_build/gettext` folder.
152
+
Before you can update the translation files for the language you are working on, you need to recreate the translation template files with the latest version of the documentation you just copied. This is an intermediate step as you will not be working on these files directly. They are stored in the `./_build/gettext` folder.
153
153
154
154
```shell
155
155
$ cd ./docs
@@ -167,7 +167,7 @@ loading intersphinx inventory from https://docs.sqlalchemy.org/objects.inv...
167
167
168
168
## Update the translation files (`.po` files)
169
169
170
-
Before we can run the next step, we need to install `sphinx-intl` in the current virtual environment. Since this is a requirement for the translation work, it is not part of the original documentation requirements:
170
+
Before we can run the next step, you need to install sphinx-intl in your current virtual environment. Since this is a requirement for the translation work, it is not part of the original documentation requirements:
171
171
172
172
```shell
173
173
$ pip install sphinx-intl
@@ -179,10 +179,11 @@ Requirement already satisfied: sphinx in /home/felipe/github/flaskcwg/flask-docs
179
179
(...)
180
180
```
181
181
182
-
Now you are ready to update the translations for the language you are working one. In the example below, we are working with the Spanish translation (language code `es`), remember to replace the language code for the one for your language:
182
+
You are now ready to update the translation for the language you are working on. In the example below, we are working with the Spanish translation (language code `es`). Remember to replace the language code for the one for your language:
@@ -196,13 +197,13 @@ At this point, the `.po` files in the `./locales` folder have been updated with
196
197
197
198
The update process will preserve the current translations and add new strings that might have been added to the English documentation.
198
199
199
-
If some of the already translated strings changed in the English documentation, the corresponding entries in the `.po` files will be marked with the tag "fuzzy", indicating they need to be checked for accuracy.
200
+
If some of the already translated strings changed in the English documentation, the corresponding entries in the .po files will be marked with the tag "fuzzy", indicating they need to be checked for accuracy.
200
201
201
202
For more information about the PO format, including the fuzzy tag, consult the [gettext documentation](https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html).
202
203
203
204
## Commit the translation files
204
205
205
-
Add the updated translation files to the branch. You do not need to worry about the `.pot` files, they don't need to be stored in the repository.
206
+
Add the updated translation files to the branch. You do not need to worry about the .pot files, they don't need to be stored in the repository.
Add this point you are ready to create a pull request to incorporate your changes into the Flask CWG language repository. You can find more information about creating a pull request in the [GitHub documentation](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request).
228
+
At this point, you are ready to create a pull request to incorporate your changes into the Flask CWG language repository. You can find more information about creating a pull request in the[GitHub documentation](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request).
0 commit comments