Skip to content

Commit

Permalink
Merge pull request #585 from Adamant-im/feat/env-default-locale
Browse files Browse the repository at this point in the history
feat(i18n): configure default locale using ENV
  • Loading branch information
bludnic authored Jan 15, 2024
2 parents edd4e6f + c89146b commit 010a3aa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VUE_APP_I18N_LOCALE=en
VUE_APP_I18N_FALLBACK_LOCALE=en
VITE_I18N_LOCALE=en
VITE_I18N_FALLBACK_LOCALE=en
7 changes: 5 additions & 2 deletions src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ function loadLocaleMessages() {
}
}

export const DEFAULT_LOCALE = import.meta.env.VITE_I18N_LOCALE || 'en'
export const FALLBACK_LOCALE = import.meta.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en'

export const i18n = createI18n({
locale: import.meta.env.VUE_APP_I18N_LOCALE || 'en',
fallbackLocale: import.meta.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en',
locale: DEFAULT_LOCALE,
fallbackLocale: FALLBACK_LOCALE,
messages: loadLocaleMessages(),
fallbackRoot: true,
pluralizationRules: {
Expand Down
4 changes: 2 additions & 2 deletions src/store/modules/language/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import dayjs from 'dayjs'
import { i18n } from '@/i18n'
import { i18n, DEFAULT_LOCALE } from '@/i18n'

const locales = ['de', 'en', 'ru', 'zh']

const state = () => ({
currentLocale: 'en'
currentLocale: DEFAULT_LOCALE
})

const mutations = {
Expand Down

0 comments on commit 010a3aa

Please sign in to comment.