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.

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

// 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)
  );
}

Parameters

$words

The words in string, list, or map to translate.

$key: null

A key of the dictionary that is used to translate $words.

$dictionary: ()

The dictionary of map or list type(dictionary key) used to translate $words.

$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