Skip to content

Globalization

Notes:

  • We use VueI18n for translations.
  • In the js/translations.js file, you can define translations for different languages.
  • Everything is already set up in the project, so you can start using it right away.

Vue syntax

Js:

JavaScript
$t('Hello World')

Html:

HTML
{{ $t('Hello World') }}

Translation file js/translation.js format

JSON
1
2
3
4
5
6
7
8
const messages = {
  pl: {
    "Hello World": 'Polish translatation',
  },
  en: {
    "Hello World": 'English translatation',
  },
}

Instance Configuration

Instance default language: kv.v.owner.language

Vue initialization

JavaScript
1
2
3
4
5
const i18n = new VueI18n({
  locale: localStorage.getItem('language') , // set locale
  fallbackLocale: 'en',
  messages, // set locale messages
})