Appsilon / shiny.i18n

Shiny applications internationalization made easy
https://appsilon.github.io/shiny.i18n/
Other
169 stars 38 forks source link

[Bug]: Live language exchange navbar #131

Closed anjelinejeline closed 1 year ago

anjelinejeline commented 1 year ago

Guidelines

Project Version

No response

Platform and OS Version

No response

Existing Issues

No response

What happened?

Hi Guys!! I would like to use the shiny.i18n to translate an app in multiple languages Following the examples in the package website Shiny Applications Internationalization • shiny.i18n I was able to build a translation file and select the target translation language using i18n$set_translation_language method. However I would like to create various instances of the app with different languages by adding a dropdown list to select the language. In the package website two options are proposed for the live language exchange (Introduction to shiny.i18n • shiny.i18n), both using a fluidPage. Instead, I would like to use the live language exchange with the navbarPage but I was not able to code it properly. I am very new to shiny and any help is really appreciated

Below you can find a the structure of my basic app

Thank you in advance

# Load libraries ----
library(shiny)
library(shinythemes)
library(dplyr)
library(shiny.i18n)

# Define the json file used for translation ----
i18n <- Translator$new(translation_json_path = "translations/translation.json")
i18n$set_translation_language("es") # run an instance of the app with a specific language (e.g. es)

# Define UI ----

ui<-navbarPage(title =  i18n$t("Website title"),
               tabPanel(title =  i18n$t("tab 1"), 
                        "content 1"),
               tabPanel(title =  i18n$t("tab 2"),
                        "content 2"),
               tabPanel(title =  i18n$t("tab 3"),
                        "content 3"),
               tabPanel(title =  i18n$t("tab 4"),
                        "content 4")

)

# Define server logic ----
server <- function(input, output,session) {

}

# Run the app ----
shinyApp(ui = ui, server = server)

Steps to reproduce

Simplified template

Expected behavior

Live language exchange should work with navbar

Attachments

No response

Screenshots or Videos

No response

Additional Information

No response