mirror of https://github.com/Lissy93/dashy.git
⚡ Adds a util file for easier language adding
This commit is contained in:
parent
55aeb44c1a
commit
c8a73dbda6
12
src/main.js
12
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,
|
||||
});
|
||||
|
||||
|
|
|
@ -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;
|
Loading…
Reference in New Issue