angular-package
PatreonTwitternpmGitHub
Sass
Sass
  • Introduction
  • ❤ Benefits
  • General concepts
  • Getting started
    • Skeleton
    • Installation
      • npm
    • Public API
    • Basic concepts
  • Class
    • Overview
    • ⚒ class.content()
    • ⚒ class.name()
    • ⚒ class.parent-first()
    • ⚒ variables
  • Color
    • Overview
    • Scheme
      • is
        • ⚒ is.dark()
        • ⚒ is.light()
        • ⚒ is.normal()
      • ⚒ scheme.is()
    • ⚒ color.alpha-var()
    • ⚒ color.color()
    • ⚒ color.hsla-color()
    • ⚒ color.hue-var()
    • ⚒ color.lightness-var()
    • ⚒ color.name()
    • ⚒ color.retrieve()
    • ⚒ color.saturation-var()
  • Comparison
    • Overview
    • Greater
      • greater.than()
      • greater.than-any()
      • greater.than-every()
    • Less
      • less.than()
      • less.than-any()
      • less.than-every()
    • comparison.compare()
    • comparison.compare-multiple()
  • Function
    • Overview
    • Call
      • ⚒ function.arglist()
      • ⚒ function.by-list()
    • ⚒ function.call()
    • ⚒ function.get()
    • ⚒ function.has()
    • ⚒ function.insert()
    • ⚒ function.is()
    • ⚒ function.name()
    • ⚒ function.pick()
    • ⚒ function.prefix()
    • ⚒ function.remove()
  • List
    • Overview
    • Get
      • get.bool()
      • get.list()
      • get.map()
      • get.number()
      • get.string()
      • get.type()
    • Has
      • has.bool()
      • has.list()
      • has.map()
      • has.number()
      • has.string()
      • has.type()
      • has.value()
    • Remove
      • remove.duplicate()
      • remove.list()
      • remove.map()
      • remove.nth()
      • remove.number()
      • remove.range()
      • remove.string()
      • remove.type()
      • remove.value()
    • list.append()
    • list.empty()
    • list.extract-map()
    • list.first()
    • list.from()
    • list.has()
    • list.index()
    • list.indexes()
    • list.insert-nth()
    • list.join()
    • list.last()
    • list.limit()
    • list.nth()
    • list.range()
    • ⚒ list.replace-string()
    • ⚒ list.replace()
    • list.select()
    • ⚒ list.swap()
    • ⚒ list.to-map()
    • list.to()
    • list.type()
  • Map
    • Overview
    • Pattern
      • pattern.is()
      • Variables
    • Pick
      • pick.key-substring()
      • pick.key-type()
      • pick.pattern()
      • pick.type()
      • pick.value-type()
    • map.deep-merge-key()
    • map.deep-merge()
    • map.get()
    • map.has-keys()
    • map.key-replace()
    • ⚒ map.merge-allowed()
    • map.pick()
    • map.remove-type()
    • map.remove()
    • map.retrieve()
    • map.set()
    • map.update()
    • map.values()
  • Math
    • Overview
    • Range
      • range.down()
      • range.up()
    • math.calculate()
    • math.range()
    • ⚒ math.sort()
    • math.strip-unit()
  • Meta
    • Overview
    • ⚒ meta.call-arglist()
    • ⚒ meta.of-type()
  • Object
    • Overview
    • ⚒ object.create()
    • ⚒ object.get()
    • ⚒ object.set()
  • Property
    • Overview
    • ⚒ property.property()
    • ⚒ property.name()
    • ⚒ property.set()
    • ⚒ property.value()
    • ⚒ property.variant()
  • Query
    • Overview
    • Operation
      • ⚒ operation.execute()
    • ⚒ query.execute()
  • Selector
    • Overview
    • ⚒ selector.class()
    • ⚒ selector.nest-content()
    • ⚒ selector.nest()
    • ⚒ selector.pseudo-class()
    • ⚒ selector.replace-parent()
  • String
    • Overview
    • string.index()
    • string.join()
    • string.replace-multiple()
    • string.replace()
    • string.split()
    • ⚒ string.to-map()
    • ⚒ string.unquote()
  • Translator v0.1.0
    • Overview
    • Dictionary
      • dictionary.get()
      • dictionary.is-global()
      • dictionary.merge()
      • dictionary.pick()
      • dictionary.set()
      • dictionary.translation()
      • dictionary.variables
    • Translate
      • translate.list()
      • translate.map()
      • translate.nth()
      • translate.string()
    • translator.dictionary()
    • translator.translate()
  • Translator v1.0.0
    • Overview
    • Dictionary
      • dictionary.get()
      • dictionary.merge()
      • dictionary.pick()
      • dictionary.set()
      • dictionary.translation()
      • dictionary.variables
    • ⚒ Translate
    • translator.dictionary()
    • translator.translate()
  • Values
    • Overview
    • values.combine()
  • Var
    • Overview
    • ⚒ var.adjust()
    • ⚒ var.css()
    • ⚒ var.get()
    • ⚒ var.is()
    • ⚒ var.name()
    • ⚒ var.negative()
    • ⚒ var.unit()
    • var.set()
  • Variant
    • Overview
  • Change log
    • Keep a changelog
    • CHANGELOG.md
    • v0.12.0-beta
  • GIT
    • Commit
    • Semantic Versioning
  • License
    • MIT
  • Social
    • Gettr
    • Twitter
    • YouTube
  • Contact
    • Chat
    • Email
    • Phone
  • Donate
    • Cryptocurrency
    • Fiat
Powered by GitBook
On this page
  • Parameters
  • Return
  • Examples

Was this helpful?

  1. Translator v0.1.0
  2. Translate

translate.list()

PreviousTranslateNexttranslate.map()

Last updated 1 year ago

Was this helpful?

The translate.list() function translates with a global dictionary and/or given .

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

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

Parameters

$list

A list with a few nested lists to translate.

$key: null

$dictionary: ()

$global: null

Return

Examples

// Use.
@use '@angular-package/sass/translator';

// Examples.
$-dictionary-example: dictionary.merge(null, (
  (extra large, 'extra large', extra-large): xl,
  (extra small, 'extra small', extra-small): xs,
  border: b,
  class: (prefix: class-prefix, separator: class-separator, suffix: class-suffix, calendars: (calendar: cal), labels: (label: lab)),
  color: c,
  general: (word: słowo, (wrapper, wrap): owijka, (technology, technologia): tech, color: c),
  large: lg,
  medium: md,
  outline: o,
  prefix: spectre,
  small: sm,
  suffix: end,
));

// @debug list(extra large);
@debug translator.translate-list(extra-large (extra small)); // xl xs

// @debug list((extra-large,));
@debug translator.translate-list(border (extra large)); // b xl

// List.
// Get dictionary with a `$key` parameter`.
@debug translator.translate-list((prefix, border, suffix), class); // class-prefix, b, class-suffix

// Get dictionary with a `$dictionary` parameter of list type.
@debug translator.translate-list((wrapper, technology), $dictionary: $-dictionary-example general); // owijka, tech
@debug translator.translate-list((wrapper, technology) color, general, $-dictionary-example); // (owijka, tech) c
@debug translator.translate-list((wrapper, (word,), ([word])), $dictionary: $-dictionary-example general); //  owijka, (słowo,), [słowo]

// Translate by using global dictionary and `class` key.
@debug translator.translate-list(prefix (separator, prefix) suffix, $key: class); // class-prefix (class-separator, class-prefix) class-suffix

// Custom dictionary.
@debug translator.translate-list((wrapper,), general, $-dictionary-example); // (owijka,)
@debug translator.translate-list((calendar, label), $dictionary: $-dictionary-example (class, calendars)); // cal, label
@debug translator.translate-list((border, outline) color, $dictionary: (border: b, outline: o, 'gray': g, 'red': r)); // (b, o) c
@debug translator.translate-list((border 'red', outline 'gray') color, $dictionary: (border: b, outline: o, 'gray': g, 'red': r)); // (b r, o g) c

// Nested lists
@debug translator.translate-list((border 1 outline (border 2, outline, (border 3, outline, (border 4, outline))) color), $dictionary: (border: b, outline: o, 'gray': g, 'red': r)); // b 1 o (b 2, o, (b 3, o, (border 4, o))) c

A key of dictionary retrieved from a global(if in use) and/or for translation.

The dictionary that is used to translate elements of .

A bool value indicates whether to use a global dictionary. Default, null, then is checked.

The return value is translated .

$dictionary-global
$dictionary
$list
$list
$list
$dictionary
$global
$dictionary-global
https://github.com/angular-package/sass/blob/main/translator/translate/_translate.list.function.scss