1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-06-09 19:07:30 +02:00

Format all PO files with dprint (#1359)

This enforces a consistent formatting for the PO files. The goal of this
is to avoid large diffs due to random and unnecessary reformatting.

We use the format of `msgcat`: this is also waht `msgmerge` produces and
it’s easy to replicate for people by installing Gettext and running
`dprint fmt`.

This is a follow-up to #1351 which started enforcing that the `msgid`
fields don’t change due to reformatting in a PR.

If this turns out to be cumbersome, then we can disable it again.
This commit is contained in:
Martin Geisler 2023-10-14 12:53:18 +02:00 committed by GitHub
parent 5fafa4842c
commit 4560ee8484
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 3302 additions and 2643 deletions

View File

@ -16,6 +16,10 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Install Gettext
run: |
sudo apt install gettext
- name: Install nightly rustfmt - name: Install nightly rustfmt
run: | run: |
rustup default nightly rustup default nightly

View File

@ -13,10 +13,9 @@ directory. The `.po` files are small text-based translation databases.
> such as [Poedit](https://poedit.net/). There are also several online editors > such as [Poedit](https://poedit.net/). There are also several online editors
> available. This will ensure that the file is encoded correctly. > available. This will ensure that the file is encoded correctly.
> **Important:** If you are planning to use [Poedit](https://poedit.net/) as > **Important:** You need to run `dprint fmt` after editing the PO file. This
> suggested above, make sure to follow the > ensures consistent formatting of the file. You need to install the Gettext
> [additional configuration steps](#Additional-Configuration-for-Poedit) below > tools for this, see the Preparation section below.
> to ensure the `.po` file is correctly formatted.
There is a `.po` file for each language. They are named after the [ISO 639] There is a `.po` file for each language. They are named after the [ISO 639]
language codes: Danish would go into `po/da.po`, Korean would go into language codes: Danish would go into `po/da.po`, Korean would go into
@ -32,13 +31,17 @@ GNU Gettext utilities below.
## Preparation ## Preparation
You will need the [Gettext] utilities (`msginit`, `msgmerge`). Under Debian and You will need the [Gettext] utilities (`msginit`, `msgmerge`) and [`dprint`].
Ubuntu, you can install with: Under Debian and Ubuntu, you can install Gettext with:
```shell ```shell
sudo apt install gettext sudo apt install gettext
``` ```
Install `dprint` using their installation instructions.
[dprint]: https://dprint.dev/
Ensure you can build the book, and that `mdbook serve` works. For this, follow Ensure you can build the book, and that `mdbook serve` works. For this, follow
the instructions in the [README](README.md). the instructions in the [README](README.md).
@ -46,11 +49,10 @@ the instructions in the [README](README.md).
First, you need to know how to update the `.pot` and `.po` files. First, you need to know how to update the `.pot` and `.po` files.
As a general rule, you should never touch the auto-generated `po/messages.pot` You should never touch the auto-generated `po/messages.pot` file. You should
file. You should also not edit the `msgid` entries in a `po/xx.po` file. If you also not never the `msgid` entries in a `po/xx.po` file. If you find mistakes,
find mistakes, you need to update the original English text instead. The fixes you need to update the original English text instead. The fixes to the English
to the English text will flow into the `.po` files the next time the translators text will flow into the `.po` files the next time the translators update them.
update them.
> **Tip:** See our [style guide](STYLE.md) for some things to keep in mind when > **Tip:** See our [style guide](STYLE.md) for some things to keep in mind when
> writing the translation. > writing the translation.
@ -134,20 +136,15 @@ will take care of escaping things like `"` correctly.
There are many PO editors available. [Poedit](https://poedit.net/) is a popular There are many PO editors available. [Poedit](https://poedit.net/) is a popular
cross-platform choice, but you can also find several online editors. cross-platform choice, but you can also find several online editors.
#### Additional Configuration for Poedit If the file is not formatted correct, you will get an error on the PR. Install
[Gettext] and [`dprint`](https://dprint.dev/) and then run
If you are using [Poedit](https://poedit.net/) to work with your `.po` file, you ```shell
will need to change a few things from their default configuration: dprint fmt
```
1. Open the **Settings** dialog This will automatically format the files for you. Commit the formatting fix and
1. On Windows, go to **File / Settings** push to your branch. Your PR should now be error free.
1. On MacOS, select **Settings** from the **Poedit** menu item
1. Go to the **Advanced** tab
1. On **Line endings**, select the option **Unix (recommended)**
1. Check the **Wrap at** box, and **79** on the textbox
1. _**Uncheck**_ the **Preserve formatting of existing files** box
![Poedit Screenshot](poedit-screenshot.png)
## Using Translations ## Using Translations

View File

@ -8,6 +8,9 @@
"commands": [{ "commands": [{
"command": "rustfmt --edition 2021", "command": "rustfmt --edition 2021",
"exts": ["rs"] "exts": ["rs"]
}, {
"command": "msgcat -",
"exts": ["po"]
}] }]
}, },
"excludes": [ "excludes": [

5844
po/bn.po

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n" "Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: 2023-09-17\n" "POT-Creation-Date: 2023-09-18\n"
"PO-Revision-Date: 2023-09-12 14:14-0400\n" "PO-Revision-Date: 2023-09-12 14:14-0400\n"
"Last-Translator: Olivier Charrez <olivier.charrez@hotmail.com>\n" "Last-Translator: Olivier Charrez <olivier.charrez@hotmail.com>\n"
"Language-Team: French <traduc@traduc.org>\n" "Language-Team: French <traduc@traduc.org>\n"
@ -2534,8 +2534,8 @@ msgstr ""
"Expérience avec C ou C++ : Rust élimine toute une classe d'_erreurs " "Expérience avec C ou C++ : Rust élimine toute une classe d'_erreurs "
"d'exécution_ via le vérificateur d'emprunt. On obtient des performances " "d'exécution_ via le vérificateur d'emprunt. On obtient des performances "
"comme en C et C++, mais sans problèmes d'insécurité de la mémoire. De plus, " "comme en C et C++, mais sans problèmes d'insécurité de la mémoire. De plus, "
"Rust est un langage moderne avec des constructions telles que le " "Rust est un langage moderne avec des constructions telles que le filtrage "
"filtrage par motif et la gestion intégrée des dépendances." "par motif et la gestion intégrée des dépendances."
#: src/why-rust.md:19 #: src/why-rust.md:19
msgid "" msgid ""
@ -2787,9 +2787,9 @@ msgid ""
"and Go. Rust does not come with several things you might consider standard " "and Go. Rust does not come with several things you might consider standard "
"and essential:" "and essential:"
msgstr "" msgstr ""
"La bibliothèque standard de Rust est petite comparée à des langages comme Java, " "La bibliothèque standard de Rust est petite comparée à des langages comme "
"Python, et Go. Rust n'est pas distribué avec certains éléments que vous " "Java, Python, et Go. Rust n'est pas distribué avec certains éléments que "
"pourriez considérer comme standard et essentiel:" "vous pourriez considérer comme standard et essentiel:"
#: src/why-rust/modern.md:41 #: src/why-rust/modern.md:41
#, fuzzy #, fuzzy
@ -5362,8 +5362,8 @@ msgid ""
"See [pattern matching](../pattern-matching.md) for more details on patterns " "See [pattern matching](../pattern-matching.md) for more details on patterns "
"in Rust." "in Rust."
msgstr "" msgstr ""
"Voir [Filtrage par motif](../pattern-matching.md) pour plus de détails sur les " "Voir [Filtrage par motif](../pattern-matching.md) pour plus de détails sur "
"motifs avec Rust." "les motifs avec Rust."
#: src/control-flow/if-let-expressions.md:23 #: src/control-flow/if-let-expressions.md:23
msgid "" msgid ""
@ -5540,8 +5540,8 @@ msgstr ""
msgid "" msgid ""
"We can now use pattern matching to match against the `&str` inside `Option`." "We can now use pattern matching to match against the `&str` inside `Option`."
msgstr "" msgstr ""
"Nous pouvons maintenant utiliser le filtrage par motif pour faire correspondre " "Nous pouvons maintenant utiliser le filtrage par motif pour faire "
"le `&str` à l'intérieur de `Option`." "correspondre le `&str` à l'intérieur de `Option`."
#: src/pattern-matching.md:3 #: src/pattern-matching.md:3
#, fuzzy #, fuzzy
@ -13055,8 +13055,8 @@ msgid ""
"that parses some raw bytes would be ideal." "that parses some raw bytes would be ideal."
msgstr "" msgstr ""
"Nous allons essayer d'appeler Rust depuis l'un de vos propres projets " "Nous allons essayer d'appeler Rust depuis l'un de vos propres projets "
"aujourd'hui. Alors essayez de trouver un petit coin de votre code où " "aujourd'hui. Alors essayez de trouver un petit coin de votre code où nous "
"nous pouvons déplacer quelques lignes de code vers Rust. Le moins il y a de " "pouvons déplacer quelques lignes de code vers Rust. Le moins il y a de "
"dépendances et de types \"exotiques\", le mieux c'est. Quelque chose qui " "dépendances et de types \"exotiques\", le mieux c'est. Quelque chose qui "
"analyse quelques octets de donnée brute serait idéal." "analyse quelques octets de donnée brute serait idéal."
@ -21700,8 +21700,8 @@ msgid ""
"(FFI)." "(FFI)."
msgstr "" msgstr ""
"[The Rustonomicon](https://doc.rust-lang.org/nomicon/) : couvre le Rust non " "[The Rustonomicon](https://doc.rust-lang.org/nomicon/) : couvre le Rust non "
"securisé (_unsafe_), y compris les pointeurs nus et l'interfaçage " "securisé (_unsafe_), y compris les pointeurs nus et l'interfaçage avec "
"avec d'autres langages (FFI)." "d'autres langages (FFI)."
#: src/other-resources.md:27 #: src/other-resources.md:27
msgid "" msgid ""
@ -21749,9 +21749,9 @@ msgid ""
"rust_for_c/): covers Rust from the perspective of developers who write " "rust_for_c/): covers Rust from the perspective of developers who write "
"firmware in C." "firmware in C."
msgstr "" msgstr ""
"\\[Rust pour Programmeurs C Embarqué\\] (https://docs.opentitan.org/doc/" "\\[Rust pour Programmeurs C Embarqué\\] (https://docs.opentitan.org/doc/ug/"
"ug/rust_for_c/) : couvre Rust du point de vue des développeurs qui " "rust_for_c/) : couvre Rust du point de vue des développeurs qui écrivent des "
"écrivent des firmwares en C." "firmwares en C."
#: src/other-resources.md:42 #: src/other-resources.md:42
#, fuzzy #, fuzzy
@ -21783,8 +21783,8 @@ msgid ""
msgstr "" msgstr ""
"\\[Matériel de Ferrous Teaching\\] (https://ferrous-systems.github.io/" "\\[Matériel de Ferrous Teaching\\] (https://ferrous-systems.github.io/"
"teaching-material/index.html) : un série de petites présentations couvrant à " "teaching-material/index.html) : un série de petites présentations couvrant à "
"la fois la partie de base et avancée de Rust. D'autres " "la fois la partie de base et avancée de Rust. D'autres sujets tels que "
"sujets tels que WebAssembly et async/wait sont également couvert." "WebAssembly et async/wait sont également couvert."
#: src/other-resources.md:52 #: src/other-resources.md:52
#, fuzzy #, fuzzy
@ -21874,8 +21874,8 @@ msgid ""
msgstr "" msgstr ""
"Certains exercices ont été copiés et adaptés de \\[Rust on Exercism\\] " "Certains exercices ont été copiés et adaptés de \\[Rust on Exercism\\] "
"(https://exercism.org/tracks/rust). Veuillez consulter le Répertoire " "(https://exercism.org/tracks/rust). Veuillez consulter le Répertoire "
"`third_party/rust-on-exercism/` pour plus de détails, y compris les conditions " "`third_party/rust-on-exercism/` pour plus de détails, y compris les "
" de la licence." "conditions de la licence."
#: src/credits.md:26 #: src/credits.md:26
#, fuzzy #, fuzzy

View File

@ -1,7 +1,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n" "Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: 2023-09-08\n" "POT-Creation-Date: 2023-09-09\n"
"PO-Revision-Date: 2023-08-25 14:28-0700\n" "PO-Revision-Date: 2023-08-25 14:28-0700\n"
"Last-Translator: Yauheni Baltukha <evgenii.boltuho@gmail.com>\n" "Last-Translator: Yauheni Baltukha <evgenii.boltuho@gmail.com>\n"
"Language-Team: \n" "Language-Team: \n"
@ -4304,7 +4304,8 @@ msgstr "Здесь также можно использовать выражен
#: src/control-flow/for-expressions.md:25 #: src/control-flow/for-expressions.md:25
msgid "Index iteration is not a special syntax in Rust for just that case." msgid "Index iteration is not a special syntax in Rust for just that case."
msgstr "" msgstr ""
"В языке Rust нет специального синтаксиса для итерации по индексам контейнеров." "В языке Rust нет специального синтаксиса для итерации по индексам "
"контейнеров."
#: src/control-flow/for-expressions.md:26 #: src/control-flow/for-expressions.md:26
msgid "`(0..10)` is a range that implements an `Iterator` trait. " msgid "`(0..10)` is a range that implements an `Iterator` trait. "
@ -5338,8 +5339,8 @@ msgid ""
"it will return `None`. The `while let` lets us keep iterating through all " "it will return `None`. The `while let` lets us keep iterating through all "
"items." "items."
msgstr "" msgstr ""
"Здесь `next()`-итератор, возвращённый выражением `v.into_iter()`, " "Здесь `next()`-итератор, возвращённый выражением `v.into_iter()`, возвращает "
"возвращает объект типа `Option<i32>`.\n" "объект типа `Option<i32>`.\n"
"Сначала будет возращаться `Some(x)` для каждого элемента вектора,\n" "Сначала будет возращаться `Some(x)` для каждого элемента вектора,\n"
"после чего `next()` вернёт `None`. Выражение `while let` позволяет нам " "после чего `next()` вернёт `None`. Выражение `while let` позволяет нам "
"лаконично\n" "лаконично\n"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB