translator.translate()
The translator.translate()
function translates string
, map
, or list
with a global dictionary and/or $dictionary
, optionally with a dictionary retrieved by $key
.
// Sass.
@use 'sass:list';
@use 'sass:map';
@use 'sass:meta';
// Functions.
@use 'translator.dictionary.function';
// Modules.
@use 'dictionary';
@use 'translate';
// The `translator.translate()` function.
@function translate($words, $key: null, $dictionary: (), $global: null) {
@return meta.call(
map.get(
(
list: meta.get-function(list, false, translate),
map: meta.get-function(map, false, translate),
string: meta.get-function(string, false, translate),
),
meta.type-of($words)
),
$words,
null,
translator.dictionary($key, $dictionary, $global)
);
}
https://github.com/angular-package/sass/blob/main/translator/_translator.translate.function.scss
Parameters
$words
$words
The words in string
, list
, or map
to translate.
$key: null
$key: null
A key of the dictionary that is used to translate $words
.
$dictionary: ()
$dictionary: ()
The dictionary of map or list type(dictionary key) used to translate $words
.
$global: null
$global: null
A bool
value indicates whether to use a global dictionary. Default, null
, then $dictionary-global
is checked.
Return
The return value is a flattened map dictionary consisting of (word:translation).
Examples
// Use.
@use '@angular-package/sass/translator';
// Examples.
Last updated
Was this helpful?