translate.list()
The translate.list() function translates $list with a global dictionary and/or given $dictionary.
// Sass.
@use 'sass:list';
// Functions.
@use '../../list/has/has.list.function' as *;
@use '../translator.dictionary.function';
@use 'translate.nth.function';
// Modules.
@use '../dictionary';
// The `translator.translate-list()` or `translate.list()` function.
@function list($list, $key: null, $dictionary: (), $global: null) {
@if type-of($list) == list {
$translation: dictionary.translation(
$list,
translator.dictionary($key, $dictionary, $global)
);
@if $translation {
@return $translation;
}
@for $i from 1 through list.length($list) {
$list: translate.nth($list, $i, $key, $dictionary, $global);
$sub-list-1: list.nth($list, $i);
@if type-of($sub-list-1) == list {
@for $j from 1 through list.length($sub-list-1) {
$sub-list-2: list.nth($sub-list-1, $j);
@if type-of($sub-list-2) == list {
@for $n from 1 through list.length($sub-list-2) {
$sub-list-2: translate.nth(
$sub-list-2,
$n,
$key,
$dictionary,
$global
);
}
$sub-list-1: list.set-nth($sub-list-1, $j, $sub-list-2);
}
$sub-list-1: translate.nth(
$sub-list-1,
$j,
$key,
$dictionary,
$global
);
}
$list: list.set-nth($list, $i, $sub-list-1);
}
}
}
@return $list;
}https://github.com/angular-package/sass/blob/main/translator/translate/_translate.list.function.scss
Parameters
$list
$listA list with a few nested lists to translate.
$key: null
$key: nullA key of dictionary retrieved from a global(if in use) and/or $dictionary for translation.
$dictionary: ()
$dictionary: ()The dictionary that is used to translate elements of $list.
$global: null
$global: nullA bool value indicates whether to use a global dictionary. Default, null, then $dictionary-global is checked.
Return
The return value is translated $list.
Examples
Last updated
Was this helpful?