// 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;
}
// 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,
));
// String.
@debug translator.translate-map((word: wrapper), general, $-dictionary-example); // (word: owijka)
@debug translator.translate-map((word: wrapper), null, $-dictionary-example general); // (word: owijka)
@debug translator.translate-map((limit: first), null, ((first, start): 1, (last, length, end): 50)); // (limit: 1)
// List.
@debug translator.translate-map((word: basic (wrapper, wrap) color), null, $-dictionary-example general); // (word: basic (owijka, owijka) c)
@debug translator.translate-map((word: basic (wrapper, wrap) color), general, $-dictionary-example); // (word: basic (owijka, owijka) c)
// Different dictionary.
@debug translator.translate-map((calendar: calendar), $dictionary: ($-dictionary-example, (class, calendars))); // (calendar: cal)
@debug translator.translate-map((calendar: calendar), (class, calendars), $-dictionary-example); // (calendar: cal)