Variables

Introduction

A variable is a part of a string that will be replaced by values provided by the application. Values may be passed using the $translate instance method or the v-i18n directive.

Naming Convention

Variable names must be camel-cased, alphanumeric, and begin with a letter (e.g. :myVariable). The colon character (:) indicates the beginning of a variable in the clause definition, but must not be included when passing the argument values.

Working with variables

In this example, the application is expected to provide values for the firstName and lastName variables as arguments to the $translate method or the v-i18n directive.

welcome_message: `Hello, { :firstName :lastName }, and welcome!`
this.$translate('welcome_message', { firstName: 'John', lastName: 'Doe' });
// Hello, John Doe, and welcome!
<div v-i18n="{ firstName: 'John', lastName: 'Doe' }">welcome_message</div>
<!-- <div>Hello, John Doe, and welcome!</div> -->

Last updated