I made a small mistake during the refactor in #1492: I removed the
`MDBOOK_BOOK__LANGUAGE` environment variable, which means that we ended
up testing the original Rust code snippets again and again.
This commit also fixes the few typos that have sneaked into the
translations due to the lack of testing.
This PR merges the pt-BR v.2 translation back to main.
Also, it refreshes the .po file format removing the line numbers.
This requires just a syntactical review, as the partial PRs into this
branch were reviewed already.
You can skim this PR with the [GitHub CLI](https://cli.github.com/):
gh pr diff 1846 | bat -l patch
#317#1463
---------
Co-authored-by: João Victor Mendes <mendesjoaovic@gmail.com>
Co-authored-by: azevedoalice <158203674+azevedoalice@users.noreply.github.com>
Before we would run `mdbook test` using the current Markdown sources.
This is subtly wrong: we publish the course using back-dated sources,
so we should therefore also run the tests using the same sources (this
ensures that the code snippets actually work).
After this commit, all translatable content lives in exactly two
directories:
- `src/`
- `third_party/`
We need to restore both directories when testing and when publishing.
This ensures consistency in the Markdown text and in the included
source code.
A new `.github/workflows/build.sh` script takes care of preparing the
two directories according to the date in the PO file (if any).
To ensure we can restore all of `third_party/` to an old commit, the
non-changing `third_party/mdbook/book.js` file has been moved to
`theme/book.js`. The file is generated by `mdbook init --theme`,
making it suitable for modification by the user (us). Symlinks have
been added to `third_party/mdbook/` to indicate that the files
ultimately came from upstream.
This is the result of running `dprint fmt` after removing `src/` from
the list of excluded directories.
This also reformats the Rust code: we might want to tweak this a bit in
the future since some of the changes removes the hand-formatting. Of
course, this formatting can be seen as a mis-feature, so maybe this is
good overall.
Thanks to mdbook-i18n-helpers 0.2, the POT file is nearly unchanged
after this, meaning that all existing translations remain valid! A few
messages were changed because of stray whitespace characters:
msgid ""
"Slices always borrow from another object. In this example, `a` has to remain "
-"'alive' (in scope) for at least as long as our slice. "
+"'alive' (in scope) for at least as long as our slice."
msgstr ""
The formatting is enforced in CI and we will have to see how annoying
this is in practice for the many contributors. If it becomes annoying,
we should look into fixing dprint/check#11 so that `dprint` can annotate
the lines that need fixing directly, then I think we can consider more
strict formatting checks.
I added more customization to `rustfmt.toml`. This is to better emulate
the dense style used in the course:
- `max_width = 85` allows lines to take up the full width available in
our code blocks (when taking margins and the line numbers into account).
- `wrap_comments = true` ensures that we don't show very long comments
in the code examples. I edited some comments to shorten them and avoid
unnecessary line breaks — please trim other unnecessarily long comments
when you see them! Remember we're writing code for slides 😄
- `use_small_heuristics = "Max"` allows for things like struct literals
and if-statements to take up the full line width configured above.
The formatting settings apply to all our Rust code right now — I think
we could improve this with https://github.com/dprint/dprint/issues/711
which lets us add per-directory `dprint` configuration files. However,
the `inherit: true` setting is not yet implemented (as far as I can
tell), so a nested configuration file will have to copy most or all of
the top-level file.
With #1460 merged, we took away the possibility of translating variable,
struct, and function names in the code snippets.
This broke the Brazilian Portuguese translation because it _does_
translate those things quite frequently! This PR reverts the
translations back to the English original.
I tried to also update the surrounding messages to use the English
words: so when a slide talked about a `nome` variable before, it now
uses `name` instead. We don’t have automated tests for this, so I hope I
did this correctly.
This updates each PO file to the date when it was last touched:
for po_file in po/*.po; do
POT_DATE=$(git log -1 --date=short --format=%ad $po_file)
sed -i -e 's/"POT-Creation-Date:.*"/"POT-Creation-Date:
'$POT_DATE'\\n"/' $po_file
done
The dates will be updated with `msgmerge` in the future via
https://github.com/google/mdbook-i18n-helpers/pull/87.
The dates here can be adjusted by hand if needed — the starting point
here only serves as a rough anchor to let us freeze the translations
from further updates. So if you know that you ran `msgmerge` most
recently on a given date, please update the file to that date in a later
PR.
Refresing Brazilian Portuguese translation via msgmerge with new version
of mdbook-i18n-helpers and agreed Poedit settings. Issue #317, keeping
pace with #1104.
Before, po/pt-BR.po had these statistics:
1272 translated messages, 93 fuzzy translations, 416 untranslated
messages.
Afterwards, the statistics for po/pt-BR.po is:
1703 translated messages, 114 fuzzy translations, 650 untranslated
messages.
The number of translated messages changed from 71% to 69%.
With this change, it becomes important to use the latest version of
mdbook-i18n-helpers when viewing the translation locally. To update to
the latest version, run
cargo install mdbook-i18n-helpers
You will now be able to serve the translation locally.
Part of #330.
* Added steps to configure Poedit properly
* Small adjustments
* Add link to Poedit
* Fix file formatting
* One. More. dprint. Fix.
* Normalizes pt-BR.po file format through Poedit
with line wrap.
* Fix typo.
* Fix fuzzy entries after .po file reformatting.
* Fix one code sample
* Added steps to configure Poedit properly
* Small adjustments
* Add link to Poedit
* Fix file formatting
* One. More. dprint. Fix.
* Normalizes pt-BR.po file format through Poedit
with line wrap.
* Fix typo.
* Completing and improving pt-BR translation for
chapter 1.
* Small typo fix.
* Some other fixes.
* pt-BR: Updates/completes translations for ch 1-6
* Fix missing '\n'
Review of the translation for pt-BR.
Some terms cannot be translated.
Other terms have no translation and have been adapted.
Code examples have been translated, where possible, for ease of understanding.
* Parse Markdown to support translation.
This upgrades from just splitting Markdown files on double-newlines, to
using a Markdown parser to break them into more appropriate chunks. The
upshot is that code samples are all in one message, lists are bundled
together, and generally it should be easier to translate.
* [WIP] helper to update po files for new translation
* process synthetic input file-by-file
* review comments
* remove temporary code
* fix msgfmt lints
* More polishing on the pt-BR translation
* Fix translation to make code compile
This was tested with `mdbook test` from
https://github.com/rust-lang/mdBook/pull/1986.
---------
Co-authored-by: Martin Geisler <mgeisler@google.com>
* pt-BR.po: fine tuning for slide #1
* pt-BR.po: orador -> instrutor
Orador is a person who speaks to the public while instrutor is literally a trainer.
* Adds latest English changes to pt-BR translation
Updating latest changes in English version to pt-BR.po file using the `msgmerge --update po/pt-BR.po po/messages.pot` command.
* Removes all `fuzzy`
Removing all `#, fuzzy` lines so the translation can be live.