Appsilon/shiny.i18n

reverseTranslation - function request

Opened this issue · 0 comments

flovv commented

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]),]))
}