Get texts for given language and supports getting them in context of quetzio_server
quetzio_txt.Rd
Get texts for given language and supports getting them in context of quetzio_server
Arguments
- lang
character to identify the language
- x
character to identify the txt to get. If NULL, all labels are recovered
- private
private element of R6 class in which context it is used to get the specific element. Used only internally. Recommended to leave at NULL default.
Details
'quetzio_txt' outside of internal usage should be used only for getting the structure of all texts generated by 'quetzio_server'. You then call it in your console without specifying the 'private' argument.
To customize texts used by questionnaire module, provide within its init call named list to the 'custom_txts' argument. Its elements should be named in the same way as the default text you are willing to replace: so to replace only the Submit button label for the state when the questionnaire is valid for submission and not, the list should look like that:
custom_txts = list(submit_enabled = "Do it!", submit_disabled = "Can't do!)
Examples
#### Usage during development ####
# Get all values for given language
quetzio_txt("en")
#> $submit_enabled
#> [1] "Submit"
#>
#> $submit_disabled
#> [1] "Can't submit"
#>
#> $submit_done
#> [1] "Submitted!"
#>
#> $submit_error
#> [1] "Error!"
#>
#> $modal_title
#> [1] "Answers can't be saved"
#>
#> $modal_content
#> [1] "Some mandatory inputs aren't filled and/or filled inputs aren't valid:"
#>
#> $modal_button
#> [1] "Close the window"
#>
# Get specific text
quetzio_txt("en", "submit_done")
#> [1] "Submitted!"
#### How to use 'custom_txts' during initialization of quetzio ####
## Only run example in interactive R sessions
if (interactive()) {
# load libraries
library(shiny)
library(shiny.quetzio)
# create ui
ui <- fluidPage(Quetzio_UI("my_quetzio"))
server <- function(input, output, session) {
# initialize new quetzio
questionnaire <- Quetzio_create(
source_method = "raw",
source_object = quetzio_examples$questions_lists$simple_quetzio,
module_id = "my_quetzio",
# specify some custom texts to show up
custom_txts = list(
modal_title = "Something is not right!",
modal_content = "Please correct your answers:",
submit_enabled = "Do it!",
submit_disabled = "Can't do!"
)
)
}
shinyApp(ui, server)
}