Skip to content

Commit 5c4ca8b

Browse files
Deploying to gh-pages from @ e51b0e8 🚀
1 parent cd5831a commit 5c4ca8b

7 files changed

Lines changed: 112 additions & 29 deletions

File tree

articles/custom-diagnostic.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

articles/developers.html

Lines changed: 53 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

articles/developers.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ message("This", " is", " a", " message")
7575
warning("This", " is", " a", " warning")
7676
#> Warning: This is a warning
7777
stop("This", " is", " an", " error")
78-
#> Error: This is an error
78+
#> Error:
79+
#> ! This is an error
7980
```
8081

8182
However, as you’ll learn shortly, this style is unlikely to generate
@@ -148,6 +149,50 @@ translatable
148149
strings](https://www.gnu.org/software/gettext/manual/html_node/Preparing-Strings.html#Preparing-Strings%20(Inspired%20by%20from%20))
149150
section of the gettext[²](#fn2) manual.
150151

152+
One important point is to avoid templating out sentence fragments,
153+
especially words. Put message pieces into a template if and only if they
154+
are untranslatable (e.g., proper nouns, function names/R code).
155+
156+
For example, it is bad practice to conditionally template a word or
157+
phrase into a message:
158+
159+
``` r
160+
# BAD
161+
in_parallel <- TRUE
162+
run_type <- if (in_parallel) "in parallel" else "sequentially"
163+
sprintf(tr_("Running job %s."), run_type)
164+
#> [1] "Running job in parallel."
165+
```
166+
167+
The translator only sees `"Running job %s."`, and cannot adapt the
168+
translation for the two cases. It’s much better to use two different,
169+
complete messages:
170+
171+
``` r
172+
# GOOD
173+
in_parallel <- TRUE
174+
if (in_parallel) {
175+
tr_("Running job in parallel.")
176+
} else {
177+
tr_("Running job sequentially.")
178+
}
179+
#> [1] "Running job in parallel."
180+
```
181+
182+
This gives the translator full context. Why is this important? Because
183+
different words can require entirely different sentence structures in
184+
other languages. For example, in Polish, “to run \[a job\] sequentially”
185+
can be expressed with a specific verb, `szeregować`. A natural
186+
translation of “Running job sequentially.” might be “Szeregowanie
187+
zadania.”. For “Running job in parallel.”, one would likely use a
188+
different verb and structure, like “Uruchamianie zadania równolegle.”.
189+
190+
The template in the “BAD” example is too rigid. It forces the translator
191+
to find a single translation for “Running job %s.” that works with both
192+
“sequentially” and “in parallel”, which is unnatural and may not even be
193+
possible. The “GOOD” example, by providing two distinct sentences,
194+
allows the translator to pick the most idiomatic phrasing for each case.
195+
151196
### Write full sentences
152197

153198
Generally, you should strive to make sure that each message comes from a

pkgdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ articles:
55
custom-diagnostic: custom-diagnostic.html
66
developers: developers.html
77
translators: translators.html
8-
last_built: 2025-12-20T06:04Z
8+
last_built: 2025-12-26T20:39Z
99
urls:
1010
reference: https://michaelchirico.github.io/potools/reference
1111
article: https://michaelchirico.github.io/potools/articles

reference/write_po_file.html

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

reference/write_po_file.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ print(metadata)
278278
#> msgstr ""
279279
#> "Project-Id-Version: potoolsExample 0.0.1\n"
280280
#> "Report-Msgid-Bugs-To: https://github.com/ruser/potoolsExample/issues\n"
281-
#> "POT-Creation-Date: 2025-12-20 06:04+0000\n"
282-
#> "PO-Revision-Date: 2025-12-20 06:04+0000\n"
281+
#> "POT-Creation-Date: 2025-12-26 20:39+0000\n"
282+
#> "PO-Revision-Date: 2025-12-26 20:39+0000\n"
283283
#> "Last-Translator: R User <ruser@gmail.com>\n"
284284
#> "Language-Team: ar_SY\n"
285285
#> "Language: ar_SY\n"
@@ -298,8 +298,8 @@ writeLines(readLines(tmp_po))
298298
#> msgstr ""
299299
#> "Project-Id-Version: potoolsExample 0.0.1\n"
300300
#> "Report-Msgid-Bugs-To: https://github.com/ruser/potoolsExample/issues\n"
301-
#> "POT-Creation-Date: 2025-12-20 06:04+0000\n"
302-
#> "PO-Revision-Date: 2025-12-20 06:04+0000\n"
301+
#> "POT-Creation-Date: 2025-12-26 20:39+0000\n"
302+
#> "PO-Revision-Date: 2025-12-26 20:39+0000\n"
303303
#> "Last-Translator: R User <ruser@gmail.com>\n"
304304
#> "Language-Team: ar_SY\n"
305305
#> "Language: ar_SY\n"
@@ -327,7 +327,7 @@ writeLines(readLines(tmp_pot))
327327
#> msgstr ""
328328
#> "Project-Id-Version: potoolsExample 0.0.1\n"
329329
#> "Report-Msgid-Bugs-To: https://github.com/ruser/potoolsExample/issues\n"
330-
#> "POT-Creation-Date: 2025-12-20 06:04+0000\n"
330+
#> "POT-Creation-Date: 2025-12-26 20:39+0000\n"
331331
#> "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
332332
#> "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
333333
#> "Language-Team: LANGUAGE <LL@li.org>\n"

search.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)