dictionary.get()
The dictionary.get()
function returns a global dictionary, optionally from $key
.
// Variables.
@forward 'dictionary.variables';
@use 'dictionary.variables' as variables;
// Modules.
@use '../../../map';
// The `translator.dictionary-get()` or `dictionary.get()` function.
@function get($key: null, $default: null) {
@return if(
$key,
if(
type-of(map.get(variables.$dictionary, $key)) == map,
map.get(variables.$dictionary, $key),
$default
),
variables.$dictionary
);
}
https://github.com/angular-package/sass/blob/main/translator/dictionary/_dictionary.get.function.scss
Parameters
$key: null
$key: null
An optional key to retrieve dictionary from a global dictionary.
$default: null
$default: null
The default returned value if dictionary is null
.
Return
The return value is a global dictionary, optionally from $key
. If null
returned value is $default
.
Examples
// Use.
@use '@angular-package/sass/translator';
// Examples.
// Gets the global dictionary
@debug translator.dictionary-get(); // (word: translation)
// Gets the global dictionary of key (not translation)
@debug translator.dictionary-get(word); // null
// Gets nested key
variables.$dictionary: map.merge(variables.$dictionary, (test: (ok: (first: accept, second: do))));
@debug translator.dictionary-get((test, ok)); // (first: accept, second: do)
@debug translator.dictionary-get((word, wrong)); // null
// Gets the `$default`
@debug translator.dictionary-get(word, exist); // exist
Last updated
Was this helpful?