1#### Regression test of translation not working outside packages for R < 4.1.0. 2#### We try French (set in Makefile.common). 3 4### First off, message translation needs to be supported. 5if (!capabilities("NLS")) { ## e.g. when R was configured with --disable-nls 6 message("no natural language support") 7 q("no") 8} 9 10#### Report locale and charset 11Sys.getlocale() 12l10n_info() 13 14#### Skip locales that do not support French (especially C) 15OK <- l10n_info()[["UTF-8"]] || l10n_info()[["Latin-1"]] 16if (!OK) { 17 if(.Platform$OS.type == "windows") { 18 OK <- l10n_info()[["codepage"]] == 28605 ## Latin-9 19 } else { 20 z <- l10n_info()[["codeset"]] 21 ## macOS and Solaris have the first, Linux the second. 22 OK <- tolower(z) %in% c("iso8859-15", "iso-8859-15", "iso885915") 23 } 24} 25if( !OK ) { 26 message("The locale encoding is not known to support French") 27 q("no") 28} 29 30## Translation domain for a function not in a package: PR#17998 31tryCmsg<- function(expr) tryCatch(expr, error = conditionMessage) 32chk0 <- function(x) stopifnot(x == 0) 33(m1 <- tryCmsg(chk0(1))) # (not translated in R < 4.1.0) 34## switch back to English (if possible) for final report. 35Sys.setenv(LANGUAGE="en") 36m2 <- "x == 0 n'est pas TRUE" 37if(m1 != m2) stop("message was not translated to French") 38