> For the complete documentation index, see [llms.txt](https://docs.angular-package.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.angular-package.dev/sass/translator-v0.1.0/translate/translate.nth.md).

# translate.nth()

The `translate.nth()` function translates element at [`$n`](#usdn) index in [`$list`](#usdlist) with a global dictionary and/or [`$dictionary`](#usddictionary).

{% hint style="info" %}
Global dictionary is in use on [`$dictionary-global`](/sass/translator-v0.1.0/dictionary/dictionary.variables.md#usddictionary-global-true) set to `true`, or by setting `$global` argument to `true`.
{% endhint %}

{% code lineNumbers="true" %}

```scss
// Sass.
@use 'sass:list';

// Functions.
@use '../translator.dictionary.function';
@use 'translate.string.function';

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

// The `translator.translate-nth()` or `translate.nth()` function.
@function nth($list, $n, $key: null, $dictionary: (), $global: null) {
  @if type-of($list) == list {
    $dictionary: translator.dictionary($key, $dictionary, $global);
    $nth: list.nth($list, $n);
    $translation: dictionary.translation($nth, $dictionary);
    @if type-of($nth) == list {
      @if $translation {
        @return list.set-nth($list, $n, $translation);
      } @else {
        @for $i from 1 through list.length($nth) {
          $translation: dictionary.translation(list.nth($nth, $i), $dictionary);
          @if $translation {
            $nth: list.set-nth($nth, $i, $translation);
          }
        }
        @return list.set-nth($list, $n, $nth);
      }
    }
    @return if($translation, list.set-nth($list, $n, $translation), $list);
  }
  @return $list;
}
```

{% endcode %}

{% embed url="<https://github.com/angular-package/sass/blob/main/translator/translate/_translate.nth.function.scss>" %}

### Parameters

#### `$list`

A list in which element at given [`$n`](#usdn) index is translated.

#### `$n`

An index of [`$list`](#usdlist) to translate.

#### `$key: null`

A key of the dictionary retrieved from a global and/or given [`$dictionary`](#usddictionary).

#### `$dictionary: ()`

The dictionary that is used to translate [`$n`](#usdn) element in [`$list`](#usdlist).

#### `$global: null`

A `bool` value indicates whether to use a global dictionary. Default, `null`, then [`$dictionary-global`](/sass/translator-v0.1.0/dictionary/dictionary.variables.md) is checked.

### Return

The return value is the list with a translated [`$n`](#usdn) element of [`$list`](#usdlist).

## Examples

```scss
// 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 with space.
@debug translator.translate-nth(border width 'extra small', 3); // border width xs

// String with delimiter.
@debug translator.translate-nth(border width extra-large, 3); // border width xl

// Translate list as phrase.
@debug translator.translate-nth(border width (extra small), 3); // border width xs

// Translate list as string.
@debug translator.translate-nth(border width (extra-small, 'extra large'), 3); // border width (xs, xl)

// `$global` dictionary true
@debug translator.translate-nth((prefix, suffix), 2, class); // prefix, class-suffix
@debug translator.translate-nth((prefix, name, suffix), 1, class); // class-prefix, name, suffix

// `$global` dictionary false
@debug translator.translate-nth((prefix, suffix), 1, class, $global: false); // prefix, suffix

// List.
@debug translator.translate-nth(((prefix, suffix), suffix), 1, class); // (class-prefix, class-suffix), suffix
@debug translator.translate-nth(((prefix, suffix, (prefix, suffix)), suffix), 1, class); // (class-prefix, class-suffix, (prefix, suffix)), suffix

// Custom `$dictionary`.
@debug translator.translate-nth((prefix, suffix), 1, null, $-dictionary-example class); // class-prefix, suffix
@debug translator.translate-nth((prefix, suffix), 1, class, (test: (class: (prefix: spectre-prefix))) test, false); // spectre-prefix, suffix
@debug translator.translate-nth((wrapper, label, ), 1, null, $-dictionary-example general); // owijka, label
@debug translator.translate-nth((wrapper, label, color), 3, general, $-dictionary-example); // wrapper, label, c
@debug translator.translate-nth((wrapper, label, color), 3, $dictionary: $-dictionary-example general); // wrapper, label, c

```
