Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame^] | 1 | import { createI18n } from 'vue-i18n'; |
Dixsie Wolmers | cbcd213 | 2020-01-30 20:58:37 -0600 | [diff] [blame] | 2 | |
Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame^] | 3 | import en_us from './locales/en-US.json'; |
| 4 | import ru_ru from './locales/ru-RU.json'; |
Dixsie Wolmers | cbcd213 | 2020-01-30 20:58:37 -0600 | [diff] [blame] | 5 | |
| 6 | function loadLocaleMessages() { |
Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame^] | 7 | const messages = { |
| 8 | 'en-US': en_us, |
| 9 | 'ru-RU': ru_ru, |
| 10 | }; |
Dixsie Wolmers | cbcd213 | 2020-01-30 20:58:37 -0600 | [diff] [blame] | 11 | return messages; |
| 12 | } |
| 13 | |
Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame^] | 14 | const i18n = createI18n({ |
Dixsie Wolmers | c85395f | 2020-02-26 13:22:12 -0600 | [diff] [blame] | 15 | // Get default locale from local storage |
Sukanya Pandey | 5ee04ef | 2020-03-19 10:23:23 +0530 | [diff] [blame] | 16 | locale: window.localStorage.getItem('storedLanguage'), |
Dixsie Wolmers | c85395f | 2020-02-26 13:22:12 -0600 | [diff] [blame] | 17 | // Locales that don't exist will fallback to English |
| 18 | fallbackLocale: 'en-US', |
| 19 | // Falling back to fallbackLocale generates two console warnings |
| 20 | // Silent fallback suppresses console warnings when using fallback |
| 21 | silentFallbackWarn: true, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 22 | messages: loadLocaleMessages(), |
Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame^] | 23 | globalInjection: false, |
| 24 | legacy: true, |
Dixsie Wolmers | cbcd213 | 2020-01-30 20:58:37 -0600 | [diff] [blame] | 25 | }); |
Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame^] | 26 | |
| 27 | export default i18n; |