Skip to content

TASK: Use new translate() method if possible #3912

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

Open
wants to merge 15 commits into
base: 9.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@ import {connect} from 'react-redux';
import LinkInput from '@neos-project/neos-ui-editors/src/Library/LinkInput';

import {IconButton} from '@neos-project/react-ui-components';
import {neos} from '@neos-project/neos-ui-decorators';
import {selectors, actions} from '@neos-project/neos-ui-redux-store';

import style from './LinkButton.module.css';
import {translate} from '@neos-project/neos-ui-i18n';

@connect(state => ({
isOpen: selectors.UI.ContentCanvas.isLinkEditorOpen(state)
}), {
toggle: actions.UI.ContentCanvas.toggleLinkEditor
})
@neos(globalRegistry => ({
i18nRegistry: globalRegistry.get('i18n')
}))
export default class LinkButton extends PureComponent {
static propTypes = {
formattingUnderCursor: PropTypes.objectOf(PropTypes.oneOfType([
Expand All @@ -28,7 +25,6 @@ export default class LinkButton extends PureComponent {
])),
inlineEditorOptions: PropTypes.object,
executeCommand: PropTypes.func.isRequired,
i18nRegistry: PropTypes.object.isRequired,
isOpen: PropTypes.bool.isRequired,
toggle: PropTypes.func.isRequired
};
Expand Down Expand Up @@ -74,12 +70,12 @@ export default class LinkButton extends PureComponent {
}

render() {
const {i18nRegistry, inlineEditorOptions, isOpen} = this.props;
const {inlineEditorOptions, isOpen} = this.props;

return (
<div>
<IconButton
title={this.getLinkValue() ? `${i18nRegistry.translate('Neos.Neos.Ui:Main:ckeditor__toolbar__unlink', 'Unlink')}` : `${i18nRegistry.translate('Neos.Neos.Ui:Main:ckeditor__toolbar__link', 'Link')}`}
title={this.getLinkValue() ? translate('Neos.Neos.Ui:Main:ckeditor__toolbar__unlink', 'Unlink') : translate('Neos.Neos.Ui:Main:ckeditor__toolbar__link', 'Link')}
isActive={isOpen}
icon={this.getLinkValue() ? 'unlink' : 'link'}
onClick={this.handleLinkButtonClick}
Expand Down
26 changes: 10 additions & 16 deletions packages/neos-ui-containers/src/InsertModeSelector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';

import {ButtonGroup, Button, ResourceIcon} from '@neos-project/react-ui-components';
import {neos} from '@neos-project/neos-ui-decorators';
import I18n from '@neos-project/neos-ui-i18n';
import {translate} from '@neos-project/neos-ui-i18n';

import style from './style.module.css';

Expand Down Expand Up @@ -38,17 +37,12 @@ const calculatePreferredInitialMode = props => {
return null;
};

@neos(globalRegistry => ({
i18nRegistry: globalRegistry.get('i18n')
}))
export default class InsertModeSelector extends PureComponent {
static propTypes = {
mode: PropTypes.string,
enableAlongsideModes: PropTypes.bool.isRequired,
enableIntoMode: PropTypes.bool.isRequired,
onSelect: PropTypes.func.isRequired,

i18nRegistry: PropTypes.object.isRequired
onSelect: PropTypes.func.isRequired
};

options = [];
Expand Down Expand Up @@ -83,7 +77,7 @@ export default class InsertModeSelector extends PureComponent {
}

render() {
const {mode, enableIntoMode, enableAlongsideModes, i18nRegistry} = this.props;
const {mode, enableIntoMode, enableAlongsideModes} = this.props;

if (!mode) {
return null;
Expand All @@ -92,40 +86,40 @@ export default class InsertModeSelector extends PureComponent {
return (
<div className={style.root}>
<span className={style.label}>
<I18n id="Neos.Neos:Main:insertMode"/>&nbsp;
{translate('Neos.Neos:Main:insertMode')}&nbsp;
</span>
<ButtonGroup value={mode} onSelect={this.handleSelect} className={style.buttonGroup}>
<Button
id={MODE_BEFORE}
disabled={!enableAlongsideModes}
style="lighter"
size="small"
title={`${i18nRegistry.translate('Neos.Neos:Main:insert')} ${i18nRegistry.translate('above')}`}
title={`${translate('Neos.Neos:Main:insert')} ${translate('Neos.Neos:Main:above')}`}
>
<ResourceIcon source={createAboveIcon} className={style.iconAlignment}/>
<I18n id="Neos.Neos.Ui:Main:above" fallback="Above"/>
{translate('Neos.Neos.Ui:Main:above', 'Above')}
</Button>
<Button
id={MODE_AFTER}
className={style.afterButton}
disabled={!enableAlongsideModes}
style="lighter"
size="small"
title={`${i18nRegistry.translate('Neos.Neos:Main:insert')} ${i18nRegistry.translate('below')}`}
title={`${translate('Neos.Neos:Main:insert')} ${translate('Neos.Neos:Main:below')}`}
>
<ResourceIcon source={createBelowIcon} className={style.iconAlignment}/>
<I18n id="Neos.Neos.Ui:Main:below" fallback="Below"/>
{translate('Neos.Neos.Ui:Main:below', 'Below')}
</Button>
<Button
id={MODE_INTO}
className={style.intoButton}
disabled={!enableIntoMode}
style="lighter"
size="small"
title={`${i18nRegistry.translate('Neos.Neos:Main:insert')} ${i18nRegistry.translate('into')}`}
title={`${translate('Neos.Neos:Main:insert')} ${translate('Neos.Neos:Main:into')}`}
>
<ResourceIcon source={createInsideIcon} className={style.iconAlignment}/>
<I18n id="Neos.Neos.Ui:Main:inside" fallback="Inside"/>
{translate('Neos.Neos.Ui:Main:inside', 'Inside')}
</Button>
</ButtonGroup>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import style from './style.module.css';
import IconButton from '@neos-project/react-ui-components/src/IconButton/';
import {neos} from '@neos-project/neos-ui-decorators';
import {translate} from '@neos-project/neos-ui-i18n';

@neos(globalRegistry => ({
i18nRegistry: globalRegistry.get('i18n')
}))
export default class Controls extends PureComponent {
static propTypes = {
onChooseFromMedia: PropTypes.func.isRequired,
onChooseFromLocalFileSystem: PropTypes.func.isRequired,
i18nRegistry: PropTypes.object.isRequired,
isUploadEnabled: PropTypes.bool.isRequired,
isMediaBrowserEnabled: PropTypes.bool.isRequired
};
Expand All @@ -26,7 +22,7 @@ export default class Controls extends PureComponent {
style="lighter"
onClick={disabled ? null : this.props.onChooseFromMedia}
className={style.button}
title={this.props.i18nRegistry.translate('Neos.Neos:Main:media')}
title={translate('Neos.Neos:Main:media')}
disabled={disabled}
/>}
{isUploadEnabled && <IconButton
Expand All @@ -35,7 +31,7 @@ export default class Controls extends PureComponent {
style="lighter"
onClick={disabled ? null : this.props.onChooseFromLocalFileSystem}
className={style.button}
title={this.props.i18nRegistry.translate('Neos.Media.Browser:Main:chooseFile')}
title={translate('Neos.Media.Browser:Main:chooseFile')}
disabled={disabled}
/>}
</div>
Expand Down
13 changes: 7 additions & 6 deletions packages/neos-ui-editors/src/Editors/AssetEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {selectors} from '@neos-project/neos-ui-redux-store';
import AssetOption from '../../Library/AssetOption';
import {AssetUpload} from '../../Library/index';
import backend from '@neos-project/neos-ui-backend-connector';
import {translate} from '@neos-project/neos-ui-i18n';

const DEFAULT_FEATURES = {
mediaBrowser: true,
Expand Down Expand Up @@ -267,7 +268,7 @@ export default class AssetEditor extends PureComponent {
return (
<SelectBox
optionValueField="identifier"
loadingLabel={this.props.i18nRegistry.translate('Neos.Neos:Main:loading')}
loadingLabel={translate('Neos.Neos:Main:loading')}
displaySearchBox={this.isFeatureEnabled('mediaBrowser')}
ListPreviewElement={AssetOption}
placeholder={this.props.i18nRegistry.translate(this.props.placeholder)}
Expand All @@ -279,8 +280,8 @@ export default class AssetEditor extends PureComponent {
showDropDownToggle={false}
allowEmpty={true}
onSearchTermChange={this.handleSearchTermChange}
noMatchesFoundLabel={this.props.i18nRegistry.translate('Neos.Neos:Main:noMatchesFound')}
searchBoxLeftToTypeLabel={this.props.i18nRegistry.translate('Neos.Neos:Main:searchBoxLeftToType')}
noMatchesFoundLabel={translate('Neos.Neos:Main:noMatchesFound')}
searchBoxLeftToTypeLabel={translate('Neos.Neos:Main:searchBoxLeftToType')}
threshold={this.props?.options?.threshold}
disabled={disabled}
/>
Expand All @@ -294,7 +295,7 @@ export default class AssetEditor extends PureComponent {
<MultiSelectBox
dndType={dndTypes.MULTISELECT}
optionValueField="identifier"
loadingLabel={this.props.i18nRegistry.translate('Neos.Neos:Main:loading')}
loadingLabel={translate('Neos.Neos:Main:loading')}
displaySearchBox={this.isFeatureEnabled('mediaBrowser')}
ListPreviewElement={AssetOption}
placeholder={this.props.i18nRegistry.translate(this.props.placeholder)}
Expand All @@ -305,8 +306,8 @@ export default class AssetEditor extends PureComponent {
searchOptions={this.state.searchOptions}
showDropDownToggle={false}
onSearchTermChange={this.handleSearchTermChange}
noMatchesFoundLabel={this.props.i18nRegistry.translate('Neos.Neos:Main:noMatchesFound')}
searchBoxLeftToTypeLabel={this.props.i18nRegistry.translate('Neos.Neos:Main:searchBoxLeftToType')}
noMatchesFoundLabel={translate('Neos.Neos:Main:noMatchesFound')}
searchBoxLeftToTypeLabel={translate('Neos.Neos:Main:searchBoxLeftToType')}
threshold={this.props?.options?.threshold}
disabled={disabled}
/>
Expand Down
3 changes: 2 additions & 1 deletion packages/neos-ui-editors/src/Editors/DateTime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import moment from 'moment';
import {neos} from '@neos-project/neos-ui-decorators';
import convertPhpDateFormatToMoment, {has24HourFormat, hasDateFormat, hasTimeFormat} from './helpers';
import {connect} from 'react-redux';
import {translate} from '@neos-project/neos-ui-i18n';

@neos(globalRegistry => ({
i18nRegistry: globalRegistry.get('i18n')
Expand Down Expand Up @@ -61,7 +62,7 @@ class DateTime extends PureComponent {
timeOnly={!hasDateFormat(options.format)}
is24Hour={hasTimeFormat(options.format) && has24HourFormat(options.format)}
placeholder={i18nRegistry.translate(options?.placeholder || 'Neos.Neos:Main:content.inspector.editors.dateTimeEditor.noDateSet')}
todayLabel={i18nRegistry.translate('content.inspector.editors.dateTimeEditor.today', 'Today', {}, 'Neos.Neos', 'Main')}
todayLabel={translate('Neos.Neos:Main:content.inspector.editors.dateTimeEditor.today', 'Today')}
locale={interfaceLanguage}
disabled={options.disabled}
timeConstraints={timeConstraints}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import style from './style.module.css';
import IconButton from '@neos-project/react-ui-components/src/IconButton/';
import {neos} from '@neos-project/neos-ui-decorators';
import {translate} from '@neos-project/neos-ui-i18n';

@neos(globalRegistry => ({
i18nRegistry: globalRegistry.get('i18n')
}))
export default class Controls extends PureComponent {
static propTypes = {
onChooseFromMedia: PropTypes.func.isRequired,
Expand All @@ -16,9 +13,7 @@ export default class Controls extends PureComponent {
disabled: PropTypes.bool,

isUploadEnabled: PropTypes.bool.isRequired,
isMediaBrowserEnabled: PropTypes.bool.isRequired,

i18nRegistry: PropTypes.object.isRequired
isMediaBrowserEnabled: PropTypes.bool.isRequired
};

render() {
Expand All @@ -37,7 +32,6 @@ export default class Controls extends PureComponent {
isUploadEnabled,
isMediaBrowserEnabled,
onRemove,
i18nRegistry,
disabled
} = this.props;

Expand All @@ -54,7 +48,7 @@ export default class Controls extends PureComponent {
style="lighter"
onClick={handleChooseFromMedia()}
className={style.button}
title={i18nRegistry.translate('Neos.Neos:Main:media')}
title={translate('Neos.Neos:Main:media')}
disabled={disabled}
/>
}
Expand All @@ -65,7 +59,7 @@ export default class Controls extends PureComponent {
style="lighter"
onClick={handleChooseFromLocalFileSystem()}
className={style.button}
title={i18nRegistry.translate('Neos.Media.Browser:Main:chooseFile')}
title={translate('Neos.Media.Browser:Main:chooseFile')}
disabled={disabled}
/>
}
Expand All @@ -76,14 +70,14 @@ export default class Controls extends PureComponent {
onClick={handleRemove()}
disabled={!onRemove || disabled}
className={style.button}
title={i18nRegistry.translate('Neos.Neos:Main:remove')}
title={translate('Neos.Neos:Main:remove')}
/>
</span>
);
}

renderisCropperVisibleButton() {
const {onCrop, i18nRegistry, disabled} = this.props;
const {onCrop, disabled} = this.props;

const handleCrop = () => disabled ? null : onCrop;

Expand All @@ -95,7 +89,7 @@ export default class Controls extends PureComponent {
style="lighter"
className={style.cropButton}
onClick={handleCrop()}
title={i18nRegistry.translate('Neos.Neos:Main:crop')}
title={translate('Neos.Neos:Main:crop')}
disabled={disabled}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';
import PropTypes from 'prop-types';

import {TextInput, CheckBox} from '@neos-project/react-ui-components';
import I18n from '@neos-project/neos-ui-i18n';

import style from './style.module.css';
import {translate} from '@neos-project/neos-ui-i18n';

const buildResizeAdjustment = (width, height) => ({
allowUpScaling: null,
Expand Down Expand Up @@ -49,7 +49,7 @@ const ResizeControls = props => {
return (
<div>
<div className={style.resizeControls__item}>
<div className={style.resizeControls__label}><I18n id="width" fallback="Width"/>:</div>
<div className={style.resizeControls__label}>{translate('Neos.Neos:Main:width', 'Width')}:</div>
<div className={style.resizeControls}>
<span className={style.resizeControls__before}>
<CheckBox
Expand All @@ -74,7 +74,7 @@ const ResizeControls = props => {
</div>
</div>
<div>
<div className={style.resizeControls__label}><I18n id="height" fallback="Height"/>:</div>
<div className={style.resizeControls__label}>{translate('Neos.Neos:Main:height', 'Height')}:</div>
<div className={style.resizeControls}>
<span className={style.resizeControls__before}>
<CheckBox
Expand Down
14 changes: 4 additions & 10 deletions packages/neos-ui-editors/src/Editors/Range/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import {neos} from '@neos-project/neos-ui-decorators';
import style from './style.module.css';
import {translate} from '@neos-project/neos-ui-i18n';

@neos(globalRegistry => {
return {
i18nRegistry: globalRegistry.get('i18n')
};
})
class RangeEditor extends PureComponent {
static propTypes = {
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
commit: PropTypes.func.isRequired,
i18nRegistry: PropTypes.object.isRequired,
options: PropTypes.shape({
min: PropTypes.number,
max: PropTypes.number,
Expand Down Expand Up @@ -89,12 +83,12 @@ class RangeEditor extends PureComponent {
disabled={options.disabled}
/>
<div className={style.rangeEditorValue}>
<span title={this.props.i18nRegistry.translate('Neos.Neos.Ui:Main:rangeEditorMinimum')}>
<span title={translate('Neos.Neos.Ui:Main:rangeEditorMinimum')}>
{options.minLabel ? options.minLabel : options.min + options.unit}
</span>
<span>
<input
title={this.props.i18nRegistry.translate('Neos.Neos.Ui:Main:rangeEditorCurrentValue')}
title={translate('Neos.Neos.Ui:Main:rangeEditorCurrentValue')}
type="text"
onKeyPress={this.onKeyPress}
onChange={this.handleChange}
Expand All @@ -104,7 +98,7 @@ class RangeEditor extends PureComponent {
/>
{options.unit}
</span>
<span title={this.props.i18nRegistry.translate('Neos.Neos.Ui:Main:rangeEditorMaximum')}>
<span title={translate('Neos.Neos.Ui:Main:rangeEditorMaximum')}>
{options.maxLabel ? options.maxLabel : options.max + options.unit}
</span>
</div>
Expand Down
Loading
Loading