Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip_if_localized() #565

Closed
krlmlr opened this issue Jan 26, 2017 · 8 comments
Closed

skip_if_localized() #565

krlmlr opened this issue Jan 26, 2017 · 8 comments
Labels
expectation 🙀 feature a feature request or enhancement

Comments

@krlmlr
Copy link
Member

krlmlr commented Jan 26, 2017

to be able to skip tests that check the wording of an error message and fail in a non-English locale.

@hadley
Copy link
Member

hadley commented Oct 1, 2017

Or we could add a language parameter to expect_error()? That's more likely to affect existing code, but it might be easy to discover.

@hadley hadley added expectation 🙀 feature a feature request or enhancement labels Oct 2, 2017
@hadley
Copy link
Member

hadley commented Oct 2, 2017

Hmmm, how do we know if you're localised?

@gaborcsardi
Copy link
Member

Maybe Sys.getenv("LANGUAGE") based on ?"environment variables"?

@gaborcsardi
Copy link
Member

@hadley
Copy link
Member

hadley commented Oct 3, 2017

Something like

is_english <- function() {
  lang <- Sys.getenv("LANGUAGE")
  if (identical(lang, "en")) {
    return(TRUE)
  }
  
  if(.Platform$OS.type == "windows") {
    lc <- sub("\\..*", "", sub("_.*", "", Sys.getlocale("LC_CTYPE")))
    lc == "English" || lc == "C"
  } else {
    lc <- sub("\\..*", "", Sys.getlocale("LC_MESSAGES"))
    lc == "C" || substr(lc, 1, 2) == "en"
  }
}

@hadley
Copy link
Member

hadley commented Oct 4, 2017

We need a different name because of localized vs localised. Maybe skip_if_not_en()?

@hadley
Copy link
Member

hadley commented Oct 4, 2017

This feels awkward - I'd rather add a lang parameter to expect_error()

@hadley hadley closed this as completed in 506f1a1 Oct 4, 2017
@hadley
Copy link
Member

hadley commented Oct 9, 2017

Unfortunately it looks like that gettext caches translations between calls making it difficult to switch languages back and forth in a single session. I'll go back to skip_if_translated()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expectation 🙀 feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants