Skip to content

Commit

Permalink
Traduction en-fr des composants de l'éditeur (#963)
Browse files Browse the repository at this point in the history
  • Loading branch information
RochDLY committed Nov 24, 2023
1 parent a79ce74 commit 0fb8b00
Show file tree
Hide file tree
Showing 18 changed files with 210 additions and 74 deletions.
4 changes: 3 additions & 1 deletion front/src/components/Write/ArticleEditorMenu.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useCallback } from 'react'
import { shallowEqual, useDispatch, useSelector } from 'react-redux'
import { useTranslation } from 'react-i18next'

import styles from './articleEditorMenu.module.scss'
import Stats from './Stats'
Expand All @@ -13,11 +14,12 @@ export default function ArticleEditorMenu ({ articleInfos, readOnly, compareTo,
const articleStats = useSelector(state => state.articleStats, shallowEqual)
const dispatch = useDispatch()
const toggleExpand = useCallback(() => dispatch({ type: 'ARTICLE_PREFERENCES_TOGGLE', key: 'expandSidebarLeft' }), [])
const { t } = useTranslation()

return (
<nav className={`${expanded ? styles.expandleft : styles.retractleft}`}>
<button onClick={toggleExpand} className={expanded ? styles.close : styles.open}>
<Sidebar /> {expanded ? 'close' : 'Bibliography & co'}
<Sidebar /> {expanded ? t('write.sidebar.closeButton') : t('write.sidebar.biblioAndCoButton')}
</button>
{expanded && (<div>
<Versions
Expand Down
10 changes: 6 additions & 4 deletions front/src/components/Write/ArticleEditorMetadata.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useCallback, useState } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import PropTypes from 'prop-types'
import { useTranslation } from 'react-i18next'

import styles from './articleEditorMetadata.module.scss'
import YamlEditor from './yamleditor/YamlEditor'
Expand All @@ -10,6 +11,7 @@ import MonacoYamlEditor from './providers/monaco/YamlEditor'
import { Sidebar } from 'react-feather'

export default function ArticleEditorMetadata({ handleYaml, readOnly, yaml }) {
const { t } = useTranslation()
const dispatch = useDispatch()
const expanded = useSelector(
(state) => state.articlePreferences.expandSidebarRight
Expand Down Expand Up @@ -57,7 +59,7 @@ export default function ArticleEditorMetadata({ handleYaml, readOnly, yaml }) {
onClick={toggleExpand}
className={expanded ? styles.close : styles.open}
>
<Sidebar /> {expanded ? 'close' : 'Metadata'}
<Sidebar /> {expanded ? t('write.sidebar.closeButton') : t('write.sidebar.metadataButton')}
</button>
{expanded && (
<div className={styles.yamlEditor}>
Expand All @@ -67,15 +69,15 @@ export default function ArticleEditorMetadata({ handleYaml, readOnly, yaml }) {
items={[
{
value: 'basic',
name: 'Basic Mode',
name: t('write.basicMode.metadataButton'),
},
{
value: 'editor',
name: 'Editor Mode',
name: t('write.editorMode.metadataButton'),
},
{
value: 'raw',
name: 'Raw Mode',
name: t('write.rawMode.metadataButton'),
},
]}
/>
Expand Down
8 changes: 5 additions & 3 deletions front/src/components/Write/Biblio.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState, useCallback } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { useTranslation } from 'react-i18next'

import { ChevronDown, ChevronRight } from 'react-feather'

Expand All @@ -23,17 +24,18 @@ function Biblio ({ article, readOnly }) {
setModal(true)
}, [])
const closeModal = useCallback(() => setModal(false), [])
const { t } = useTranslation()

return (
<section className={[menuStyles.section, styles.section].join(' ')}>
<h1 onClick={toggleExpand}>
{expand ? <ChevronDown/> : <ChevronRight/>} Bibliography
{expand ? <ChevronDown/> : <ChevronRight/>} {t('write.sidebar.biblioTitle')}

<Button className={styles.headingAction} small={true} disabled={readOnly} onClick={openModal}>Manage</Button>
<Button className={styles.headingAction} small={true} disabled={readOnly} onClick={openModal}>{t('write.sidebar.manageButton')}</Button>
</h1>
{expand && <ReferenceList />}
{modal && (
<Modal title="Bibliography Manager" cancel={closeModal}>
<Modal title={t('write.biblioModal.title')} cancel={closeModal}>
<Bibliographe cancel={closeModal} article={article} />
</Modal>
)}
Expand Down
12 changes: 7 additions & 5 deletions front/src/components/Write/CreateVersion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Link } from 'react-router-dom'
import { useDispatch, useSelector } from 'react-redux'
import { ArrowLeft } from 'react-feather'
import { createVersion } from '../../services/ArticleService.graphql'
import { useTranslation } from 'react-i18next'

import { useMutation } from '../../hooks/graphql.js'

Expand All @@ -14,6 +15,7 @@ import Button from '../Button'
import Field from '../Field'

const CreateVersion = ({ articleId, readOnly, onClose }) => {
const { t } = useTranslation()
const { setToast } = useToasts()
const mutation = useMutation()
const activeUser = useSelector(state => state.activeUser)
Expand All @@ -33,7 +35,7 @@ const CreateVersion = ({ articleId, readOnly, onClose }) => {
})
dispatch({ type: 'SET_ARTICLE_VERSIONS', versions: response.article.createVersion.versions })
setToast({
text: `Nouvelle version créée.`,
text: t('write.createVersion.defaultNotification'),
type: 'default',
})
} catch (err) {
Expand All @@ -56,25 +58,25 @@ const CreateVersion = ({ articleId, readOnly, onClose }) => {
>
<Field
className={styles.createVersionInput}
placeholder="Label of the version (optional)"
placeholder={t('write.createVersion.placeholder')}
value={message}
autoFocus={true}
onChange={(e) => setMessage(e.target.value)}
/>
<ul className={styles.actions}>
<li className={styles.closeButton}>
<Button icon={true} onClick={onClose}>
Close
{t('write.sidebar.closeButton')}
</Button>
</li>
<li>
<Button primary={true}>
Create Minor
{t('write.createMinorVersion.Button')}
</Button>
</li>
<li>
<Button onClick={(e) => handleCreateVersion(e, true)}>
Create Major
{t('write.createMajorVersion.Button')}
</Button>
</li>
</ul>
Expand Down
5 changes: 4 additions & 1 deletion front/src/components/Write/Reference.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { memo } from 'react'
import { CopyToClipboard } from 'react-copy-to-clipboard'
import { useTranslation } from 'react-i18next'

import { Clipboard } from 'react-feather'
import styles from './reference.module.scss'
Expand All @@ -8,6 +9,8 @@ import Button from '../Button'

const BibliographyReference = memo(function BibliographyReference ({ entry }) {
const { key, title, type, date, authorName } = entry
const { t } = useTranslation()

return (
<div
className={styles.reference}
Expand All @@ -24,7 +27,7 @@ const BibliographyReference = memo(function BibliographyReference ({ entry }) {
</p>
</div>
<CopyToClipboard text={`[@${key}]`}>
<Button title="Copy to clipboard" className={styles.copyToClipboard} icon={true}><Clipboard/></Button>
<Button title={t('write.copyClipboard.referenceButton')} className={styles.copyToClipboard} icon={true}><Clipboard/></Button>
</CopyToClipboard>
</div>
)
Expand Down
6 changes: 4 additions & 2 deletions front/src/components/Write/ReferenceList.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useCallback, useState } from 'react'
import { shallowEqual, useSelector } from 'react-redux'
import { Search } from 'react-feather'
import { useTranslation } from 'react-i18next'

import Reference from './Reference'
import styles from './ReferenceList.module.scss'
Expand All @@ -23,16 +24,17 @@ export default function ReferenceList() {
}
}
const handleShowAll = useCallback(() => setShowAll(true), [])
const { t } = useTranslation()
return (
<>
<Field className={styles.searchField} type="text" icon={Search} value={filter} placeholder="Search" onChange={(e) => setFilter(e.target.value)} />
<Field className={styles.searchField} type="text" icon={Search} value={filter} placeholder={t('write.searchFieldBiblio.placeholder')} onChange={(e) => setFilter(e.target.value)} />
{filter && <span className={styles.resultFoundCount}>{bibTeXFound.length} found</span>}
{bibTeXFound
.map((entry, index) => (
<Reference key={`ref-${entry.key}-${index}`} entry={entry} />
))
}
{!showAll && bibliographyEntries.length > 25 && <Button className={styles.showAll} onClick={handleShowAll}>Show all {bibliographyEntries.length} references</Button>}
{!showAll && bibliographyEntries.length > 25 && <Button className={styles.showAll} onClick={handleShowAll}>{t('write.showBiblio.button')} {bibliographyEntries.length} references</Button>}
</>
)
}
4 changes: 3 additions & 1 deletion front/src/components/Write/Sommaire.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useCallback } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { useRouteMatch } from 'react-router-dom'
import { ChevronDown, ChevronRight } from 'react-feather'
import { useTranslation } from 'react-i18next'
import { usePandocAnchoring } from '../../hooks/pandoc.js'

import styles from './sommaire.module.scss'
Expand All @@ -21,11 +22,12 @@ export default function Sommaire () {
? document.querySelector(`#${target.dataset.headingAnchor}`)?.scrollIntoView()
: dispatch({ type: 'UPDATE_EDITOR_CURSOR_POSITION', lineNumber: parseInt(target.dataset.index, 10), column: 0 })
},[hasHtmlAnchors])
const { t } = useTranslation()

return (
<section className={[styles.section, menuStyles.section].join(' ')}>
<h1 onClick={toggleExpand}>
{expand ? <ChevronDown/> : <ChevronRight/>} Table of contents
{expand ? <ChevronDown/> : <ChevronRight/>} {t('write.titleToc.sidebar')}
</h1>
{expand && (<ul>
{articleStructure.map((item) => (
Expand Down
10 changes: 6 additions & 4 deletions front/src/components/Write/Stats.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React, { useCallback } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { ChevronDown, ChevronRight } from 'react-feather'
import { useTranslation } from 'react-i18next'

import menuStyles from './menu.module.scss'

export default function WriteStats ({ stats }) {
const expand = useSelector(state => state.articlePreferences.expandStats)
const dispatch = useDispatch()
const toggleExpand = useCallback(() => dispatch({ type: 'ARTICLE_PREFERENCES_TOGGLE', key: 'expandStats' }), [])
const { t } = useTranslation()

return (
<section className={menuStyles.section}>
Expand All @@ -16,10 +18,10 @@ export default function WriteStats ({ stats }) {
</h1>
{expand && (
<>
<p>Words : {stats.wordCount}</p>
<p>Characters : {stats.charCountNoSpace}</p>
<p>Characters (with spaces) : {stats.charCountPlusSpace}</p>
<p>Citations : {stats.citationNb}</p>
<p>{t('write.wordCountStat.text', {stats: stats.wordCount})}</p>
<p>{t('write.charCountNoSpaceStat.text', {stats: stats.charCountNoSpace})}</p>
<p>{t('write.charCountPlusSpaceStat.text', {stats: stats.charCountPlusSpace})}</p>
<p>{t('write.citationsStat.text', {stats: stats.citationNb})}</p>
</>
)}
</section>
Expand Down
19 changes: 10 additions & 9 deletions front/src/components/Write/Versions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ function Version ({ articleId, compareTo, readOnly, selectedVersion, v }) {
<Field autoFocus={true} type="text" value={title} onChange={(event) => setTitle(event.target.value)}
placeholder={'Label of the version'}/>
<div className={styles.actions}>
<Button title="Save" primary={true}>
<Check/> Save
<Button title={t('write.saveVersionName.buttonTitle')} primary={true}>
<Check/> {t('write.saveVersionName.buttonText')}
</Button>
<Button title="Cancel" type="button" onClick={cancelRenaming}>
Cancel
<Button title={t('write.cancelVersionName.buttonTitle')} type="button" onClick={cancelRenaming}>
{t('write.cancelVersionName.buttonText')}
</Button>
</div>
</form>
Expand All @@ -76,7 +76,7 @@ function Version ({ articleId, compareTo, readOnly, selectedVersion, v }) {
<span className={styles.versionLabel}>
v{v.version}.{v.revision}{' '}{title || ''}
</span>
{!readOnly && <Button title="Edit" icon={true} className={styles.editTitleButton} onClick={startRenaming}>
{!readOnly && <Button title={t('write.editVersionName.buttonTitle')} icon={true} className={styles.editTitleButton} onClick={startRenaming}>
<Edit3 size="20"/>
</Button>}
</header>}
Expand All @@ -99,7 +99,7 @@ function Version ({ articleId, compareTo, readOnly, selectedVersion, v }) {
className={clsx(buttonStyles.button, buttonStyles.secondary, styles.action)}
to={compareLink}
>
Compare
{t('write.compareVersion.button')}
</Link>
</li>
)}
Expand All @@ -109,7 +109,7 @@ function Version ({ articleId, compareTo, readOnly, selectedVersion, v }) {
className={clsx(buttonStyles.button, buttonStyles.secondary, styles.action)}
to={`/article/${articleId}/${versionPart}`}
>
Stop
{t('write.stopCompareVersion.button')}
</Link>
</li>
)}
Expand Down Expand Up @@ -140,15 +140,16 @@ export default function Versions ({ article, selectedVersion, compareTo, readOnl
setExpandCreateForm(true)
}, [])
const cancelExport = useCallback(() => setExportParams({}), [])
const { t } = useTranslation()

return (
<section className={clsx(menuStyles.section)}>
<h1 className={expand ? null : styles.closed} onClick={toggleExpand}>
{expand ? <ChevronDown/> : <ChevronRight/>}
Versions
{t('write.titleVersion.sidebar')}

{!readOnly && <Button className={styles.headingAction} small={true} disabled={readOnly} onClick={createNewVersion}>
New Version
{t('write.newVersion.button')}
</Button>}
{readOnly && <Link className={clsx(buttonStyles.button, buttonStyles.secondary, styles.editMode, styles.headingAction)} to={`/article/${article._id}`}> <ArrowLeft/> Edit Mode</Link>}
</h1>
Expand Down
Loading

0 comments on commit 0fb8b00

Please sign in to comment.