mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-10 14:40:47 +02:00
9cc9997ba5
- Replace free-text license input with a select box - Improve visual presentation of modals and enhance keyboard interaction
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { useMemo } from 'react'
|
|
import { useTranslation } from 'react-i18next'
|
|
import getMeta from '../../../../utils/meta'
|
|
import SettingsMenuSelect from './settings-menu-select'
|
|
import type { Optgroup } from './settings-menu-select'
|
|
|
|
interface SettingsLanguageProps {
|
|
value: string
|
|
onChange: (value: string) => void
|
|
}
|
|
|
|
export default function SettingsLanguage({
|
|
value,
|
|
onChange,
|
|
}: SettingsLanguageProps) {
|
|
const { t } = useTranslation()
|
|
|
|
const optgroup: Optgroup = useMemo(() => {
|
|
const options = (getMeta('ol-languages') ?? [])
|
|
// only include spell-check languages that are available in the client
|
|
.filter(language => language.dic !== undefined)
|
|
|
|
return {
|
|
label: 'Language',
|
|
options: options.map(language => ({
|
|
value: language.code,
|
|
label: language.name,
|
|
})),
|
|
}
|
|
}, [])
|
|
|
|
return (
|
|
<SettingsMenuSelect
|
|
onChange={onChange}
|
|
value={value}
|
|
options={[{ value: '', label: t('off') }]}
|
|
optgroup={optgroup}
|
|
label={t('spell_check')}
|
|
name="spellCheckLanguage"
|
|
/>
|
|
)
|
|
}
|