R/zzz.R

Defines functions get_i18n_config .onLoad

Documented in get_i18n_config .onLoad

#' Global  i18n config list.
#' @keywords internal
.i18_config <- list()

#' onLoad
#'
#' On package load it updates .i18_config reading yaml file from config.
#'
#' @param libname library name
#' @param pkgname package name
#'
#' @importFrom yaml yaml.load_file
#' @keywords internal
.onLoad <- function(libname, pkgname) {
  .i18_config <<- yaml.load_file(system.file("config.yaml",
                                             package = "shiny.i18n"))
}

#' Get i18n config
#'
#' @param field a field from configuration file
#'
#' @return character with option from config.yaml file
#' @keywords internal
get_i18n_config <- function(field) {
  stopifnot(field %in% names(.i18_config))
  return(.i18_config[[field]])
}

Try the shiny.i18n package in your browser

Any scripts or data that you put into this service are public.

shiny.i18n documentation built on Jan. 16, 2023, 5:10 p.m.