Languages management in teks
This commit is contained in:
@@ -71,10 +71,10 @@ const useStyles = makeStyles(theme => ({
|
||||
marginBottom: '0.5em'
|
||||
},
|
||||
gridText: {
|
||||
border: '1px dashed grey',
|
||||
border: '2px solid grey',
|
||||
borderRadius: '5px',
|
||||
marginTop: '2em',
|
||||
marginInline: '2px'
|
||||
padding: '1em'
|
||||
},
|
||||
grid: {
|
||||
marginTop: '1em'
|
||||
@@ -101,7 +101,30 @@ const formatJsonString = stringToFormat => {
|
||||
return stringToFormat.split('\n').map((string, index) => <div key={index}>{`${string}`}<br /></div>) // eslint-disable-line react/no-array-index-key
|
||||
}
|
||||
|
||||
const langToArray = anTeks => {
|
||||
const langArray = []
|
||||
|
||||
if (anTeks && anTeks.tradiksyon) {
|
||||
const {francais, english, espagnol} = anTeks.tradiksyon
|
||||
|
||||
if (francais) {
|
||||
langArray.push({title: 'Traduction', emoji: '🇫🇷', lang: francais})
|
||||
}
|
||||
|
||||
if (english) {
|
||||
langArray.push({title: 'Translation', emoji: '🇬🇧', lang: english})
|
||||
}
|
||||
|
||||
if (espagnol) {
|
||||
langArray.push({title: 'Traducción', emoji: '🇪🇸', lang: espagnol})
|
||||
}
|
||||
}
|
||||
|
||||
return langArray
|
||||
}
|
||||
|
||||
export default function TeksDrawer({teks, anTeks}) {
|
||||
const langArray = langToArray(anTeks)
|
||||
const classes = useStyles()
|
||||
const theme = useTheme()
|
||||
const [esMobilOuve, meteEsMobilOuve] = useState(false)
|
||||
@@ -197,25 +220,29 @@ export default function TeksDrawer({teks, anTeks}) {
|
||||
{anTeks.okiMizikID && (
|
||||
<OkiMizik id={anTeks.okiMizikID} />
|
||||
)}
|
||||
<Grid container className={classes.grid} spacing={3}>
|
||||
<Grid item md className={classes.gridText}>
|
||||
<Grid container justify='center' spacing={1}>
|
||||
<Grid item xs={12} md={langArray.length > 0 ? 6 : null}>
|
||||
<div className={classes.gridText}>
|
||||
<Typography align='center' className={classes.text} variant='h4'>
|
||||
Transcription
|
||||
</Typography>
|
||||
<Typography paragraph align='justify' component='span'>
|
||||
<Typography paragraph align={langArray.length === 0 ? 'center' : 'justify'} component='span'>
|
||||
{formatJsonString(anTeks.transkripsyon)}
|
||||
</Typography>
|
||||
</div>
|
||||
</Grid>
|
||||
{anTeks.tradiksyon && (
|
||||
<Grid item md className={classes.gridText}>
|
||||
{langArray.map(({title, emoji, lang}) => (
|
||||
<Grid key={title} item xs={12} md={6}>
|
||||
<div className={classes.gridText}>
|
||||
<Typography align='center' className={classes.text} variant='h4'>
|
||||
Traduction
|
||||
<span dangerouslySetInnerHTML={{__html: emoji}} /> {title}
|
||||
</Typography>
|
||||
<Typography paragraph align='justify' component='span'>
|
||||
{formatJsonString(anTeks.tradiksyon.francais)}
|
||||
{formatJsonString(lang)}
|
||||
</Typography>
|
||||
</div>
|
||||
</Grid>
|
||||
)}
|
||||
))}
|
||||
</Grid>
|
||||
</>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user