Sélecteur de langue : regroupement par continent, Afrique en tête #6
+65
-17
@@ -88,15 +88,34 @@ const LANG_NAMES = {
|
|||||||
pt: 'Português', ja: '日本語', ko: '한국어',
|
pt: 'Português', ja: '日本語', ko: '한국어',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CONTINENTS = ['Afrique', 'Asie', 'Europe']
|
||||||
|
|
||||||
const TRAD_FIELDS = [
|
const TRAD_FIELDS = [
|
||||||
{field: 'japonais', title: '日本語'},
|
// Afrique — langues vedettes en premier
|
||||||
{field: 'coreen', title: '한국어'},
|
{field: 'yoruba', title: 'Yorùbá', continent: 'Afrique'},
|
||||||
{field: 'anglais', title: 'English'},
|
{field: 'lingala', title: 'Lingála', continent: 'Afrique'},
|
||||||
{field: 'francais', title: 'Français'},
|
{field: 'wolof', title: 'Wolof', continent: 'Afrique'},
|
||||||
{field: 'espagnol', title: 'Español'},
|
{field: 'swahili', title: 'Kiswahili', continent: 'Afrique'},
|
||||||
{field: 'allemand', title: 'Deutsch'},
|
{field: 'hausa', title: 'Hausa', continent: 'Afrique'},
|
||||||
{field: 'italien', title: 'Italiano'},
|
{field: 'arabe', title: 'العربية', continent: 'Afrique'},
|
||||||
{field: 'portugais', title: 'Português'},
|
{field: 'oromo', title: 'Oromoo', continent: 'Afrique'},
|
||||||
|
{field: 'igbo', title: 'Igbo', continent: 'Afrique'},
|
||||||
|
{field: 'zoulou', title: 'isiZulu', continent: 'Afrique'},
|
||||||
|
{field: 'malgache', title: 'Malagasy', continent: 'Afrique'},
|
||||||
|
{field: 'xhosa', title: 'isiXhosa', continent: 'Afrique'},
|
||||||
|
{field: 'tswana', title: 'Setswana', continent: 'Afrique'},
|
||||||
|
{field: 'tsonga', title: 'Xitsonga', continent: 'Afrique'},
|
||||||
|
{field: 'sesotho', title: 'Sesotho', continent: 'Afrique'},
|
||||||
|
// Asie
|
||||||
|
{field: 'japonais', title: '日本語', continent: 'Asie'},
|
||||||
|
{field: 'coreen', title: '한국어', continent: 'Asie'},
|
||||||
|
// Europe
|
||||||
|
{field: 'anglais', title: 'English', continent: 'Europe'},
|
||||||
|
{field: 'francais', title: 'Français', continent: 'Europe'},
|
||||||
|
{field: 'espagnol', title: 'Español', continent: 'Europe'},
|
||||||
|
{field: 'allemand', title: 'Deutsch', continent: 'Europe'},
|
||||||
|
{field: 'italien', title: 'Italiano', continent: 'Europe'},
|
||||||
|
{field: 'portugais', title: 'Português', continent: 'Europe'},
|
||||||
]
|
]
|
||||||
|
|
||||||
const langToArray = parole => {
|
const langToArray = parole => {
|
||||||
@@ -106,10 +125,13 @@ const langToArray = parole => {
|
|||||||
|
|
||||||
return TRAD_FIELDS
|
return TRAD_FIELDS
|
||||||
.filter(({field}) => parole.traductions[field])
|
.filter(({field}) => parole.traductions[field])
|
||||||
.map(({field, title}) => ({field, title, lang: parole.traductions[field]}))
|
.map(({field, title, continent}) => ({field, title, continent, lang: parole.traductions[field]}))
|
||||||
}
|
}
|
||||||
|
|
||||||
const BROWSER_LANG_TO_FIELD = {
|
const BROWSER_LANG_TO_FIELD = {
|
||||||
|
yo: 'yoruba', ln: 'lingala', wo: 'wolof', sw: 'swahili', ha: 'hausa',
|
||||||
|
ar: 'arabe', om: 'oromo', ig: 'igbo', zu: 'zoulou', mg: 'malgache',
|
||||||
|
xh: 'xhosa', tn: 'tswana', ts: 'tsonga', st: 'sesotho',
|
||||||
ja: 'japonais', ko: 'coreen', en: 'anglais', fr: 'francais',
|
ja: 'japonais', ko: 'coreen', en: 'anglais', fr: 'francais',
|
||||||
es: 'espagnol', de: 'allemand', it: 'italien', pt: 'portugais',
|
es: 'espagnol', de: 'allemand', it: 'italien', pt: 'portugais',
|
||||||
}
|
}
|
||||||
@@ -123,7 +145,6 @@ export default function Teks({parole}) {
|
|||||||
const coverFmt = formatKuveti(parole.couverture)
|
const coverFmt = formatKuveti(parole.couverture)
|
||||||
const [tab, setTab] = useState(0)
|
const [tab, setTab] = useState(0)
|
||||||
const [, setCurrentTrack] = useCurrentTrack()
|
const [, setCurrentTrack] = useCurrentTrack()
|
||||||
const options = ['Transcription', ...langArray.map(({title}) => title)]
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const isBrowser = () => typeof window !== 'undefined'
|
const isBrowser = () => typeof window !== 'undefined'
|
||||||
@@ -247,19 +268,46 @@ export default function Teks({parole}) {
|
|||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{maxWidth: 700, margin: '0 auto'}} className={classes.gridText}>
|
<Box sx={{maxWidth: 700, margin: '0 auto'}} className={classes.gridText}>
|
||||||
<Box sx={{display: 'flex', flexWrap: 'wrap', justifyContent: 'center', gap: 1, borderBottom: 1, borderColor: 'divider', mb: 2, pb: 2}}>
|
<Box sx={{display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 1.5, borderBottom: 1, borderColor: 'divider', mb: 2, pb: 2}}>
|
||||||
{options.map((label, index) => (
|
|
||||||
<Chip
|
<Chip
|
||||||
key={label}
|
|
||||||
clickable
|
clickable
|
||||||
color='primary'
|
color='primary'
|
||||||
label={label}
|
label='Transcription'
|
||||||
sx={{fontWeight: tab === index ? 600 : 400}}
|
sx={{fontWeight: tab === 0 ? 600 : 400}}
|
||||||
variant={tab === index ? 'filled' : 'outlined'}
|
variant={tab === 0 ? 'filled' : 'outlined'}
|
||||||
onClick={() => setTab(index)}
|
onClick={() => setTab(0)}
|
||||||
|
/>
|
||||||
|
{CONTINENTS.map(continent => {
|
||||||
|
const items = langArray
|
||||||
|
.map((item, index) => ({...item, index}))
|
||||||
|
.filter(item => item.continent === continent)
|
||||||
|
|
||||||
|
if (items.length === 0) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box key={continent} sx={{display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 0.5}}>
|
||||||
|
<Typography variant='caption' color='text.secondary' sx={{textTransform: 'uppercase', letterSpacing: 1}}>
|
||||||
|
{continent}
|
||||||
|
</Typography>
|
||||||
|
<Box sx={{display: 'flex', flexWrap: 'wrap', justifyContent: 'center', gap: 1}}>
|
||||||
|
{items.map(({title, index}) => (
|
||||||
|
<Chip
|
||||||
|
key={title}
|
||||||
|
clickable
|
||||||
|
color='primary'
|
||||||
|
label={title}
|
||||||
|
sx={{fontWeight: tab === index + 1 ? 600 : 400}}
|
||||||
|
variant={tab === index + 1 ? 'filled' : 'outlined'}
|
||||||
|
onClick={() => setTab(index + 1)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</Box>
|
||||||
{tab === 0 && (
|
{tab === 0 && (
|
||||||
<>
|
<>
|
||||||
{parole.langueSource && parole.langueSource !== 'ka' && (
|
{parole.langueSource && parole.langueSource !== 'ka' && (
|
||||||
|
|||||||
Reference in New Issue
Block a user