shi18ny's People
shi18ny's Issues
Should give error when langSelectorInput is not defined in UI
library(shiny)
library(shi18ny)
ui <- fluidPage(
useShi18ny(),
#langSelectorInput("lang", position = "fixed"),
h1(ui_("hello")),
uiOutput("results")
)
server <- function(input, output, session) {
i18n <- list(
defaultLang = "en",
availableLangs = c("es","en")
)
lang <- callModule(langSelector,"lang", i18n = i18n, showSelector = TRUE)
output$results <- renderUI({
list(
h2(i_("language",lang()), ": ", lang()),
h1(i_("hello",lang()))
)
})
}
shinyApp(ui, server)
can the parameter keys of i_ function accept something like ALL (indicating that every element of the list should be translated)
Sections' labels not translating in a parmesan type of list (see comments)
not translating sections' labels only parameters's labels; example:
path <- system.file("examples", "ex03-shi18ny", "parmesan", package = "parmesan")
parmesan <- parmesan_load(path)
i_(parmesan, "es")
Include Date and Number formats according to locale
Dates
Numbers (, .)
how to handle common two or more words labels' translation? Start a relevant-short-phrases dictionary?
Sample data
Copy and paste
and common phrases in general could be in a short and relevant phrases dictionary or something like that
put locale folder in the same folder of the examples run (e.g. ex-03)
We would expect users generally not to modify the default locale
folder for the app translations.
It would be easier for users to check the code of the app and how it works right in the same folder they are running the app from, and not having to navigate to the tests folder to see what is happening.
ui_ not working with new selectLangInput with images
Fix uiLangUpdate for workaround of shi18ny/parmesan clash
Without the updateSelectLangInput
function in langSelector
(which was removed to temporarily solve the shi18ny
/parmesan
clash which was blocking modals from shinypanels
to open) the translations of text directly in the UI
of an app doesn't work, because input$shi18ny_ui_classes
isn't created on time by useShi18ny
.
There is a workaround for this by adding a shinyjs::delay
to the observeEvent
in the apps, in which the UI texts are translated (as in code below). This should probably work without the delay function.
observeEvent(lang(),{
shinyjs::delay(500, uiLangUpdate(input$shi18ny_ui_classes, lang()))
})
add country flags in language switcher
i_ function should work with character vectors
Allow CSV table translations in locale
Allow inline locale list for translations in server
locale <- list(
en = list(keyword = "Keyword"),
es = list(keyword = "Clave")
)
ui translations could be done client side in JS by passing locales as json
Maybe also move the replacement in the classes to .init javascript
e.g.
mylang-plot --> mylang.plot
So gsub is not used on uiLangUpdate
FYI - potential useful backend support in package traduire
Full disclosure, I am one of the authors of tradiure.
We've been working on backend support for i18n work (not in the context of shiny apps) and developed a package called traduire (https://github.com/reside-ic/traduire) which wraps the i18next js library, and so includes lots of nice support (pluralisation, context specific translation, in theory support for RTL languages etc). Depending on your goals you might find it useful.
Just an FYI - if you're happier developing your own engine please disregard
match case when translating?
It could be useful if the output of
i_("Upload", "es")
was Subir instead of subir
Fix clash with parmesan caused in langSelector
In langSelector
the updateSelectLangInput
inside the initLocale
reactive was causing a clash with the parmesan
package and therefore blocking modals from opening. In particular, modals from shinypanels::showModalMultipleId
(example to reproduce this problem can be found in inst/examples/ex07-translate_with_parmesan
) were not opening. The temporary fix was to remove this updateSelectLangInput
which means that shi18ny
only works with language parameters from the URL, but not with the language dropdown.
The following code snippet shows the reactives initLocale
and currentLocale
how they are working right now, with the old code commented out. Uncomment the commented sections to reproduce issue.
initLocale <- reactive({
selected <- queryLang() %||% config$defaultLang
message("selected2 ", selected," config ", config$defaultLang)
message(showSelector)
if(showSelector){
shinyjs::show("langContainer")
}
message("config_av_langs",config$availableLangs)
# uncomment the following to reproduce problem
# updateSelectLangInput(session, 'langInner',
# langs = config$availableLangs,
# selected = selected)
message("selected3", selected, " config ", config$defaultLang)
selected
})
currentLocale <- reactive({
initLocale()
newLocale <- queryLang() # comment out this to reproduce problem
# newLocale <- input$langInner # uncomment this to reproduce problem
message("initLocale: ", initLocale())
message("input3 ", newLocale, " is null ",is.null(newLocale))
newLocale
})
Language selection dropdown missing
When I run the code provided in the example below, the dropdown menu to select a language is missing.
if (interactive()) {
library("shiny")
library("shi18ny")
ui <- fluidPage(
tags$h1("shiny internationalization"),
br(),
# Initialize shi18ny
useShi18ny(),
# Language selector input
langSelectorInput("lang", position = "fixed"),
# UI elements
# Text can be translated directly from the UI, using the ui_ function:
h1(ui_("hello")),
# OR by using uiOutput:
uiOutput("results")
)
server <- function(input, output, session) {
# Configure shi18ny
i18n <- list(
defaultLang = "en",
availableLangs = c("es", "en", "pt")
)
# Call language module to get currently selected language and save it in a reactive
lang <- callModule(langSelector, "lang", i18n = i18n, showSelector = TRUE)
# Update UI translation
observeEvent(lang(),{
uiLangUpdate(input$shi18ny_ui_classes, lang())
})
# Render translations by passing the text and the active (selected) language as the lang() parameter to the i_ function
output$results <- renderUI({
list(
h1(i_("world", lang())),
br(),
h4(i_("language", lang()))
)
})
}
shinyApp(ui, server)
}
I should be able to designate the translation to choices inputs from the ymal
Example
agg:
show: true
input_type: selectizeInput
input_params:
label: Aggregation
choices:
i_total:
- sum
i_mean:
- mean
i_median:
- median
selected: discrete
the choices name with "i_" is the word assign for know if translate or no
Stablish how to use internalization (i_() function) with dsmodules' modules (tableInput, downloadHtmlwidget, ...) rendered in ui
for example how to use it here..
downloadTableUI("download_data_button", "Download", formats = c("csv", "xlsx", "json")))
tableInputUI("initial_data",
choices = list("Sample data" = "sampleData",
"Copy & paste" = "pasted",
"CSV/XLS Upload" = "fileUpload",
"Google sheets" = "googleSheets"),
selected = "sampleData"))
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.