-
Notifications
You must be signed in to change notification settings - Fork 81
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
Create snippet or extend addin to allow specification of LANGUAGE for the reprex #250
Comments
Temporary workaround – you can use the withr package dplyr::select(foo)
#> Error in dplyr::select(foo): object 'foo' not found If I run: withr::with_envvar(c("LANG" = "de_DE.UTF-8"), code = {reprex::reprex(dplyr::select(foo))}) I get dplyr::select(foo)
#> Error in dplyr::select(foo): Objekt 'foo' nicht gefunden Created on 2019-04-16 by the reprex package (v0.2.1) |
Thanks Mara!, this is a nice walkaround solution although I still think it would be more convenient to have this functionality on the |
Assuming that one attaches reprex in withr::with_envvar(
c("LANG" = "de_DE.UTF-8"),
reprex()
) I can't see a built-in solution being that much easier/shorter and it would create more code to document and maintain. This looks like a good thing to create an RStudio snippet for? Or maybe even incorporate this as a feature in the current gadget/addin? I think all of those are better ways to make this withr trick more available than to add another argument to Do you @andresrcs have any interest in noodling on those alternatives? |
Re: tidyverse dev day An interesting project would be to explore exposing this method of setting the language in the existing addin/gadget. reprex already imports withr. A minimum viable product, therefore, it's adding some sort of input for language and reworking the |
I whish I had the skills needed, I just ended up creating my own
|
I think that's a good solution! Esp. for an individual. I will leave this open in case anyone want to tackle at our next tidyverse dev day. |
Maybe something like this would be more generalizable
|
This is related to locale in the
And this thread appears to really be about this, more than true aspects of locale. Not sure what to make of this difference: "LANGUAGE" (from the docs) vs. "LANG" (from all the working examples here). |
Details at https://cran.rstudio.com/doc/manuals/r-devel/R-admin.html#Localization-of-messages — I think setting |
This make me think about this other use case, being English the "lingua franca" I also want my date labels in English when rendering a reprex. reprex_locale <- function(..., locale = "en_US.UTF-8") {
withr::with_envvar(
c("LC_ALL" = locale),
reprex::reprex(...)
)
}
library(ggplot2)
df <- data.frame(stringsAsFactors = FALSE,
date = as.Date(c("2019-01-01", "2019-02-01")),
value = c(1, 2))
ggplot(df, aes(x = date, y = value)) +
geom_col() +
scale_x_date(date_breaks = "1 month", date_labels = "%b") |
My native language is spanish, so the locale on my PC is ES_us, but when posting a reprex to English forums that includes error messages I would like to use EN_us, that way I wouldn't have to manually translate the error messages, or remeber to manually change my locale beforehand, would you consider adding this funtionality? I think it would be pretty handy for non-English users.
The text was updated successfully, but these errors were encountered: