1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2024-12-13 21:55:20 +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
uses: actions/checkout@v3
- name: Install Gettext
run: |
sudo apt install gettext
- name: Install nightly rustfmt
run: |
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
> available. This will ensure that the file is encoded correctly.
> **Important:** If you are planning to use [Poedit](https://poedit.net/) as
> suggested above, make sure to follow the
> [additional configuration steps](#Additional-Configuration-for-Poedit) below
> to ensure the `.po` file is correctly formatted.
> **Important:** You need to run `dprint fmt` after editing the PO file. This
> ensures consistent formatting of the file. You need to install the Gettext
> tools for this, see the Preparation section below.
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
@ -32,13 +31,17 @@ GNU Gettext utilities below.
## Preparation
You will need the [Gettext] utilities (`msginit`, `msgmerge`). Under Debian and
Ubuntu, you can install with:
You will need the [Gettext] utilities (`msginit`, `msgmerge`) and [`dprint`].
Under Debian and Ubuntu, you can install Gettext with:
```shell
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
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.
As a general rule, you should never touch the auto-generated `po/messages.pot`
file. You should also not edit the `msgid` entries in a `po/xx.po` file. If you
find mistakes, you need to update the original English text instead. The fixes
to the English text will flow into the `.po` files the next time the translators
update them.
You should never touch the auto-generated `po/messages.pot` file. You should
also not never the `msgid` entries in a `po/xx.po` file. If you find mistakes,
you need to update the original English text instead. The fixes to the English
text will flow into the `.po` files the next time the translators update them.
> **Tip:** See our [style guide](STYLE.md) for some things to keep in mind when
> 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
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
will need to change a few things from their default configuration:
```shell
dprint fmt
```
1. Open the **Settings** dialog
1. On Windows, go to **File / Settings**
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)
This will automatically format the files for you. Commit the formatting fix and
push to your branch. Your PR should now be error free.
## Using Translations

View File

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

5844
po/bn.po

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"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"
"Last-Translator: Olivier Charrez <olivier.charrez@hotmail.com>\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 "
"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, "
"Rust est un langage moderne avec des constructions telles que le "
"filtrage par motif et la gestion intégrée des dépendances."
"Rust est un langage moderne avec des constructions telles que le filtrage "
"par motif et la gestion intégrée des dépendances."
#: src/why-rust.md:19
msgid ""
@ -2787,9 +2787,9 @@ msgid ""
"and Go. Rust does not come with several things you might consider standard "
"and essential:"
msgstr ""
"La bibliothèque standard de Rust est petite comparée à des langages comme Java, "
"Python, et Go. Rust n'est pas distribué avec certains éléments que vous "
"pourriez considérer comme standard et essentiel:"
"La bibliothèque standard de Rust est petite comparée à des langages comme "
"Java, Python, et Go. Rust n'est pas distribué avec certains éléments que "
"vous pourriez considérer comme standard et essentiel:"
#: src/why-rust/modern.md:41
#, fuzzy
@ -5362,8 +5362,8 @@ msgid ""
"See [pattern matching](../pattern-matching.md) for more details on patterns "
"in Rust."
msgstr ""
"Voir [Filtrage par motif](../pattern-matching.md) pour plus de détails sur les "
"motifs avec Rust."
"Voir [Filtrage par motif](../pattern-matching.md) pour plus de détails sur "
"les motifs avec Rust."
#: src/control-flow/if-let-expressions.md:23
msgid ""
@ -5540,8 +5540,8 @@ msgstr ""
msgid ""
"We can now use pattern matching to match against the `&str` inside `Option`."
msgstr ""
"Nous pouvons maintenant utiliser le filtrage par motif pour faire correspondre "
"le `&str` à l'intérieur de `Option`."
"Nous pouvons maintenant utiliser le filtrage par motif pour faire "
"correspondre le `&str` à l'intérieur de `Option`."
#: src/pattern-matching.md:3
#, fuzzy
@ -13055,8 +13055,8 @@ msgid ""
"that parses some raw bytes would be ideal."
msgstr ""
"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ù "
"nous pouvons déplacer quelques lignes de code vers Rust. Le moins il y a de "
"aujourd'hui. Alors essayez de trouver un petit coin de votre code où nous "
"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 "
"analyse quelques octets de donnée brute serait idéal."
@ -21700,8 +21700,8 @@ msgid ""
"(FFI)."
msgstr ""
"[The Rustonomicon](https://doc.rust-lang.org/nomicon/) : couvre le Rust non "
"securisé (_unsafe_), y compris les pointeurs nus et l'interfaçage "
"avec d'autres langages (FFI)."
"securisé (_unsafe_), y compris les pointeurs nus et l'interfaçage avec "
"d'autres langages (FFI)."
#: src/other-resources.md:27
msgid ""
@ -21749,9 +21749,9 @@ msgid ""
"rust_for_c/): covers Rust from the perspective of developers who write "
"firmware in C."
msgstr ""
"\\[Rust pour Programmeurs C Embarqué\\] (https://docs.opentitan.org/doc/"
"ug/rust_for_c/) : couvre Rust du point de vue des développeurs qui "
"écrivent des firmwares en C."
"\\[Rust pour Programmeurs C Embarqué\\] (https://docs.opentitan.org/doc/ug/"
"rust_for_c/) : couvre Rust du point de vue des développeurs qui écrivent des "
"firmwares en C."
#: src/other-resources.md:42
#, fuzzy
@ -21783,8 +21783,8 @@ msgid ""
msgstr ""
"\\[Matériel de Ferrous Teaching\\] (https://ferrous-systems.github.io/"
"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 "
"sujets tels que WebAssembly et async/wait sont également couvert."
"la fois la partie de base et avancée de Rust. D'autres sujets tels que "
"WebAssembly et async/wait sont également couvert."
#: src/other-resources.md:52
#, fuzzy
@ -21874,8 +21874,8 @@ msgid ""
msgstr ""
"Certains exercices ont été copiés et adaptés de \\[Rust on Exercism\\] "
"(https://exercism.org/tracks/rust). Veuillez consulter le Répertoire "
"`third_party/rust-on-exercism/` pour plus de détails, y compris les conditions "
" de la licence."
"`third_party/rust-on-exercism/` pour plus de détails, y compris les "
"conditions de la licence."
#: src/credits.md:26
#, fuzzy

View File

@ -1,7 +1,7 @@
msgid ""
msgstr ""
"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"
"Last-Translator: Yauheni Baltukha <evgenii.boltuho@gmail.com>\n"
"Language-Team: \n"
@ -4304,7 +4304,8 @@ msgstr "Здесь также можно использовать выражен
#: src/control-flow/for-expressions.md:25
msgid "Index iteration is not a special syntax in Rust for just that case."
msgstr ""
"В языке Rust нет специального синтаксиса для итерации по индексам контейнеров."
"В языке Rust нет специального синтаксиса для итерации по индексам "
"контейнеров."
#: src/control-flow/for-expressions.md:26
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 "
"items."
msgstr ""
"Здесь `next()`-итератор, возвращённый выражением `v.into_iter()`, "
"возвращает объект типа `Option<i32>`.\n"
"Здесь `next()`-итератор, возвращённый выражением `v.into_iter()`, возвращает "
"объект типа `Option<i32>`.\n"
"Сначала будет возращаться `Some(x)` для каждого элемента вектора,\n"
"после чего `next()` вернёт `None`. Выражение `while let` позволяет нам "
"лаконично\n"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB