Merge pull request #3997 from overleaf/ae-react-translations

Ensure that all strings are translated in React components

GitOrigin-RevId: 855280150a21982fcf0ba57a39002451d37621e8
This commit is contained in:
Hugh O'Brien 2021-05-07 14:20:55 +01:00 committed by Copybot
parent 903c1110e0
commit d9b369c6c1
12 changed files with 188 additions and 73 deletions

View file

@ -1,6 +1,8 @@
{
"access_your_projects_with_git": "",
"account_settings": "",
"add_files": "",
"also": "",
"anyone_with_link_can_edit": "",
"anyone_with_link_can_view": "",
"ask_proj_owner_to_upgrade_for_git_bridge": "",
@ -69,6 +71,7 @@
"fast": "",
"file_already_exists": "",
"file_already_exists_in_this_location": "",
"file_name": "",
"file_name_in_this_project": "",
"file_outline": "",
"files_cannot_include_invalid_characters": "",
@ -76,6 +79,8 @@
"first_error_popup_label": "",
"following_paths_conflict": "",
"free_accounts_have_timeout_upgrade_to_increase": "",
"from_another_project": "",
"from_external_url": "",
"full_doc_history": "",
"full_screen": "",
"generic_something_went_wrong": "",
@ -102,6 +107,28 @@
"headers": "",
"hide_outline": "",
"history": "",
"hotkey_add_a_comment": "",
"hotkey_autocomplete_menu": "",
"hotkey_beginning_of_document": "",
"hotkey_bold_text": "",
"hotkey_compile": "",
"hotkey_delete_current_line": "",
"hotkey_end_of_document": "",
"hotkey_find_and_replace": "",
"hotkey_go_to_line": "",
"hotkey_indent_selection": "",
"hotkey_insert_candidate": "",
"hotkey_italic_text": "",
"hotkey_redo": "",
"hotkey_search_references": "",
"hotkey_select_all": "",
"hotkey_select_candidate": "",
"hotkey_to_lowercase": "",
"hotkey_to_uppercase": "",
"hotkey_toggle_comment": "",
"hotkey_toggle_review_panel": "",
"hotkey_toggle_track_changes": "",
"hotkey_undo": "",
"hotkeys": "",
"if_error_persists_try_relinking_provider": "",
"ignore_validation_errors": "",
@ -113,6 +140,7 @@
"importing_and_merging_changes_in_github": "",
"invalid_email": "",
"invalid_file_name": "",
"invalid_request": "",
"invite_not_accepted": "",
"learn_how_to_make_documents_compile_quickly": "",
"learn_more_about_link_sharing": "",
@ -154,6 +182,7 @@
"new_name": "",
"no_messages": "",
"no_new_commits_in_github": "",
"no_other_projects_found": "",
"no_preview_available": "",
"normal": "",
"off": "",
@ -170,6 +199,9 @@
"pdf_rendering_error": "",
"please_compile_pdf_before_download": "",
"please_refresh": "",
"please_select_a_file": "",
"please_select_a_project": "",
"please_select_an_output_file": "",
"please_set_main_file": "",
"plus_upgraded_accounts_receive": "",
"private": "",
@ -198,6 +230,7 @@
"refresh_page_after_starting_free_trial": "",
"refreshing": "",
"remote_service_error": "",
"remove": "",
"remove_collaborator": "",
"rename": "",
"repository_name": "",
@ -205,22 +238,28 @@
"review": "",
"revoke_invite": "",
"run_syntax_check_now": "",
"select_a_file": "",
"select_a_project": "",
"select_an_output_file": "",
"select_from_output_files": "",
"select_from_source_files": "",
"select_from_your_computer": "",
"send_first_message": "",
"server_error": "",
"session_error": "",
"session_expired_redirecting_to_login": "",
"share": "",
"share_project": "",
"share_with_your_collabs": "",
"show_outline": "",
"something_went_wrong_rendering_pdf": "",
"something_went_wrong_server": "",
"somthing_went_wrong_compiling": "",
"split_screen": "",
"start_free_trial": "",
"stop_compile": "",
"stop_on_validation_error": "",
"store_your_work": "",
"submit": "",
"submit_title": "",
"sure_you_want_to_delete": "",
"sync_project_to_github_explanation": "",
@ -234,6 +273,7 @@
"to_change_access_permissions": "",
"toggle_compile_options_menu": "",
"toggle_output_files_list": "",
"too_many_attempts": "",
"too_many_files_uploaded_throttled_short_period": "",
"too_many_requests": "",
"too_recently_compiled": "",
@ -247,6 +287,7 @@
"upgrade": "",
"upgrade_for_longer_compiles": "",
"upload": "",
"url_to_fetch_the_file_from": "",
"use_your_own_machine": "",
"validation_issue_description": "",
"validation_issue_entry_description": "",

View file

@ -129,13 +129,14 @@ export default function BinaryFileHeader({ file, storeReferencesKeys }) {
className="btn btn-info"
>
<Icon type="download" modifier="fw" />
<span>{' ' + t('download')}</span>
&nbsp;
<span>{t('download')}</span>
</a>
{refreshError && (
<div className="row">
<br />
<div className="alert alert-danger col-md-6 col-md-offset-3">
Error: {refreshError}
{t('error')}: {refreshError}
{tprLinkedFileRefreshError.map(
({ import: { LinkedFileRefreshError }, path }) => (
<LinkedFileRefreshError key={path} file={file} />

View file

@ -62,32 +62,17 @@ export default function ErrorMessage({ error }) {
// TODO: translations
switch (error.response?.status) {
case 400:
return (
<DangerMessage>
Invalid Request. Please correct the data and try again.
</DangerMessage>
)
return <DangerMessage>{t('invalid_request')}</DangerMessage>
case 403:
return (
<DangerMessage>
Session error. Please check you have cookies enabled. If the
problem persists, try clearing your cache and cookies.
</DangerMessage>
)
return <DangerMessage>{t('session_error')}</DangerMessage>
case 429:
return (
<DangerMessage>
Too many attempts. Please wait for a while and try again.
</DangerMessage>
)
return <DangerMessage>{t('too_many_attempts')}</DangerMessage>
default:
return (
<DangerMessage>
Something went wrong talking to the server :(. Please try again.
</DangerMessage>
<DangerMessage>{t('something_went_wrong_server')}</DangerMessage>
)
}
}

View file

@ -2,7 +2,7 @@ import ControlLabel from 'react-bootstrap/lib/ControlLabel'
import { Alert, FormControl } from 'react-bootstrap'
import FormGroup from 'react-bootstrap/lib/FormGroup'
import React, { useCallback } from 'react'
import { Trans } from 'react-i18next'
import { Trans, useTranslation } from 'react-i18next'
import { useFileTreeCreateName } from '../../contexts/file-tree-create-name'
import PropTypes from 'prop-types'
import {
@ -16,12 +16,14 @@ import {
* plus a validation warning and/or an error message when needed
*/
export default function FileTreeCreateNameInput({
label = 'File Name',
label,
focusName = false,
classes = {},
placeholder = 'File Name',
placeholder,
error,
}) {
const { t } = useTranslation()
// the value is stored in a context provider, so it's available elsewhere in the form
const { name, setName, touchedName, validName } = useFileTreeCreateName()
@ -40,11 +42,11 @@ export default function FileTreeCreateNameInput({
return (
<FormGroup controlId="new-doc-name" className={classes.formGroup}>
<ControlLabel>{label}</ControlLabel>
<ControlLabel>{label || t('file_name')}</ControlLabel>
<FormControl
type="text"
placeholder={placeholder}
placeholder={placeholder || t('file_name')}
required
value={name}
onChange={event => setName(event.target.value)}

View file

@ -1,4 +1,5 @@
import React from 'react'
import { useTranslation } from 'react-i18next'
import FileTreeCreateNewDoc from './modes/file-tree-create-new-doc'
import FileTreeImportFromUrl from './modes/file-tree-import-from-url'
import FileTreeImportFromProject from './modes/file-tree-import-from-project'
@ -13,6 +14,8 @@ import importOverleafModules from '../../../../../macros/import-overleaf-module.
const createFileModeModules = importOverleafModules('createFileModes')
export default function FileTreeModalCreateFileBody() {
const { t } = useTranslation()
const { newFileCreateMode } = useFileTreeActionable()
const { fileCount } = useFileTreeMutable()
@ -29,26 +32,26 @@ export default function FileTreeModalCreateFileBody() {
<FileTreeModalCreateFileMode
mode="doc"
icon="file"
label="New File"
label={t('new_file')}
/>
<FileTreeModalCreateFileMode
mode="upload"
icon="upload"
label="Upload"
label={t('upload')}
/>
<FileTreeModalCreateFileMode
mode="project"
icon="folder-open"
label="From Another Project"
label={t('from_another_project')}
/>
{window.ExposedSettings.hasLinkUrlFeature && (
<FileTreeModalCreateFileMode
mode="url"
icon="globe"
label="From External URL"
label={t('from_external_url')}
/>
)}

View file

@ -132,8 +132,8 @@ export default function FileTreeImportFromProject() {
>
<span>
{isOutputFilesMode
? 'select from source files'
: 'select from output files'}
? t('select_from_source_files')
: t('select_from_output_files')}
</span>
</Button>
</div>
@ -153,6 +153,8 @@ export default function FileTreeImportFromProject() {
}
function SelectProject({ projectId, selectedProject, setSelectedProject }) {
const { t } = useTranslation()
// NOTE: unhandled error
const { data, loading } = useUserProjects()
@ -166,7 +168,7 @@ function SelectProject({ projectId, selectedProject, setSelectedProject }) {
return (
<FormGroup className="form-controls" controlId="project-select">
<ControlLabel>Select a Project</ControlLabel>
<ControlLabel>{t('select_a_project')}</ControlLabel>
{loading && (
<span>
@ -186,7 +188,7 @@ function SelectProject({ projectId, selectedProject, setSelectedProject }) {
}}
>
<option disabled value="">
- Please Select a Project
- {t('please_select_a_project')}
</option>
{filteredData &&
@ -198,9 +200,7 @@ function SelectProject({ projectId, selectedProject, setSelectedProject }) {
</FormControl>
{filteredData && !filteredData.length && (
<small>
No other projects found, please create another project first
</small>
<small>{t('no_other_projects_found')}</small>
)}
</FormGroup>
)
@ -216,6 +216,8 @@ function SelectProjectOutputFile({
selectedProjectOutputFile,
setSelectedProjectOutputFile,
}) {
const { t } = useTranslation()
// NOTE: unhandled error
const { data, loading } = useProjectOutputFiles(selectedProjectId)
@ -224,7 +226,7 @@ function SelectProjectOutputFile({
className="form-controls row-spaced-small"
controlId="project-output-file-select"
>
<ControlLabel>Select an Output File</ControlLabel>
<ControlLabel>{t('select_an_output_file')}</ControlLabel>
{loading && (
<span>
@ -244,7 +246,7 @@ function SelectProjectOutputFile({
}}
>
<option disabled value="">
- Please Select an Output File
- {t('please_select_an_output_file')}
</option>
{data &&
@ -268,6 +270,8 @@ function SelectProjectEntity({
selectedProjectEntity,
setSelectedProjectEntity,
}) {
const { t } = useTranslation()
// NOTE: unhandled error
const { data, loading } = useProjectEntities(selectedProjectId)
@ -276,7 +280,7 @@ function SelectProjectEntity({
className="form-controls row-spaced-small"
controlId="project-entity-select"
>
<ControlLabel>Select a File</ControlLabel>
<ControlLabel>{t('select_a_file')}</ControlLabel>
{loading && (
<span>
@ -296,7 +300,7 @@ function SelectProjectEntity({
}}
>
<option disabled value="">
- Please Select a File
- {t('please_select_a_file')}
</option>
{data &&

View file

@ -51,7 +51,7 @@ export default function FileTreeImportFromUrl() {
onSubmit={handleSubmit}
>
<FormGroup controlId="import-from-url">
<ControlLabel>URL to fetch the file from</ControlLabel>
<ControlLabel>{t('url_to_fetch_the_file_from')}</ControlLabel>
<FormControl
type="url"

View file

@ -1,5 +1,6 @@
import React from 'react'
import { Modal } from 'react-bootstrap'
import { useTranslation } from 'react-i18next'
import { useFileTreeActionable } from '../../contexts/file-tree-actionable'
import FileTreeCreateFormProvider from '../../contexts/file-tree-create-form'
import FileTreeModalCreateFileBody from '../file-tree-create/file-tree-modal-create-file-body'
@ -7,6 +8,8 @@ import FileTreeModalCreateFileFooter from '../file-tree-create/file-tree-modal-c
import AccessibleModal from '../../../../shared/components/accessible-modal'
export default function FileTreeModalCreateFile() {
const { t } = useTranslation()
const { isCreatingFile, cancel } = useFileTreeActionable()
if (!isCreatingFile) {
@ -17,7 +20,7 @@ export default function FileTreeModalCreateFile() {
<FileTreeCreateFormProvider>
<AccessibleModal bsSize="large" onHide={cancel} show>
<Modal.Header closeButton>
<Modal.Title>Add Files</Modal.Title>
<Modal.Title>{t('add_files')}</Modal.Title>
</Modal.Header>
<Modal.Body className="modal-new-file">

View file

@ -33,15 +33,24 @@ export default function HotkeysModal({
<Col xs={4}>
<Hotkey
combination={`${ctrl} + F`}
description="Find (and replace)"
description={t('hotkey_find_and_replace')}
/>
<Hotkey
combination={`${ctrl} + Enter`}
description={t('hotkey_compile')}
/>
<Hotkey combination={`${ctrl} + Enter`} description="Compile" />
</Col>
<Col xs={4}>
<Hotkey combination={`${ctrl} + Z`} description="Undo" />
<Hotkey
combination={`${ctrl} + Z`}
description={t('hotkey_undo')}
/>
</Col>
<Col xs={4}>
<Hotkey combination={`${ctrl} + Y`} description="Redo" />
<Hotkey
combination={`${ctrl} + Y`}
description={t('hotkey_redo')}
/>
</Col>
</Row>
@ -51,17 +60,20 @@ export default function HotkeysModal({
<Col xs={4}>
<Hotkey
combination={`${ctrl} + Home`}
description="Beginning of document"
description={t('hotkey_beginning_of_document')}
/>
</Col>
<Col xs={4}>
<Hotkey
combination={`${ctrl} + End`}
description="End of document"
description={t('hotkey_end_of_document')}
/>
</Col>
<Col xs={4}>
<Hotkey combination={`${ctrl} + L`} description="Go To Line" />
<Hotkey
combination={`${ctrl} + L`}
description={t('hotkey_go_to_line')}
/>
</Col>
</Row>
@ -69,26 +81,44 @@ export default function HotkeysModal({
<Row>
<Col xs={4}>
<Hotkey combination={`${ctrl} + /`} description="Toggle Comment" />
<Hotkey
combination={`${ctrl} + /`}
description={t('hotkey_toggle_comment')}
/>
<Hotkey
combination={`${ctrl} + D`}
description="Delete Current Line"
description={t('hotkey_delete_current_line')}
/>
<Hotkey
combination={`${ctrl} + A`}
description={t('hotkey_select_all')}
/>
<Hotkey combination={`${ctrl} + A`} description="Select All" />
</Col>
<Col xs={4}>
<Hotkey combination={`${ctrl} + U`} description="To Uppercase" />
<Hotkey
combination={`${ctrl} + U`}
description={t('hotkey_to_uppercase')}
/>
<Hotkey
combination={`${ctrl} + Shift + U`}
description="To Lowercase"
description={t('hotkey_to_lowercase')}
/>
<Hotkey
combination="Tab"
description={t('hotkey_indent_selection')}
/>
<Hotkey combination="Tab" description="Indent Selection" />
</Col>
<Col xs={4}>
<Hotkey combination={`${ctrl} + B`} description="Bold text" />
<Hotkey combination={`${ctrl} + I`} description="Italic Text" />
<Hotkey
combination={`${ctrl} + B`}
description={t('hotkey_bold_text')}
/>
<Hotkey
combination={`${ctrl} + I`}
description={t('hotkey_italic_text')}
/>
</Col>
</Row>
@ -98,17 +128,20 @@ export default function HotkeysModal({
<Col xs={4}>
<Hotkey
combination={`${ctrl} + Space`}
description="Autocomplete Menu"
description={t('hotkey_autocomplete_menu')}
/>
</Col>
<Col xs={4}>
<Hotkey
combination="Tab / Up / Down"
description="Select Candidate"
description={t('hotkey_select_candidate')}
/>
</Col>
<Col xs={4}>
<Hotkey combination="Enter" description="Insert Candidate" />
<Hotkey
combination="Enter"
description={t('hotkey_insert_candidate')}
/>
</Col>
</Row>
@ -123,7 +156,7 @@ export default function HotkeysModal({
<Col xs={4}>
<Hotkey
combination={`${ctrl} + Space `}
description="Search References"
description={t('hotkey_search_references')}
/>
</Col>
</Row>
@ -136,19 +169,19 @@ export default function HotkeysModal({
<Col xs={4}>
<Hotkey
combination={`${ctrl} + J`}
description="Toggle review panel"
description={t('hotkey_toggle_review_panel')}
/>
</Col>
<Col xs={4}>
<Hotkey
combination={`${ctrl} + Shift + A`}
description="Toggle track changes"
description={t('hotkey_toggle_track_changes')}
/>
</Col>
<Col xs={4}>
<Hotkey
combination={`${ctrl} + Shift + C`}
description="Add a comment"
description={t('hotkey_add_a_comment')}
/>
</Col>
</Row>

View file

@ -1,17 +1,19 @@
import React, { useState } from 'react'
import { Trans } from 'react-i18next'
import { Trans, useTranslation } from 'react-i18next'
import { Button } from 'react-bootstrap'
import Icon from '../../../shared/components/icon'
import { upgradePlan } from '../../../main/account-upgrade'
import StartFreeTrialButton from '../../../shared/components/start-free-trial-button'
export default function AddCollaboratorsUpgrade() {
const { t } = useTranslation()
const [startedFreeTrial, setStartedFreeTrial] = useState(false)
return (
<div className="add-collaborators-upgrade">
<p className="text-center">
<Trans i18nKey="need_to_upgrade_for_more_collabs" />. Also:
<Trans i18nKey="need_to_upgrade_for_more_collabs" />. {t('also')}:
</p>
<ul className="list-unstyled">

View file

@ -1,6 +1,6 @@
import React, { useEffect, useMemo, useState, useRef, useCallback } from 'react'
import PropTypes from 'prop-types'
import { Trans } from 'react-i18next'
import { Trans, useTranslation } from 'react-i18next'
import { matchSorter } from 'match-sorter'
import { useCombobox } from 'downshift'
import classnames from 'classnames'
@ -286,6 +286,8 @@ function SelectedItem({
getSelectedItemProps,
index,
}) {
const { t } = useTranslation()
const handleClick = useCallback(
event => {
event.preventDefault()
@ -306,7 +308,7 @@ function SelectedItem({
<button
type="button"
className="remove-button btn-inline-link"
aria-label="Remove"
aria-label={t('remove')}
onClick={handleClick}
>
<Icon type="close" modifier="fw" />

View file

@ -374,7 +374,7 @@
"save_or_cancel-or": "or",
"save_or_cancel-cancel": "Cancel",
"make_default": "Make default",
"remove": "remove",
"remove": "Remove",
"confirm_email": "Confirm Email",
"invited_to_join_team": "You have been invited to join a team",
"join_team": "Join Team",
@ -1083,7 +1083,6 @@
"admin": "admin",
"subscribe": "Subscribe",
"update_billing_details": "Update Billing Details",
"thank_you": "Thank You",
"group_admin": "Group Admin",
"all_templates": "All Templates",
"your_settings": "Your settings",
@ -1380,7 +1379,6 @@
"please_check_your_inbox_to_confirm": "Please check your email inbox to confirm your <0>__institutionName__</0> affiliation.",
"your_affiliation_is_confirmed": "Your <0>__institutionName__</0> affiliation is confirmed.",
"thank_you": "Thank you!",
"add_email": "Add Email",
"imported_from_mendeley_at_date": "Imported from Mendeley at __formattedDate__ __relativeDate__",
"imported_from_zotero_at_date": "Imported from Zotero at __formattedDate__ __relativeDate__",
"imported_from_external_provider_at_date": "Imported from <0>__shortenedUrlHTML__</0> at __formattedDate__ __relativeDate__",
@ -1388,6 +1386,47 @@
"imported_from_the_output_of_another_project_at_date": "Imported from the output of <0>Another project</0>: __sourceOutputFilePathHTML__, at __formattedDate__ __relativeDate__",
"refreshing": "Refreshing",
"if_error_persists_try_relinking_provider": "If this error persists, try re-linking your __provider__ account here",
"select_from_source_files": "select from source files",
"select_from_output_files": "select from output files",
"select_a_project": "Select a Project",
"please_select_a_project": "Please Select a Project",
"no_other_projects_found": "No other projects found, please create another project first",
"select_an_output_file": "Select an Output File",
"please_select_an_output_file": "Please Select an Output File",
"select_a_file": "Select a File",
"please_select_a_file": "Please Select a File",
"url_to_fetch_the_file_from": "URL to fetch the file from",
"invalid_request": "Invalid Request. Please correct the data and try again.",
"session_error": "Session error. Please check you have cookies enabled. If the problem persists, try clearing your cache and cookies.",
"too_many_attempts": "Too many attempts. Please wait for a while and try again.",
"something_went_wrong_server": "Something went wrong talking to the server :(. Please try again.",
"file_name": "File Name",
"from_another_project": "From Another Project",
"from_external_url": "From External URL",
"thank_you_exclamation": "Thank you!",
"add_files": "Add Files",
"hotkey_find_and_replace": "Find (and replace)",
"hotkey_compile": "Compile",
"hotkey_undo": "Undo",
"hotkey_redo": "Redo",
"hotkey_beginning_of_document": "Beginning of document",
"hotkey_end_of_document": "End of document",
"hotkey_go_to_line": "Go To Line",
"hotkey_toggle_comment": "Toggle Comment",
"hotkey_delete_current_line": "Delete Current Line",
"hotkey_select_all": "Select All",
"hotkey_to_uppercase": "To Uppercase",
"hotkey_to_lowercase": "To Lowercase",
"hotkey_indent_selection": "Indent Selection",
"hotkey_bold_text": "Bold text",
"hotkey_italic_text": "Italic Text",
"hotkey_autocomplete_menu": "Autocomplete Menu",
"hotkey_select_candidate": "Select Candidate",
"hotkey_insert_candidate": "Insert Candidate",
"hotkey_search_references": "Search References",
"hotkey_toggle_review_panel": "Toggle review panel",
"hotkey_toggle_track_changes": "Toggle track changes",
"hotkey_add_a_comment": "Add a comment",
"also": "Also",
"add_email": "Add Email"
}