Appsilon/shiny.i18n

[Bug]: Translator cannot deal with sentences starting with the same string.

Closed this issue · 1 comments

Guidelines

  • I agree to follow this project's Contributing Guidelines.

Project Version

No response

Platform and OS Version

Windows 10

Existing Issues

No response

What happened?

I have a translation file in which many sentences start with the same words. This causes an error in which duplicate rownames are generated (unclear where) and the translation stops (see below). Presumably this is because the first word is stored as rowname of the DF.
Most likely culprit:

column_to_row <- function(data, colname) {
  stopifnot(colname %in% colnames(data))
  key_index <- which(colname == colnames( (data) ))
  ndata <- data[-key_index]
  rownames(ndata) <- data[, key_index]
  ndata
}

Steps to reproduce

  1. Make translation CSV file with different rows starting with the exact same character.
  2. Run serverside translation workflow:
    translator <- Translator$new(translation_csvs_path = "./inst/extdata/")
  3. Following error is generated:
Error in `.rowNamesDF<-`(x, value = value) : 
  duplicate 'row.names' are not allowed
  1. When you remove the sentences starting with the same strings, the error is resolved.

Expected behavior

Text should be translated without triggering the error.

Attachments

No response

Screenshots or Videos

No response

Additional Information

No response

Problem was caused by commas being present in strings in CSV, thereby artificially replicating certain parts of sentences.