1 config.inc config_get_translated($config_file, $option = NULL, $args = array(), $options = array())

A shortcut function to load and retrieve a single translated value from a config file.

Parameters

string $config_file: The name of the configuration object to retrieve. The name corresponds to an JSON configuration file. For

config('book.admin') 

, the config object returned will contain the contents of book.admin.json.

string $option: The name of the config option within the file to read. The config option may contain periods to indicate levels within the config file. If NULL is passed in, the entire contents of the config file will be returned.

array $args: An associative array of replacements to make. Replacements are made in the same way as the t() function.

array $options: An associative array of additional options, with the following elements:

  • 'langcode' (defaults to the current language): The language code to translate to a language other than what is used to display the page.
  • 'context' (defaults to the empty context): The context the source string belongs to.

Return value

string: The translated contents of the requested config option. Returns default if no translation is found. Returns NULL if the specified option was not found in the file at all or if not a string.

See also

t()

config_get()

File

core/includes/config.inc, line 151
This is the API for configuration storage.

Code

function config_get_translated($config_file, $option = NULL, $args = array(), $options = array()) {
  $config = config($config_file);
  return $config->getTranslated($option, $args, $options);
}