Appsilon / shiny.i18n

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

reverseTranslation - function request #65

Open flovv opened 3 years ago

flovv commented 3 years ago

Hi, thanks for providing the package.

I stumbled into a problem in cases where the interface defines backend behavior. In my case I had a list of items with https://shiny.rstudio.com/articles/selectize.html Depending on what a user selects, the backend calculation changes. So it would be great to translate what users can select, however as the translated items end in the backend they need to be stable. (e.g. the translation key).

A solution would be to provide a reverseTranslation function:

reverseTranslation(interfaceName="FB", currentLang="en"){
  dff <- i18n$get_translations()

  dfff <- dff[dff[,currentLang]==interfaceName,]
  return(row.names(dfff[!is.na(dfff[,currentLang]),]))
}