translate.map()

The translate.map() function translates flatten $map with a global dictionary and/or $dictionary.

Global dictionary is in use on $dictionary-global set to true, or by setting $global argument to true.

// Sass.
@use 'sass:map';
@use 'sass:meta';

// Modules.
@use '../dictionary';

// Functions.
@use 'translate.list.function' as *;
@use 'translate.string.function' as *;

// The `translator.translate-map()` or `translate.map()` function.
@function map($map, $key: null, $dictionary: (), $global: null) {
  @if type-of($map) == map {
    @each $map-key, $value in $map {
      $map: if(
        meta.type-of($value) == string,
        map.set($map, $map-key, string($value, $key, $dictionary, $global)),
        if(
          meta.type-of($value) == list,
          map.set($map, $map-key, list($value, $key, $dictionary, $global)),
          $map
        )
      );
    }
  }
  @return $map;
}
https://github.com/angular-package/sass/blob/main/translator/translate/_translate.map.function.scss

Parameters

$map

A list in which element at given $n index is translated.

$n

An index of $list to translate.

$key: null

A key of the dictionary retrieved from a global and/or given $dictionary.

$dictionary: ()

The dictionary that is used to translate $n element in $list.

$global: null

A 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?