Files
navidrome/ui/src/personal/SelectLanguage.jsx
T
Deluan Quintão fcdd30ba8f build(ui): migrate from CRA/Jest to Vite/Vitest (#3311)
* feat: create vite project

* feat: it's alive!

* feat: `make dev` working!

* feat: replace custom serviceWorker with vite plugin

* test: replace Jest with Vitest

* fix: run prettier

* fix: skip eslint for now.

* chore: remove ui.old folder

* refactor: replace lodash.pick with simple destructuring

* fix: eslint errors (wip)

* fix: eslint errors (wip)

* fix: display-name eslint errors (wip)

* fix: no-console eslint errors (wip)

* fix: react-refresh/only-export-components eslint errors (wip)

* fix: react-refresh/only-export-components eslint errors (wip)

* fix: react-refresh/only-export-components eslint errors (wip)

* fix: react-refresh/only-export-components eslint errors (wip)

* fix: build

* fix: pwa manifest

* refactor: pwa manifest

* refactor: simplify PORT configuration

* refactor: rename simple JS files

* test: cover playlistUtils

* fix: react-image-lightbox

* feat(ui): add sourcemaps to help debug issues
2024-09-28 11:54:36 -04:00

40 lines
1.1 KiB
React

import { SelectInput, useLocale, useSetLocale, useTranslate } from 'react-admin'
import { useGetLanguageChoices } from '../i18n'
import { HelpMsg } from './HelpMsg'
import { docsUrl, openInNewTab } from '../utils'
const helpKey = '_help'
export const SelectLanguage = (props) => {
const translate = useTranslate()
const setLocale = useSetLocale()
const locale = useLocale()
const { choices } = useGetLanguageChoices()
choices.push({
id: helpKey,
name: <HelpMsg caption={'Help to translate'} />,
})
return (
<SelectInput
{...props}
source="language"
label={translate('menu.personal.options.language')}
defaultValue={locale}
choices={choices}
translateChoice={false}
onChange={(event) => {
if (event.target.value === helpKey) {
openInNewTab(docsUrl('/docs/developers/translations/'))
return
}
setLocale(event.target.value).then(() => {
localStorage.setItem('locale', event.target.value)
document.documentElement.lang = event.target.value
})
}}
/>
)
}