translator.dictionary()

The translator.dictionary() function returns(flattened map) the global and/or given $dictionary, optionally merged with the dictionary retrieved from $key of this dictionary.

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

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

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

// The `translator.dictionary()` function.
@function dictionary($key: null, $dictionary: (), $global: null) {
  @if list.length($dictionary) > 0 {
    $dictionary: if(
      meta.type-of($dictionary) == map or list.separator($dictionary) == space,
      ($dictionary),
      $dictionary
    );
    @for $i from 1 through list.length($dictionary) {
      $retrieved-dictionary: list.nth($dictionary, $i);
      $dictionary: list.set-nth(
        $dictionary,
        $i,
        if(
          meta.type-of($retrieved-dictionary) ==
            list and
            list.length($retrieved-dictionary) >
            1,
          map.deep-merge-key(
            dictionary.pick(null, $retrieved-dictionary, false),
            list.nth($retrieved-dictionary, 2)...
          ),
          $retrieved-dictionary
        )
      );
    }
  }
  @return map.remove-type(
    map.deep-merge-key(dictionary.merge(null, $dictionary, $global), $key...),
    map
  );
}

Parameters

$key: null

A key to deep merge the dictionary under this key with a global dictionary and/or with $dictionary.

$dictionary: ()

Dictionary of (flatten) map or list(dictionary keys) type to retrieve.

$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