Closed mcsiple closed 3 years ago
I just noticed that this problem is specific to areas where I have chunks of raw HTML and where I have special characters in plot labels, so I don't think this is a shinyi18.n
issue. I will leave it up for now just in case others have run into the same issue but am fairly sure the fix will not require any changes on your part.
I fixed this with an update where I saved all the .R files usign UTF-8 encoding (that was the system default, but I did it again anyway) and changed the raw HTML translations (accessed with switch()
for use in the splash page) I converted UTF-8 characters to HTML, e.g., exploración
--> exploración
. Thank you, and hopefully someone else will benefit from this little code adventure.
Thanks @mcsiple , it was indeed helpful.
So you used switch
function inside your server instead of shiny.i18n
translator. I managed to get it working this way, but wonder if you've done the same. Thanks!
Hi @owen-cho indeed, this is what I used. Here's an example code chunk for what those HTML pieces look like in my code:
In the constants file that loads before the app runs:
splash_es <- "<div class='jumbotron'>
<h2>Bienvenido a la herramienta de exploración de impactos de la captura incidental de mamíferos marinos</h2>
</div>"
In the server code:
output$splash <- renderUI({
htmltools::HTML(
switch(input$selected_language,
"en" = splash_en,
"es" = splash_es,
"fr" = splash_fr
)
)
})
I hope this helps!
Thank you @mcsiple I did pretty much the same:
library(shiny)
ui <- fluidPage(
actionButton("btn", "Welcome"),
selectInput("lang", NULL, c("en", "kr"))
)
server <- function(input, output, session) {
observeEvent(input$lang, {
label <- switch(
input$lang,
en = "Welcome",
kr = HTML("환영합니다")
)
updateActionButton(inputId = "btn", label = label)
})
}
shinyApp(ui = ui, server = server)
Hi Appsilon developers! I built an app using
golem
because I hope to publish it as an R package.I am using live translation in the app via radioButtons. The .json file with my translations contains special characters. When I deploy the app from the R package to shinyapps.io , the version that publishes to the server does not display these special characters at all (notice how the í is missing from "vaya aquí"):
Special characters included in the app_ui.R file render as UTF on the server:
I am not sure if this is a
golem
issue or ashiny.i18n
issue, but I am posting here because I am guessing othershiny.i18n
users have similar issues. I have to keep both types (the .json contents and the in-app special characters) in order to allow translation for the radioButton options and the plots.Here is the repo for the R package (everything works perfectly when the app is deployed from the package): https://github.com/mcsiple/mmrefpoints Here is the server version that deploys automatically when I use
golem::add_shinyappsio_file(); rsconnect::deployApp()
: https://msiple.shinyapps.io/mmrefpoints/If I should post this on the
golem
github page instead, just let me know. And thank you in advance for your help.