focalboard/webapp/src/i18n.tsx

26 lines
646 B
TypeScript
Raw Normal View History

2020-10-23 13:40:39 +02:00
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import messages_en from '../i18n/en.json'
import messages_es from '../i18n/es.json'
export function getMessages(lang: string): {[key: string]: string} {
switch (lang) {
case 'es':
return messages_es
}
return messages_en
}
export function getCurrentLanguage(): string {
let lang = localStorage.getItem('language')
if (!lang) {
lang = navigator.language.split(/[-_]/)[0]
}
return lang
}
export function storeLanguage(lang: string): void {
localStorage.setItem('language', lang)
}