improve searchLanguage

main
Mike Fix 5 years ago
parent d43c5766cf
commit 8b5d766d1e

@ -9,12 +9,12 @@ import SpinnerWrapper from './SpinnerWrapper'
import WindowControls from './WindowControls' import WindowControls from './WindowControls'
import { import {
COLORS, COLORS,
LANGUAGES,
LANGUAGE_MODE_HASH, LANGUAGE_MODE_HASH,
LANGUAGE_NAME_HASH, LANGUAGE_NAME_HASH,
LANGUAGE_MIME_HASH, LANGUAGE_MIME_HASH,
DEFAULT_SETTINGS, DEFAULT_SETTINGS,
THEMES_HASH, THEMES_HASH
LANGUAGES
} from '../lib/constants' } from '../lib/constants'
const Watermark = dynamic(() => import('./svg/Watermark'), { const Watermark = dynamic(() => import('./svg/Watermark'), {
@ -22,11 +22,7 @@ const Watermark = dynamic(() => import('./svg/Watermark'), {
}) })
function searchLanguage(l) { function searchLanguage(l) {
const config = LANGUAGE_NAME_HASH[l] || LANGUAGE_MODE_HASH[l] || LANGUAGE_MIME_HASH[l] return LANGUAGE_NAME_HASH[l] || LANGUAGE_MODE_HASH[l] || LANGUAGE_MIME_HASH[l]
if (config) {
return config.mime || config.mode
}
} }
class Carbon extends React.PureComponent { class Carbon extends React.PureComponent {
@ -42,14 +38,14 @@ class Carbon extends React.PureComponent {
const languageMode = searchLanguage(detectedLanguage) const languageMode = searchLanguage(detectedLanguage)
if (languageMode) { if (languageMode) {
return languageMode return languageMode.mime || languageMode.mode
} }
} }
const languageMode = searchLanguage(language) const languageMode = searchLanguage(language)
if (languageMode) { if (languageMode) {
return languageMode return languageMode.mime || languageMode.mode
} }
return language return language

Loading…
Cancel
Save