-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement l10n strategy #205
Comments
a little update on this, it appears that Quarto has reinvented the wheel for their strategy, so when we port to them, we will need to adapt: https://quarto.org/docs/authoring/language.html At the moment, pkdown's answer is still the most comprehensive... addressing both generated and static translations. |
Regarding the implementation in pkgdown, the strategy is to use the gettext standard in R, which uses the tr_ <- function(...) {
enc2utf8(gettext(..., domain = "R-pkgdown"))
} (Note that this only translates singular phrases. In the {pkdown} workflow, all of the templated content is provisioned in a large list that is passed between pkgdown functions. The translations are implemented early on in the creation of this data: # Language and translations
out$lang <- pkg$lang
out$translate <- list(
skip = tr_("Skip to contents"),
toggle_nav = tr_("Toggle navigation"),
search_for = tr_("Search for"),
on_this_page = tr_("On this page"),
source = tr_("Source"),
abstract = tr_("Abstract"),
authors = tr_("Authors"),
version = tr_("Version"),
examples = tr_("Examples"),
citation = tr_("Citation")
) These variables are compiled to the pkgdown yaml and then passed to the mustache templates. I was wondering: if The answer is the LANGUAGE environment variable is set locally before computation: local_envvar_pkgdown <- function(pkg, scope = parent.frame()) {
withr::local_envvar(
IN_PKGDOWN = "true",
LANGUAGE = pkg$lang,
.local_envir = scope
)
} Note this uses {withr} to ensure the environment variable is set in the right scope. This gets called in a function called Resources |
One challenge that I currently face is that all of the site elements are embedded in mustache templates such as
here and in several places in varnish. In order to implement this, I will either have to do one of two things:
|
This is a first step towards addressing #205, but there is still a lot more work that needs to go into it. Because I'm pretty sure the tests will not pass, I'm going to skip the continuous integration for now. [skip ci]
Thanks to the work of @joelnitta in #546 this can now be closed |
This has been split from #18
As {pkgdown} is moving towards their own implementation of l10n (localisation), we need to think about how this will work practically.
At the moment, they are in the process of fixing the issue via R's internal system for l10n, which involves
.po
files r-lib/pkgdown#1446 (comment)I think for l10n, this is largely the way to go because every other blog does something slightly different and we want to be able to use an already existing system instead of reinventing the wheel.
The text was updated successfully, but these errors were encountered: