datasketch / shi18ny

19 stars 7 forks source link

Allow csv translations #37

Closed lenafm closed 3 years ago

lenafm commented 3 years ago

Fixes #27

Translations can now be done from a csv with an id column and one or multiple language columns (e.g. en, es, etc).

To use a csv translations, the csv file needs to be located in the locale directory (by default "locale") and needs to be called translations.csv.

To use translations from csv, the customTranslationSource parameter needs to be passed to i18nLoad as follows (default for this parameter is yaml).

i18n <- list(
    defaultLang = "en",
    availableLangs = c("de","en","es"),
    customTranslationSource = "csv"
  )

lang <- callModule(langSelector,"lang", i18n = i18n, showSelector = TRUE)

Note that at the moment, for this to work, all translation functions in the app also need to be passed the i18n parameter: i_("translation_id", lang = lang(), i18n = i18n)