闪亮:动态更改选项卡名称
我正在开发一个可以处理多种语言的 Shiny 应用程序.我设法根据 selectInput
来动态翻译应用程序的几乎所有元素来选择语言.然而,硬东西"仍然是我页面中的 navbarPage
标签以及 tabPanels
.我不能改变他们的名字.我试过这个,但它不起作用:
I'm working on a Shiny application that is supposed to handle multiple languages. I managed to dynamically translate almost all elements of the app depending on a selectInput
to choose the language. However the "hard stuff" remains the navbarPage
tabs as well as the tabPanels
inside my pages. I cannot change their names. I tried this, but it does not work:
library(shiny)
ui <- navbarPage("App Title",
tabPanel("tab1",
selectInput("language", "language", c("EN", "FR"), width = '300px'),
textOutput("text")),
uiOutput("render_tab2"))
server <- function(input, output, session) {
output$text = renderText({ switch(input$language, "EN"="hello world", "FR"="bonjour monde") })
output$render_tab2 = renderUI({
tabPanel( title=switch(input$language, "EN"="tab2", "FR"="onglet2") )})}
shinyApp(ui, server)
而 updatenavbarpanel()
系列函数只是设置活动选项卡,而不是改变它们的特性......有没有办法做到这一点,如果可能的话,不改变其结构我所有的应用程序...非常感谢.
And the updatenavbarpanel()
family of functions are just to set the active tab, not change their characteristics...Is there a way to do it, if possible that does not change the structure of all my app... THanks a lot.
这段代码动态设置标题:
This piece of code set the title dynamically :
library(shiny)
ui <- navbarPage("App Title",
tabPanel(title = uiOutput("title_panel"),
selectInput("language", "language", c("EN", "FR"), width = '300px')
)
)
server <- function(input, output, session) {
output$title_panel = renderText({
switch(input$language, "EN"="hello world", "FR"="bonjour monde")
})
}
shinyApp(ui, server)
适用于 uiOutput("title_panel")
&textOutput("title_panel")