From c8eb768c7e6a35a1bea51157a150cc7b5836980b Mon Sep 17 00:00:00 2001 From: olivroy Date: Thu, 9 May 2024 08:01:02 -0400 Subject: [PATCH 1/4] Set language to english --- NEWS.md | 2 +- R/rd-eval.R | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 2d1ac342..adbd3eb3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # roxygen2 (development version) -* `@includeRmd` now additionally sets `options(cli.hyperlink = FALSE)` to make +* `@includeRmd` now additionally sets `options(cli.hyperlink = FALSE)` and language = English to make code run in included `.Rmd`s even more consistent across sessions (#1620). # roxygen2 7.3.1 diff --git a/R/rd-eval.R b/R/rd-eval.R index c902df3b..a333fac6 100644 --- a/R/rd-eval.R +++ b/R/rd-eval.R @@ -23,5 +23,9 @@ local_reproducible_output <- function(.envir = parent.frame()) { .local_envir = .envir ) withr::local_envvar(RSTUDIO = NA, .local_envir = .envir) + if (isTRUE(capabilities("NLS")) && Sys.getenv("LANG") != + "C") { + withr::local_language("en", .local_envir = .envir) + } withr::local_collate("C", .local_envir = .envir) } From 8e4fbf4f3e09fb4775000a47456a2f5717df7297 Mon Sep 17 00:00:00 2001 From: olivroy <52606734+olivroy@users.noreply.github.com> Date: Tue, 9 Jul 2024 10:53:39 -0400 Subject: [PATCH 2/4] Use language in DESCRIPTION --- R/rd-eval.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/rd-eval.R b/R/rd-eval.R index a333fac6..e13cd6c5 100644 --- a/R/rd-eval.R +++ b/R/rd-eval.R @@ -25,7 +25,8 @@ local_reproducible_output <- function(.envir = parent.frame()) { withr::local_envvar(RSTUDIO = NA, .local_envir = .envir) if (isTRUE(capabilities("NLS")) && Sys.getenv("LANG") != "C") { - withr::local_language("en", .local_envir = .envir) + lang <- unname(desc::desc_get("Language")) %|% "en" + withr::local_language(lang, .local_envir = .envir) } withr::local_collate("C", .local_envir = .envir) } From 0c16adc6658f81b9066d0f68b8253c7a2e966bc4 Mon Sep 17 00:00:00 2001 From: olivroy <52606734+olivroy@users.noreply.github.com> Date: Tue, 9 Jul 2024 11:01:23 -0400 Subject: [PATCH 3/4] style --- R/rd-eval.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/R/rd-eval.R b/R/rd-eval.R index e13cd6c5..c09ee1ec 100644 --- a/R/rd-eval.R +++ b/R/rd-eval.R @@ -23,10 +23,11 @@ local_reproducible_output <- function(.envir = parent.frame()) { .local_envir = .envir ) withr::local_envvar(RSTUDIO = NA, .local_envir = .envir) - if (isTRUE(capabilities("NLS")) && Sys.getenv("LANG") != - "C") { + + if (isTRUE(capabilities("NLS")) && Sys.getenv("LANG") != "C") { lang <- unname(desc::desc_get("Language")) %|% "en" withr::local_language(lang, .local_envir = .envir) } + withr::local_collate("C", .local_envir = .envir) } From d32f34e9804e9181c7d92c4fe256e140da6d7ea1 Mon Sep 17 00:00:00 2001 From: olivroy <52606734+olivroy@users.noreply.github.com> Date: Thu, 11 Jul 2024 10:51:02 -0400 Subject: [PATCH 4/4] Set language unconditionally --- R/rd-eval.R | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/R/rd-eval.R b/R/rd-eval.R index c09ee1ec..bffd76ee 100644 --- a/R/rd-eval.R +++ b/R/rd-eval.R @@ -24,10 +24,8 @@ local_reproducible_output <- function(.envir = parent.frame()) { ) withr::local_envvar(RSTUDIO = NA, .local_envir = .envir) - if (isTRUE(capabilities("NLS")) && Sys.getenv("LANG") != "C") { - lang <- unname(desc::desc_get("Language")) %|% "en" - withr::local_language(lang, .local_envir = .envir) - } + lang <- unname(desc::desc_get("Language")) %|% "en" + withr::local_language(lang, .local_envir = .envir) withr::local_collate("C", .local_envir = .envir) }