\n \n
\n \n
\n \n Overview\n
\n \n\n \n
\n The internationalization (i18n) library for Vue is\n
vue-i18n
and defined in\n
src/core/plugins/i18n.ts
. Vue I18n is\n internationalization plugin of Vue.js. It easily integrates some\n localization features to your Vue.js Application. For more detailed\n check\n
vue-i18n official documentation.\n
\n \n
\n \n\n \n
\n \n
\n \n Add new language with translation keys\n
\n \n\n \n
\n - \n To add new language support we should add new object into the\n messages object there key will be language code and value object\n with translation keys.\n {{\n `\n const messages = {\n en: {\n dashboard: \"Dashboard\"\n },\n es: {\n dashboard: \"Tablero\",\n },\n de: {\n dashboard: \"Instrumententafel\",\n },\n ja: {\n dashboard: \"ダッシュボード\",\n },\n + fr: {\n + dashboard: \"Générateur de mise\",\n + }\n};\n `\n }}\n
\n
\n \n
\n \n\n \n
\n \n
\n \n Switching language dynamically\n
\n \n\n \n
\n To change theme language dynamically we can use i18n.locale.value\n property.\n
\n\n
\n - \n Import
useI18n
function form vue-i18n
\n\n {{\n `import { useI18n } from \"vue-i18n\";`\n }}\n \n\n - \n Get i18n instance using useI18n function\n\n {{\n `const i18n = useI18n();`\n }}\n
\n\n - \n Set i18n.locale.value property and set required language\n\n {{\n `i18n.locale.value = \"fr\";`\n }}\n
\n
\n\n
\n You can check ready language switching functionality inside file\n src/layout/header/partials/UserMenu.vue
\n
\n \n
\n \n\n \n
\n \n
\n \n Translation usage inside component\n
\n \n\n \n
\n - \n Get t from the useI18n function which we have imported in a previous\n section.\n\n {{\n `const { t } = useI18n();`\n }}\n
\n\n - \n Use t function inside template section, t function receives a\n translation key as a parameter and returns translation value.\n\n {{\n `\\{\\{ t(\"dashboard\") \\}\\}`\n }}\n
\n
\n\n
\n Check examples of usage inside file\n src/layout/aside/Menu.vue
.\n
\n \n
\n \n