2020-10-23 13:40:39 +02:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
// See LICENSE.txt for license information.
|
|
|
|
|
2021-09-06 14:17:33 +02:00
|
|
|
import messages_ca from '../i18n/ca.json'
|
|
|
|
import messages_de from '../i18n/de.json'
|
|
|
|
import messages_el from '../i18n/el.json'
|
2020-10-23 13:40:39 +02:00
|
|
|
import messages_en from '../i18n/en.json'
|
|
|
|
import messages_es from '../i18n/es.json'
|
2021-03-19 23:07:53 +01:00
|
|
|
import messages_fr from '../i18n/fr.json'
|
2021-09-06 14:17:33 +02:00
|
|
|
import messages_id from '../i18n/id.json'
|
|
|
|
import messages_it from '../i18n/it.json'
|
|
|
|
import messages_ja from '../i18n/ja.json'
|
2021-03-21 19:47:47 +01:00
|
|
|
import messages_nl from '../i18n/nl.json'
|
2021-03-25 19:46:59 +01:00
|
|
|
import messages_oc from '../i18n/oc.json'
|
2021-09-06 14:17:33 +02:00
|
|
|
import messages_ptBr from '../i18n/pt_BR.json'
|
|
|
|
import messages_ru from '../i18n/ru.json'
|
|
|
|
import messages_sv from '../i18n/sv.json'
|
2021-03-25 19:46:59 +01:00
|
|
|
import messages_tr from '../i18n/tr.json'
|
2021-04-30 12:25:14 +02:00
|
|
|
import messages_zhHans from '../i18n/zh_Hans.json'
|
2021-09-06 14:17:33 +02:00
|
|
|
import messages_zhHant from '../i18n/zh_Hant.json'
|
2021-04-30 12:25:14 +02:00
|
|
|
|
2021-08-15 12:51:19 +02:00
|
|
|
import {UserSettings} from './userSettings'
|
|
|
|
|
2021-09-06 14:17:33 +02:00
|
|
|
const supportedLanguages = ['ca', 'de', 'el', 'en', 'es', 'fr', 'id', 'it', 'ja', 'nl', 'oc', 'pt-br', 'ru', 'sv', 'tr', 'zh-cn', 'zh-tw']
|
2021-03-25 19:46:59 +01:00
|
|
|
|
2020-10-23 13:40:39 +02:00
|
|
|
export function getMessages(lang: string): {[key: string]: string} {
|
|
|
|
switch (lang) {
|
2021-09-06 14:17:33 +02:00
|
|
|
case 'ca':
|
|
|
|
return messages_ca
|
2021-03-19 16:10:28 +01:00
|
|
|
case 'de':
|
|
|
|
return messages_de
|
2021-09-06 14:17:33 +02:00
|
|
|
case 'el':
|
|
|
|
return messages_el
|
|
|
|
case 'es':
|
|
|
|
return messages_es
|
2021-03-19 23:07:53 +01:00
|
|
|
case 'fr':
|
|
|
|
return messages_fr
|
2021-09-06 14:17:33 +02:00
|
|
|
case 'id':
|
|
|
|
return messages_id
|
|
|
|
case 'it':
|
|
|
|
return messages_it
|
2021-03-19 16:10:28 +01:00
|
|
|
case 'ja':
|
|
|
|
return messages_ja
|
2021-03-21 19:47:47 +01:00
|
|
|
case 'nl':
|
|
|
|
return messages_nl
|
2021-03-25 19:46:59 +01:00
|
|
|
case 'oc':
|
|
|
|
return messages_oc
|
2021-09-06 14:17:33 +02:00
|
|
|
case 'pt-br':
|
|
|
|
return messages_ptBr
|
|
|
|
case 'ru':
|
|
|
|
return messages_ru
|
|
|
|
case 'sv':
|
|
|
|
return messages_sv
|
2021-03-25 19:46:59 +01:00
|
|
|
case 'tr':
|
|
|
|
return messages_tr
|
2021-06-21 11:51:11 +02:00
|
|
|
case 'zh-cn':
|
2021-03-25 19:46:59 +01:00
|
|
|
return messages_zhHant
|
2021-08-11 16:58:10 +02:00
|
|
|
case 'zh-tx':
|
|
|
|
return messages_zhHans
|
2021-06-21 11:51:11 +02:00
|
|
|
case 'zh-tw':
|
2021-04-30 12:25:14 +02:00
|
|
|
return messages_zhHans
|
2020-10-23 13:40:39 +02:00
|
|
|
}
|
|
|
|
return messages_en
|
|
|
|
}
|
|
|
|
export function getCurrentLanguage(): string {
|
2021-08-15 12:51:19 +02:00
|
|
|
let lang = UserSettings.language
|
2020-10-23 13:40:39 +02:00
|
|
|
if (!lang) {
|
2021-04-30 12:25:14 +02:00
|
|
|
if (supportedLanguages.includes(navigator.language)) {
|
|
|
|
lang = navigator.language
|
|
|
|
} else if (supportedLanguages.includes(navigator.language.split(/[-_]/)[0])) {
|
|
|
|
lang = navigator.language.split(/[-_]/)[0]
|
|
|
|
} else {
|
|
|
|
lang = 'en'
|
|
|
|
}
|
2020-10-23 13:40:39 +02:00
|
|
|
}
|
|
|
|
return lang
|
|
|
|
}
|
|
|
|
|
|
|
|
export function storeLanguage(lang: string): void {
|
2021-08-15 12:51:19 +02:00
|
|
|
UserSettings.language = lang
|
2020-10-23 13:40:39 +02:00
|
|
|
}
|