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 registerServiceWorker from '@/registerServiceWorker';
|
||||||
import clickOutside from '@/utils/ClickOutside';
|
import clickOutside from '@/utils/ClickOutside';
|
||||||
import { toastedOptions } from '@/utils/defaults';
|
import { toastedOptions } from '@/utils/defaults';
|
||||||
|
import { messages } from '@/utils/languages';
|
||||||
// Locales - Import translation files here!
|
|
||||||
import en from '@/assets/locales/en-GB.json';
|
|
||||||
|
|
||||||
Vue.use(VueI18n);
|
Vue.use(VueI18n);
|
||||||
Vue.use(VTooltip);
|
Vue.use(VTooltip);
|
||||||
|
@ -29,12 +27,10 @@ Vue.directive('clickOutside', clickOutside);
|
||||||
|
|
||||||
Vue.config.productionTip = false;
|
Vue.config.productionTip = false;
|
||||||
|
|
||||||
// Setup translations
|
// Setup i18n translations
|
||||||
const messages = { en }; // <-- Add new language files here!
|
|
||||||
|
|
||||||
const i18n = new VueI18n({
|
const i18n = new VueI18n({
|
||||||
locale: 'en',
|
locale: 'en-GB',
|
||||||
fallbackLocale: 'en',
|
fallbackLocale: 'en-GB',
|
||||||
messages,
|
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