Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traduction en-fr des composants de l'éditeur #963

Merged
merged 27 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1bc3ebc
init PR
RochDLY Nov 9, 2023
1ac955b
documentation : traduction interface ArticleEditorMenu.jsx - test pou…
RochDLY Nov 9, 2023
70ad9ac
interface en-fr: test dans ArticleEditorMetadata.jsx
RochDLY Nov 9, 2023
c9c5879
interface en-fr : correction du fichier translation.json (en)
RochDLY Nov 9, 2023
466f399
interface en-fr : Biblio.jsx (volet biblio dans la partie edition)
RochDLY Nov 9, 2023
1284ee6
interface en-fr : CreateVersion.jsx
RochDLY Nov 9, 2023
c48274e
interface en-fr: correction du translate.json fr pour les boutons de …
RochDLY Nov 9, 2023
e7243bb
interface en-fr : correction des clefs pour CreateVersion.jsx et ajou…
RochDLY Nov 9, 2023
c84face
interface en-fr : ajout de la librairie react en tete de ReferenceLis…
RochDLY Nov 9, 2023
821b0a7
interface en-fr : ajout des clefs dans Stats.jsx
RochDLY Nov 9, 2023
2f76fc0
interface en-fr : import librairie dans Stats.jsx
RochDLY Nov 9, 2023
3770fea
interface en-fr : correction syntaxe dans CreateVersion.jsx
RochDLY Nov 9, 2023
d8113cf
interface en-fr : modification de tout le composant bibliographe/
RochDLY Nov 9, 2023
2649f88
interface en-fr : tentative de résolution de declaration de la const …
RochDLY Nov 9, 2023
aeae2dc
interface en-fr : deuxieme tentative de resolution erreur dans Biblio…
RochDLY Nov 9, 2023
76503d4
interface en-fr : ajout de clef i18n dans l'interface d'édition pour …
RochDLY Nov 9, 2023
b96d686
interface en-fr : ajout de clefs pour Versions.jsx
RochDLY Nov 9, 2023
6a5120e
interface en-fr : ajout de const {t} dans la fonction Versions de Ver…
RochDLY Nov 9, 2023
b7eb5ed
interface en-fr : ajout de la traduction pour Sommaire.jsx
RochDLY Nov 9, 2023
f07c863
interface en-fr : ajout d'une clef dans Reference.jsx
RochDLY Nov 9, 2023
aacc98a
interface en-fr : ajout des clefs i18n dans WorkingVersion.jsx
RochDLY Nov 13, 2023
2fac172
interface fr-en : intégration des relectures sur la PR#963
RochDLY Nov 17, 2023
fff7aad
interface en-fr : ajout des clefs pour les boutons edition solo / col…
RochDLY Nov 20, 2023
1607eed
interface en-fr: test de résolution de l'affichage des termes traduit…
RochDLY Nov 24, 2023
3cdee35
interface en-fr: ajout de la dernière clef pour la working copy dans …
RochDLY Nov 24, 2023
6c8441e
interface en-fr: declaration de la constante {t} dans la fonction Art…
RochDLY Nov 24, 2023
d8160b3
interface en-fr: correction coquille dans une trad fr copie -> version
RochDLY Nov 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
ggrossetie marked this conversation as resolved.
Show resolved Hide resolved
</h1>
{expand && <ReferenceList />}
{modal && (
<Modal title="Bibliography Manager" cancel={closeModal}>
<Modal title={t('write.title.biblioModal')} cancel={closeModal}>
ggrossetie marked this conversation as resolved.
Show resolved Hide resolved
<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.createVersion.minorButton')}
ggrossetie marked this conversation as resolved.
Show resolved Hide resolved
</Button>
</li>
<li>
<Button onClick={(e) => handleCreateVersion(e, true)}>
Create Major
{t('write.createVersion.majorButton')}
ggrossetie marked this conversation as resolved.
Show resolved Hide resolved
</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.wordCount.stat', {stats: stats.wordCount})}</p>
ggrossetie marked this conversation as resolved.
Show resolved Hide resolved
<p>{t('write.charCountNoSpace.stat', {stats: stats.charCountNoSpace})}</p>
<p>{t('write.charCountPlusSpace.stat', {stats: stats.charCountPlusSpace})}</p>
<p>{t('write.citations.stat', {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.saveButton.versionName')} primary={true}>
<Check/> {t('write.saveButton.versionName')}
</Button>
ggrossetie marked this conversation as resolved.
Show resolved Hide resolved
<Button title="Cancel" type="button" onClick={cancelRenaming}>
Cancel
<Button title={t('write.cancelButton.versionName')} type="button" onClick={cancelRenaming}>
{t('write.cancelButton.versionName')}
</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.editButton.versionName')} 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.compareButton.version')}
</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.stopButton.version')}
</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
6 changes: 4 additions & 2 deletions front/src/components/Write/WorkingVersion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useEffect, useMemo, useState, useCallback } from 'react'
import { shallowEqual, useSelector } from 'react-redux'
import { Link } from "react-router-dom";
import { AlertCircle, AlignLeft, Check, Edit3, Eye, Loader, Printer } from 'react-feather'
import { useTranslation } from 'react-i18next'
import ArticleContributors from '../ArticleContributors.jsx'
import TimeAgo from '../TimeAgo.jsx'

Expand Down Expand Up @@ -76,6 +77,7 @@ export default function WorkingVersion ({ articleInfos, live, selectedVersion, m
const workingArticle = useSelector(state => state.workingArticle, shallowEqual)
const cancelExport = useCallback(() => setExporting(false), [])
const openExport = useCallback(() => setExporting(true), [])
const { t } = useTranslation()


const previewUrl = selectedVersion
Expand Down Expand Up @@ -113,12 +115,12 @@ export default function WorkingVersion ({ articleInfos, live, selectedVersion, m
</Link>
</li></>)}
<li>
<Button icon title="Download a printable version" onClick={openExport}>
<Button icon title={t('write.title.buttonExport')} onClick={openExport}>
<Printer/>
</Button>
</li>
<li>
<Link to={previewUrl} title="Preview (open a new window)" target="_blank" rel="noopener noreferrer"
<Link to={previewUrl} title={t('write.title.buttonPreview')} target="_blank" rel="noopener noreferrer"
className={buttonStyles.icon}>
<Eye/>
</Link>
Expand Down
12 changes: 7 additions & 5 deletions front/src/components/Write/bibliographe/Bibliographe.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import React, { useCallback, useState } from 'react'
import { useDispatch } from 'react-redux'
import { useTranslation } from 'react-i18next'

import NavTag from '../../NavTab'

import ZoteroPanel from './ZoteroPanel'
import CitationsPanel from './CitationsPanel'
import RawBibtexPanel from './RawBibtexPanel'

const tabItems = [
{ value: 'zotero', name: 'Zotero' },
{ value: 'citations', name: 'Citations' },
{ value: 'raw', name: 'Raw BibTeX' }
]

export default function Bibliographe({ article, cancel }) {
const { t } = useTranslation()
const tabItems = [
{ value: 'zotero', name: t('writeBibliographe.zotero.tabItem') },
{ value: 'citations', name: t('writeBibliographe.citation.tabItem') },
{ value: 'raw', name: t('writeBibliographe.rawBibtex.tabItem') }
]
const [selector, setSelector] = useState(tabItems.at(0).value)
const dispatch = useDispatch()
const handleTabChange = useCallback((value) => setSelector(value), [])
Expand Down
Loading
Loading