Skip to content

Commit

Permalink
Also check for LC_ALL=C in with_language()
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel- committed Jan 9, 2024
1 parent d6aa9bf commit 6bb8939
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions R/language.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,8 @@ local_language <- function(lang, .local_envir = parent.frame()) {
# > (or LC_ALL) to a value other than ‘C’, before you can use a language
# > priority list through the LANGUAGE variable.
# --- https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html
if (Sys.getenv("LANG") %in% c("C", "C.UTF-8")) {
warning(sprintf(
"Changing language has no effect when envvar LANG='%s'",
Sys.getenv("LANG")
))
}
check_language_envvar("LANG")
check_language_envvar("LC_ALL") # Has precedence over `LANG`

local_envvar(LANGUAGE = lang, .local_envir = .local_envir)

Expand All @@ -56,4 +52,14 @@ local_language <- function(lang, .local_envir = parent.frame()) {
invisible()
}

check_language_envvar <- function(var) {
if (Sys.getenv(var) %in% c("C", "C.UTF-8")) {
warning(sprintf(
"Changing language has no effect when envvar %s='%s'",
var,
Sys.getenv(var)
))
}
}

has_nls <- function() capabilities("NLS")[[1]]

0 comments on commit 6bb8939

Please sign in to comment.