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}
0 commit comments