rquartogt

How to change the language of gt html tables in quarto


I want to change the language or the input placeholder in the search bar and the pagination buttons of an interactive table created with the {gt} package within a quarto website.

REPREX

library(gt)

mtcars |>
  gt() |>
  opt_interactive(use_search = TRUE, use_pagination = TRUE)

Solution

  • You can set the locale with gt(..., locale = xx-XX), where xx-XX is one of the available locales found with info_locale().


    Edit: to set a give locale for all calls to gt in the document, here's a (sort of hackish) way to redefine gt for the session:

    gt_orig <- gt
    gt <- \(...) do.call(gt_orig, c(locale = 'xx-XX', list(...)))
    

    restore with gt <- gt_orig