$t and $ta instance methods

$t method

Formats message with key identifier. args is used to resolve references to variables passed as arguments to the translation.

  • Arguments

    • {string} key: required
    • {object} args: optional
  • Returns: {string}

Template:

<p>{{ $t('greeting', { name: 'World' }) }}</p>
1

Message:

greeting = Hello, {$name}
1

Result:

<p>Hello, World</p>
1

$ta method

Formats message with key identifier, but only returns message attributes. args is used to resolve references to variables passed as arguments to the translation.

This method should be used mostly for passing parameters to custom components. For localization of regular html elements v-t directive is more convenient.

  • Arguments

    • {string} key: required
    • {object} args: optional
  • Returns: {object}

Template:

<input v-bind="$ta('login-input')" type="email">
1

Message:

login-input =
    .placeholder = email@example.com
    .aria-label = Login input value
    .title = Type your login email
1
2
3
4

Result:

<input placeholder="email@example.com" aria-label="Login input value" title="Type your login email" type="email">
1