Key translation error in using shiny.i18n in R Shiny

I want to start with translation in R Shiny. At the very beginning, I am creating the simplest app in Shiny and trying to translate it. But I get the following error:

Warning in load_local_config(translation_csv_config) :
  You didn't specify config translation yaml file. Default settings are used.
Error in multmerge(all_files, sep) :
  Key translation is not the same in all files.

Even when I comment all the app, just running the first line for defining the translation gives me this error.
I have created a csv file for translation.
The code is:

 library(shiny)
 library(shiny.i18n)

 i18n <- Translator$new(translation_csvs_path = "translation_no.csv")
 i18n$set_translation_language("en")

 ui <- fluidPage(p(i18n$t("Hello")))
 server <- function(input, output) {}
 shinyApp(ui, server)

I have saved the csv file in the same directory as my working directory. The csv file is:

en,no
Hello,Hei

The error message you're seeing suggests that there is an issue with the configuration file for the translation package you're using, shiny.i18n. The message "You didn't specify config translation yaml file. Default settings are used." indicates that the package is trying to use the default settings for translations, but the settings in your CSV file are different.

It seems that the package is looking for a YAML file for translation configurations but you are providing it with a CSV file. The package might be expecting a specific format for the translation file, and the CSV file you've provided is not in that format.

To fix this, you'll need to check the documentation for the shiny.i18n package to see what format it expects for translation files. You may need to convert your CSV file to that format or create a new file in the correct format. Once you've done that, you can then update the call to Translator$new() to point to the correct file.

Additionally, it is also possible that the translation package is not compatible with the version of Shiny you are using. Try to update both the packages to their latest version and see if that resolves the issue.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.