This repository documents a proposal to support internationalisation of R help pages.
This project started at the 2023 R Project Sprint. More in this issue.
For users
Install this package:
pak::pak("eliocamp/rhelpi18n")
Next install a translation module. The base.es package hosts translations for base::mean()
as an example, install it with
pak::pak("eliocamp/base.es")
Setting the LANGAUGE environmental variable to “es” will change your R language.
library(rhelpi18n)
Sys.setenv(LANGUAGE = "es")
Now base::mean()
’s help page will be displayed in Spanish.
This will work with the HTML documentation displayed by R GUIs like RStudio, as well as with text documentation displayed by R in the console.
For package developers
First get a copy of the package you want to translate.
Choose your translation language by its ISO 2-letter code eventually with a regional option using underscore:
or example Spanish would be language = "es"
, and Argentine Spanish would be language = "es_AR"
.
Then use rhelpi18n::i18n_module_create()
to create a lang translation module for that package
rhelpi18n::i18n_module_create(module_name = "package.lang",
language = "lang",
module_path = "path/to/module",
package_path = "path/to/package")
The translation string are saved into yaml files, one per Rd file of the original package.
You can find them in “path/to/module/translations” with this format:
You can distribute them to your package translators.
After translation, replace the completed yaml files in the same folder.
Build the package and test.
That’s it.
For package translators
In the received yaml files, replace the ~
in each translation
field by the translation of the original
field, like in the exemple:
Problems
- It’s not clear that the page is a translation and not the “official” one.
- It’s not possible to access the original documentation without changing the LANGUAGE environmental variable and opening the help page again.
- There are some formatting issues, such as the
...
argument name.