translate.nth()
The translate.nth() function translates element at $n index in $list with a global dictionary and/or $dictionary.
// Sass.
@use 'sass:list';
// Functions.
@use '../translator.dictionary.function';
@use 'translate.string.function';
// Modules.
@use '../dictionary';
// The `translator.translate-nth()` or `translate.nth()` function.
@function nth($list, $n, $key: null, $dictionary: (), $global: null) {
@if type-of($list) == list {
$dictionary: translator.dictionary($key, $dictionary, $global);
$nth: list.nth($list, $n);
$translation: dictionary.translation($nth, $dictionary);
@if type-of($nth) == list {
@if $translation {
@return list.set-nth($list, $n, $translation);
} @else {
@for $i from 1 through list.length($nth) {
$translation: dictionary.translation(list.nth($nth, $i), $dictionary);
@if $translation {
$nth: list.set-nth($nth, $i, $translation);
}
}
@return list.set-nth($list, $n, $nth);
}
}
@return if($translation, list.set-nth($list, $n, $translation), $list);
}
@return $list;
}https://github.com/angular-package/sass/blob/main/translator/translate/_translate.nth.function.scss
Parameters
$list
$listA list in which element at given $n index is translated.
$n
$nAn index of $list to translate.
$key: null
$key: nullA key of the dictionary retrieved from a global and/or given $dictionary.
$dictionary: ()
$dictionary: ()The dictionary that is used to translate $n element in $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 the list with a translated $n element of $list.
Examples
Last updated
Was this helpful?