R What does the domain argument in the stop () function do?

When starting the function

stop("m<0", domain=NA)

default domain setting NULL, but what happens when you install it on NA? I tried to change the domain to this, but it did not seem to be doing anything. The error message is the same.

+4
source share
1 answer

In R, messages are divided into domains, and translations may be available for some or all of the messages in the domain. You can switch the language domains by changing the variable LANG:

> Sys.setenv(LANG = "fr")
> 2 + x
Erreur : objet 'x' introuvable
> Sys.setenv(LANG = "en")
> 2 + x
Error: object 'x' not found

Usage example:

> Sys.setenv(LANG = "de")
> 
> if((length(nopkgs) > 0) && !missing(lib.loc)) {
+   pkglist <- paste(sQuote(nopkgs), collapse = ", ")
+   msg <- sprintf(ngettext(length(nopkgs),
+                           "library %s contains no packages",
+                           "libraries %s contain no packages",
+                           domain = "R-base"),
+                  pkglist)
+   warning(msg)
+ }
Fehler: Objekt 'nopkgs' nicht gefunden
> 

... restart session R

> Sys.setenv(LANG = "en")
> if((length(nopkgs) > 0) && !missing(lib.loc)) {
+   pkglist <- paste(sQuote(nopkgs), collapse = ", ")
+   msg <- sprintf(ngettext(length(nopkgs),
+                           "library %s contains no packages",
+                           "libraries %s contain no packages",
+                           domain = "R-base"),
+                  pkglist)
+   warning(msg)
+ }
Error: object 'nopkgs' not found
> 

R uses the following areas.

  • Domain R for error messages and level C warnings from the interpreter R.
  • R-pkg R-- , R-base .
  • pkg C .
  • RGui .. R Windows GUI.

R : .

, , , , (de_AT) (de) , , , , . , R en_GB, (, ) .

, . LANGUAGE , , se: de, .

, . .mo. , R RGui, R_HOME/share/locale , , po ( inst/po ). , , . se de_AT. LC_MESSAGES . , R

share/locale/en/LC_MESSAGES/R.mo
share/locale/en@quot/LC_MESSAGES/R.mo
library/splines/po/en/LC_MESSAGES/R-splines.mo
library/splines/po/en/LC_MESSAGES/splines.mo

( "" en @- UTF-8.)

: https://developer.r-project.org/Translations30.html

+1

Source: https://habr.com/ru/post/1690527/


All Articles