diff --git a/src/main.js b/src/main.js index 1004cfc1..6de769f3 100644 --- a/src/main.js +++ b/src/main.js @@ -15,9 +15,7 @@ import router from '@/router'; import registerServiceWorker from '@/registerServiceWorker'; import clickOutside from '@/utils/ClickOutside'; import { toastedOptions } from '@/utils/defaults'; - -// Locales - Import translation files here! -import en from '@/assets/locales/en-GB.json'; +import { messages } from '@/utils/languages'; Vue.use(VueI18n); Vue.use(VTooltip); @@ -29,12 +27,10 @@ Vue.directive('clickOutside', clickOutside); Vue.config.productionTip = false; -// Setup translations -const messages = { en }; // <-- Add new language files here! - +// Setup i18n translations const i18n = new VueI18n({ - locale: 'en', - fallbackLocale: 'en', + locale: 'en-GB', + fallbackLocale: 'en-GB', messages, }); diff --git a/src/utils/languages.js b/src/utils/languages.js new file mode 100644 index 00000000..1819c83c --- /dev/null +++ b/src/utils/languages.js @@ -0,0 +1,23 @@ +// Locales - Import translation files here! +import enGB from '@/assets/locales/en-GB.json'; + +// Language data - Add your country name, locale code and imported file here +export const languages = [ + { + name: 'English', + code: 'en-GB', + locale: enGB, + flag: '🇬🇧', + }, + // Including: + // name - Human readable name for your language + // code - ISO language code + // locale - The file that you imported above + // flag - A nice emoji flag (optional) +]; + +const i18nMessages = {}; +languages.forEach((lang) => { + i18nMessages[lang.code] = lang.locale; +}); +export const messages = i18nMessages;