mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 03:06:31 -05:00
Add function for language code shortening (#156)
Add function for language code shortening
This commit is contained in:
parent
1c2dd630d9
commit
a376c95fab
1 changed files with 12 additions and 3 deletions
|
@ -1,7 +1,7 @@
|
|||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import moment from 'moment'
|
||||
import React from 'react'
|
||||
import { Form } from 'react-bootstrap'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
const LanguagePicker: React.FC = () => {
|
||||
const { i18n } = useTranslation()
|
||||
|
@ -11,12 +11,21 @@ const LanguagePicker: React.FC = () => {
|
|||
await i18n.changeLanguage(event.currentTarget.value)
|
||||
}
|
||||
|
||||
const shortenLanguageCode = (language: string): string => {
|
||||
const languageWithoutArea = language.substr(0, 2)
|
||||
if (languageWithoutArea === 'zh') {
|
||||
return language
|
||||
} else {
|
||||
return languageWithoutArea
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Form.Control
|
||||
as="select"
|
||||
size="sm"
|
||||
className="mb-2 mx-auto w-auto"
|
||||
value={i18n.language}
|
||||
value={shortenLanguageCode(i18n.language)}
|
||||
onChange={onChangeLang}
|
||||
>
|
||||
<option value="en">English</option>
|
||||
|
|
Loading…
Reference in a new issue