Skip to content

skip_if_localized() #565

Closed
Closed

Description

@krlmlr

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

Activity

  1. hadley commented on Oct 1, 2017

    @hadley
    Member

    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.

  2. hadley commented on Oct 2, 2017

    @hadley
    Member

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

  3. gaborcsardi commented on Oct 2, 2017

    @gaborcsardi
    Member

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

  4. hadley commented on Oct 3, 2017

    @hadley
    Member

    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"
      }
    }
  5. hadley commented on Oct 4, 2017

    @hadley
    Member

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

  6. hadley commented on Oct 4, 2017

    @hadley
    Member

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

  7. hadley commented on Oct 9, 2017

    @hadley
    Member

    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()

  8. added a commit that references this issue on Oct 9, 2017
    4b77f92
  9. added a commit that references this issue on Feb 15, 2024
    506f1a1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions