Files
navidrome/ui/src/i18n/useGetLanguageChoices.js
Deluan Quintão 5631493cc4 Upgrade Web UI to Create-React-App 4 and React 17 (#1105)
* Upgrade to CRA 4.0.3

* Try to fix tests. No lucky

* Fix new ESLint errors

* Fix JS tests and remove unwanted dependency. (#1106)

* Fix tests

* Fix lint

* Remove React v16 workaround (fixed in v17)

* Force eslint to break on warnings

* Lint now needs to be called explicitly in the pipeline

Co-authored-by: Yash Jipkate <34203227+YashJipkate@users.noreply.github.com>
2021-05-25 09:58:06 -04:00

22 lines
576 B
JavaScript

// React Hook to get a list of all languages available. English is hardcoded
import { useGetList } from 'react-admin'
const useGetLanguageChoices = () => {
const { ids, data, loaded, loading } = useGetList(
'translation',
{ page: 1, perPage: -1 },
{ field: '', order: '' },
{}
)
const choices = [{ id: 'en', name: 'English' }]
if (loaded) {
ids.forEach((id) => choices.push({ id: id, name: data[id].name }))
}
choices.sort((a, b) => a.name.localeCompare(b.name))
return { choices, loaded, loading }
}
export default useGetLanguageChoices