In this post, I will show you how to translate text with parameters with Vue I18n in Vue.js.
Simple text
To use a translation use the $t()
function with a translation id as parameter:
<template>
<p>{{ $t('hello') }}</p>
</template>
Text with parameters
You can of course add parameters to your translation texts:
{
"hello": "Hallo {name}!",
}
<template>
<p>{{ $t('hello', { name: 'Vue.js'}) }}</p>
</template>