Closed rschramm9 closed 1 year ago
Better workaround. Using named arguments in the function call (instead of positional args) as shown below appears to work in either shiny.i18n package version: update_lang( language = "pl", session = session )
Hi @rschramm9
Thank you for pointing this out. The tutorial has been already updated. Regarding the change in arguments order - shiny.i18n
is still before its stable 1.0.0 version, so the API of the package can change.
The current version of update_lang
function follows the general approach with session
argument with the given default - so now you should be able to simply use update_lang( language = "pl")
(or update_lang( "pl")
).
Guidelines
Project Version
0.3.0
Platform and OS Version
macOS 12.6, Windows10 Pro
Existing Issues
No response
What happened?
My shiny apps broke as result of upgrade in shiny.i18n package from v0.2.0 to 0.3.0. The problem occurs in my server.R includes an observeEvent for language change which includes a call to this package's update_lang() method. At appears the order of arguments to the function changed between versions 0.2.0 and 0.3.0 the call: update_lang(session, input$lang_pick) # works in v 0.2.0 but breaks in 0.3.0 the call: update_lang(input$lang_pick, session) # works in v 0.3.0 but breaks in 0.2.0
The problem also occurs in your minimal tutorial at: https://appsilon.github.io/shiny.i18n/articles/basics.html
Steps to reproduce
Expected behavior
Updating the package should not break functionality. Order of arguments or the tutorials and the README notes should be corrected or state the naturre of the breaking change.
Attachments
library(shiny) library(shiny.i18n)
i18n <- Translator$new(translation_json_path = "translation.json")
i18n$set_translation_language("en")
ui <- fluidPage(usei18n(i18n), p(i18n$t("Hello")), actionButton("go", "GO!") )
server <- function(input, output, session) { observeEvent(input$go,{
update_lang(session, "pl") # tutorial and 0.2.0 code, breaks with 0.3.0
}) }
shinyApp(ui, server)
Screenshots or Videos
No response
Additional Information
No response