Multi Language
Multi Language Settings
i18n Language translation settings
How to add new language?
Let's add the German language in the existing language.
-
Create a new file
src/lang/gr.json
-
update the below code in the
src/i18n.js
file
import { createI18n } from 'vue-i18n'; function loadLocaleMessages() { const locales = require.context('./lang', true, /[A-Za-z0-9-_,\s]+\.json$/i); const messages = {}; locales.keys().forEach((key) => { const matched = key.match(/([A-Za-z0-9-_]+)\./i); if (matched && matched.length > 1) { const locale = matched[1]; messages[locale] = locales(key); } }); return messages; } export default createI18n({ locale: process.env.VUE_APP_I18N_LOCALE || 'en', fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en', messages: loadLocaleMessages(), });