Appsilon / shiny.i18n

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

Allow translating vectors #28

Closed krystian8207 closed 4 years ago

krystian8207 commented 4 years ago

It would improve the usage a lot if we could pass vectors of keys to the translator. An example:

i18n$t(c("key1", "key2"))

could return:

[1] "Key one" "Key two"
SigurdJanson commented 4 years ago

Is this still open?? I just did this i18n$t(c("Result", "Ability")) and it worked!

SigurdJanson commented 4 years ago

I retract my comment. It basically works, unless all strings are availble. This part is the source of the trouble:

if (is.na(tr)){
        warning(sprintf("'%s' translation does not exist.", keyword))
        tr <- keyword
      }

If we change this to:

if (anyNA(tr)) ...

it won't be pretty (because the warning could not be formatted nicer) but it would work.

dokato commented 4 years ago

Thanks @SigurdJanson for suggestion. Indeed it should be easy this way, formatting warning shouldn't be a big issue. I'll try to include it soon.

dokato commented 4 years ago

@SigurdJanson it should be working now.