Skip to content

Commit 0926fad

Browse files
author
smeyer
committed
Sys.setLanguage() cleanup: 'C.vs.en' was a kludge for str(), obsolete with r87080
git-svn-id: https://svn.r-project.org/R/trunk@88094 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 0a90544 commit 0926fad

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

src/library/base/R/stop.R

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# File src/library/base/R/stop.R
22
# Part of the R package, https://www.R-project.org
33
#
4-
# Copyright (C) 1995-2024 The R Core Team
4+
# Copyright (C) 1995-2025 The R Core Team
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -126,24 +126,17 @@ gettextf <- function(fmt, ..., domain = NULL, trim = TRUE)
126126

127127
## Could think of using *several* domains, i.e. domain = vector; but seems complicated;
128128
## the default domain="R" seems to work for all of base R: {"R", "R-base", "RGui"}
129-
Sys.setLanguage <- function(lang, unset = "en",
130-
C.vs.en = c("msg", "warn", "silent"), force = FALSE)
129+
Sys.setLanguage <- function(lang, unset = "en", force = FALSE)
131130
{
132131
stopifnot(is.character(lang), length(lang) == 1L, # e.g., "es" , "fr_CA"
133132
lang == "C" || grepl("^[a-z][a-z]", lang))
134133
curLang <- Sys.getenv("LANGUAGE", unset = NA) # so it can be reset
135134
if(is.na(curLang) || !nzchar(curLang))
136135
curLang <- unset # "factory" default
137136
if (!capabilities("NLS") || is.na(.popath)) {
138-
warning(gettextf("no natural language support or missing translations"), domain=NA)
137+
warning("no natural language support or missing translations")
139138
return(invisible(structure(curLang, ok = FALSE)))
140139
}
141-
Warning <- if(startsWith(lang, "en"))
142-
switch(match.arg(C.vs.en),
143-
silent = function(...){},
144-
msg = message,
145-
warn = warning)
146-
else warning
147140
if(identical("C", Sys.getlocale()) && lang != "C") { ## e.g. LC_ALL=C R on Linux
148141
if(force) {
149142
lcSet <- if(.Platform[["OS.type"]] == "unix") # works to "undo LC_ALL=C"
@@ -153,19 +146,19 @@ Sys.setLanguage <- function(lang, unset = "en",
153146
## 2) How to deal w/ Windows ? {can set things but with *no* effect}
154147
ok.lc <- !is.null(lcSet) && nzchar(lcSet) # NULL or "" are not ok
155148
if(!ok.lc)
156-
Warning(gettextf(
149+
warning(gettextf(
157150
"In bare C locale: LANGUAGE reset, but message language may be unchanged"),
158151
domain=NA)
159152
} else { # !force (default) :
160-
Warning(gettextf("In bare C locale, not forcing locale; possibly use 'force = TRUE'?"),
153+
warning(gettextf("In bare C locale, not forcing locale; possibly use 'force = TRUE'?"),
161154
domain=NA)
162155
return(invisible(structure(curLang, ok = FALSE)))
163156
}
164157
} else ok.lc <- TRUE
165158
ok <- Sys.setenv(LANGUAGE=lang)
166159
if(!ok)
167160
warning(gettextf('Sys.setenv(LANGUAGE="%s") may have failed', lang), domain=NA)
168-
ok. <- capabilities("NLS") &&
161+
ok. <- #capabilities("NLS") && # asserted above
169162
isTRUE(bindtextdomain(NULL)) # only flush the cache (of already translated strings)
170163
invisible(structure(curLang, ok = ok && ok.lc && ok.))
171164
}

src/library/base/man/gettext.Rd

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ ngettext(n, msg1, msg2, domain = NULL)
2727

2828
bindtextdomain(domain, dirname = NULL)
2929

30-
Sys.setLanguage(lang, unset = "en", C.vs.en = c("msg", "warn", "silent"),
31-
force = FALSE)
30+
Sys.setLanguage(lang, unset = "en", force = FALSE)
3231
}
3332
\arguments{
3433
\item{\dots}{one or more character vectors.}
@@ -47,11 +46,6 @@ Sys.setLanguage(lang, unset = "en", C.vs.en = c("msg", "warn", "silent"),
4746
\item{unset}{a string, specifying the default language assumed to be
4847
current in the case \code{\link{Sys.getenv}("LANGUAGE")} is unset or
4948
empty.}
50-
\item{C.vs.en}{a string specifying how a current (sometimes \dQuote{hard})
51-
setting of language \code{"C"} is treated for \code{lang = "en"}.
52-
When \code{"silent"}, nothing happens, when \code{"msg"}, a
53-
\code{\link{message}()} and if \code{"warn"} a \code{\link{warning}()}
54-
is signalled.}
5549
\item{force}{logical indicating if in case of a \dQuote{hard} set
5650
\code{"C"} locale, \code{Sys.setLanguage()} should try modifying the
5751
locale (to \code{"en"}) in order to subsequently set the desired language

0 commit comments

Comments
 (0)