Refactor i18n functions a bit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
// React Hook to get a list of all languages available. English is hardcoded
|
||||
import { useGetList } from 'react-admin'
|
||||
|
||||
export default () => {
|
||||
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 }
|
||||
}
|
||||
Reference in New Issue
Block a user