knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval = FALSE )
library(datamods)
When using {datamods} modules, a simple way to modify labels display is provided for using a different language or simply use other labels. There are 4 different ways to use new labels:
# Using a supported language set_i18n("fr") # Using a named list set_i18n(list("Some label" = "Its translation", ...)) # Using a data.framewith 2 columns set_i18n(data.frame(label = c(...), translation = c(...))) # Using a CSV file set_i18n("path/to/file.csv")
The following languages are integrated in {datamods} :
{height=16, style="height:16px"} english, the default.
{height=16, style="height:16px"} french, activate with:
set_i18n("fr")
set_i18n("mk")
set_i18n("pt")
set_i18n("al")
set_i18n("cn")
set_i18n("es")
set_i18n("de")
set_i18n("tr")
set_i18n("kr")
set_i18n("pl")
set_i18n("ja")
If you want another language to be supported, you can submit a Pull Request to add a CSV file like the one used for french (file is located in inst/i18n
folder in the package, you can see it here on GitHub).
You can change labels with a named list
, where names correspond to the labels and values to the translation to use:
options("datamods.i18n" = list( "Import a dataset from an environment" = "Importer un jeu de données depuis l'environnement global", "Select a data.frame:" = "Sélectionner un data.frame :", ... ))
You can change labels with a data.frame
with two columns label
(the original label) and translation
(the new label to display):
set_i18n(data.frame( label = c("Import a dataset from an environment", "Select a data.frame:", ...), translation = c("Importer un jeu de données depuis l'environnement global", "Sélectionner un data.frame :", ...) ))
Use a CSV file with same structure than data.frame
above:
set_i18n("path/to/file.csv")
An example of file is shown below.
Here's the file used for french translation with all labels used in the package:
cat(readLines(system.file("i18n", "fr.csv", package = "datamods"), encoding = "UTF-8"), sep = '\n')
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.