diff --git a/packages/netlify-cms-locales/src/en/index.js b/packages/netlify-cms-locales/src/en/index.js index c8eda3e9..54a1465a 100644 --- a/packages/netlify-cms-locales/src/en/index.js +++ b/packages/netlify-cms-locales/src/en/index.js @@ -197,6 +197,10 @@ const en = { datetime: { now: 'Now', }, + list: { + add: 'Add %{item}', + addType: 'Add %{item} item', + }, }, }, mediaLibrary: { diff --git a/packages/netlify-cms-ui-default/src/ObjectWidgetTopBar.js b/packages/netlify-cms-ui-default/src/ObjectWidgetTopBar.js index ddc00d67..c3eb7112 100644 --- a/packages/netlify-cms-ui-default/src/ObjectWidgetTopBar.js +++ b/packages/netlify-cms-ui-default/src/ObjectWidgetTopBar.js @@ -65,6 +65,7 @@ class ObjectWidgetTopBar extends React.Component { collapsed: PropTypes.bool, heading: PropTypes.node, label: PropTypes.string, + t: PropTypes.func.isRequired, }; renderAddUI() { @@ -82,7 +83,9 @@ class ObjectWidgetTopBar extends React.Component { return ( ( - Add {this.props.label} item + + {this.props.t('editor.editorWidgets.list.addType', { item: this.props.label })} + )} > {types.map((type, idx) => ( @@ -99,7 +102,8 @@ class ObjectWidgetTopBar extends React.Component { renderAddButton() { return ( - Add {this.props.label} + {this.props.t('editor.editorWidgets.list.add', { item: this.props.label })} + ); } diff --git a/packages/netlify-cms-widget-list/src/ListControl.js b/packages/netlify-cms-widget-list/src/ListControl.js index 122a0c71..e4c04595 100644 --- a/packages/netlify-cms-widget-list/src/ListControl.js +++ b/packages/netlify-cms-widget-list/src/ListControl.js @@ -128,6 +128,7 @@ export default class ListControl extends React.Component { clearFieldErrors: PropTypes.func.isRequired, fieldsErrors: ImmutablePropTypes.map.isRequired, entry: ImmutablePropTypes.map.isRequired, + t: PropTypes.func.isRequired, }; static defaultProps = { @@ -604,7 +605,7 @@ export default class ListControl extends React.Component { } renderListControl() { - const { value, forID, field, classNameWrapper } = this.props; + const { value, forID, field, classNameWrapper, t } = this.props; const { itemsCollapsed, listCollapsed } = this.state; const items = value || List(); const label = field.get('label', field.get('name')); @@ -635,6 +636,7 @@ export default class ListControl extends React.Component { label={labelSingular.toLowerCase()} onCollapseToggle={this.handleCollapseAllToggle} collapsed={selfCollapsed} + t={t} /> {(!selfCollapsed || !minimizeCollapsedItems) && ( { expect(queryByTestId('object-control-0')).toBeNull(); - fireEvent.click(getByText('Add list')); + fireEvent.click(getByText('editor.editorWidgets.list.add')); expect(props.onChange).toHaveBeenCalledTimes(1); expect(props.onChange).toHaveBeenCalledWith(fromJS([{}])); diff --git a/packages/netlify-cms-widget-list/src/__tests__/__snapshots__/ListControl.spec.js.snap b/packages/netlify-cms-widget-list/src/__tests__/__snapshots__/ListControl.spec.js.snap index 36936f01..533ec967 100644 --- a/packages/netlify-cms-widget-list/src/__tests__/__snapshots__/ListControl.spec.js.snap +++ b/packages/netlify-cms-widget-list/src/__tests__/__snapshots__/ListControl.spec.js.snap @@ -177,7 +177,7 @@ exports[`ListControl should add to list when add button is clicked 1`] = `