Files
overleaf-cep/services/web/frontend/js/features/template/components/settings/settings-language.tsx
T
yu-i-i 9cc9997ba5 Refactor Template Gallery; resolves #38 and #39
- Replace free-text license input with a select box
- Improve visual presentation of modals and enhance keyboard interaction
2025-11-12 02:00:03 +01:00

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"
/>
)
}