Skip to content

Commit db560cc

Browse files
authored
fix(widget-list): add missing translations in widget list top bar (#5471) (#5679)
1 parent d15a022 commit db560cc

File tree

6 files changed

+26
-14
lines changed

6 files changed

+26
-14
lines changed

packages/netlify-cms-locales/src/en/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ const en = {
197197
datetime: {
198198
now: 'Now',
199199
},
200+
list: {
201+
add: 'Add %{item}',
202+
addType: 'Add %{item} item',
203+
},
200204
},
201205
},
202206
mediaLibrary: {

packages/netlify-cms-ui-default/src/ObjectWidgetTopBar.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class ObjectWidgetTopBar extends React.Component {
6565
collapsed: PropTypes.bool,
6666
heading: PropTypes.node,
6767
label: PropTypes.string,
68+
t: PropTypes.func.isRequired,
6869
};
6970

7071
renderAddUI() {
@@ -82,7 +83,9 @@ class ObjectWidgetTopBar extends React.Component {
8283
return (
8384
<Dropdown
8485
renderButton={() => (
85-
<StyledDropdownButton>Add {this.props.label} item</StyledDropdownButton>
86+
<StyledDropdownButton>
87+
{this.props.t('editor.editorWidgets.list.addType', { item: this.props.label })}
88+
</StyledDropdownButton>
8689
)}
8790
>
8891
{types.map((type, idx) => (
@@ -99,7 +102,8 @@ class ObjectWidgetTopBar extends React.Component {
99102
renderAddButton() {
100103
return (
101104
<AddButton onClick={this.props.onAdd}>
102-
Add {this.props.label} <Icon type="add" size="xsmall" />
105+
{this.props.t('editor.editorWidgets.list.add', { item: this.props.label })}
106+
<Icon type="add" size="xsmall" />
103107
</AddButton>
104108
);
105109
}

packages/netlify-cms-widget-list/src/ListControl.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export default class ListControl extends React.Component {
128128
clearFieldErrors: PropTypes.func.isRequired,
129129
fieldsErrors: ImmutablePropTypes.map.isRequired,
130130
entry: ImmutablePropTypes.map.isRequired,
131+
t: PropTypes.func.isRequired,
131132
};
132133

133134
static defaultProps = {
@@ -604,7 +605,7 @@ export default class ListControl extends React.Component {
604605
}
605606

606607
renderListControl() {
607-
const { value, forID, field, classNameWrapper } = this.props;
608+
const { value, forID, field, classNameWrapper, t } = this.props;
608609
const { itemsCollapsed, listCollapsed } = this.state;
609610
const items = value || List();
610611
const label = field.get('label', field.get('name'));
@@ -635,6 +636,7 @@ export default class ListControl extends React.Component {
635636
label={labelSingular.toLowerCase()}
636637
onCollapseToggle={this.handleCollapseAllToggle}
637638
collapsed={selfCollapsed}
639+
t={t}
638640
/>
639641
{(!selfCollapsed || !minimizeCollapsedItems) && (
640642
<SortableList

packages/netlify-cms-widget-list/src/__tests__/ListControl.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ describe('ListControl', () => {
587587

588588
expect(queryByTestId('object-control-0')).toBeNull();
589589

590-
fireEvent.click(getByText('Add list'));
590+
fireEvent.click(getByText('editor.editorWidgets.list.add'));
591591

592592
expect(props.onChange).toHaveBeenCalledTimes(1);
593593
expect(props.onChange).toHaveBeenCalledWith(fromJS([{}]));

packages/netlify-cms-widget-list/src/__tests__/__snapshots__/ListControl.spec.js.snap

+9-9
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ exports[`ListControl should add to list when add button is clicked 1`] = `
177177
<button
178178
class="emotion-10 emotion-11"
179179
>
180-
Add list
180+
editor.editorWidgets.list.add
181181
<span
182182
class="emotion-0 emotion-8 emotion-2"
183183
>
@@ -406,7 +406,7 @@ exports[`ListControl should remove from list when remove button is clicked 1`] =
406406
<button
407407
class="emotion-10 emotion-11"
408408
>
409-
Add list
409+
editor.editorWidgets.list.add
410410
<span
411411
class="emotion-0 emotion-8 emotion-2"
412412
>
@@ -665,7 +665,7 @@ exports[`ListControl should remove from list when remove button is clicked 2`] =
665665
<button
666666
class="emotion-10 emotion-11"
667667
>
668-
Add list
668+
editor.editorWidgets.list.add
669669
<span
670670
class="emotion-0 emotion-8 emotion-2"
671671
>
@@ -905,7 +905,7 @@ exports[`ListControl should render list with fields with collapse = "false" and
905905
<button
906906
class="emotion-10 emotion-11"
907907
>
908-
Add list
908+
editor.editorWidgets.list.add
909909
<span
910910
class="emotion-0 emotion-8 emotion-2"
911911
>
@@ -1163,7 +1163,7 @@ exports[`ListControl should render list with fields with collapse = "false" and
11631163
<button
11641164
class="emotion-10 emotion-11"
11651165
>
1166-
Add list
1166+
editor.editorWidgets.list.add
11671167
<span
11681168
class="emotion-0 emotion-8 emotion-2"
11691169
>
@@ -1422,7 +1422,7 @@ exports[`ListControl should render list with fields with default collapse ("true
14221422
<button
14231423
class="emotion-10 emotion-11"
14241424
>
1425-
Add list
1425+
editor.editorWidgets.list.add
14261426
<span
14271427
class="emotion-0 emotion-8 emotion-2"
14281428
>
@@ -1663,7 +1663,7 @@ exports[`ListControl should render list with fields with default collapse ("true
16631663
<button
16641664
class="emotion-10 emotion-11"
16651665
>
1666-
Add list
1666+
editor.editorWidgets.list.add
16671667
<span
16681668
class="emotion-0 emotion-8 emotion-2"
16691669
>
@@ -1862,7 +1862,7 @@ exports[`ListControl should render list with nested object 1`] = `
18621862
<button
18631863
class="emotion-10 emotion-11"
18641864
>
1865-
Add list
1865+
editor.editorWidgets.list.add
18661866
<span
18671867
class="emotion-0 emotion-8 emotion-2"
18681868
>
@@ -2120,7 +2120,7 @@ exports[`ListControl should render list with nested object with collapse = false
21202120
<button
21212121
class="emotion-10 emotion-11"
21222122
>
2123-
Add list
2123+
editor.editorWidgets.list.add
21242124
<span
21252125
class="emotion-0 emotion-8 emotion-2"
21262126
>

packages/netlify-cms-widget-object/src/ObjectControl.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default class ObjectControl extends React.Component {
3838
clearFieldErrors: PropTypes.func.isRequired,
3939
fieldsErrors: ImmutablePropTypes.map.isRequired,
4040
hasError: PropTypes.bool,
41+
t: PropTypes.func.isRequired,
4142
};
4243

4344
static defaultProps = {
@@ -135,7 +136,7 @@ export default class ObjectControl extends React.Component {
135136
};
136137

137138
render() {
138-
const { field, forID, classNameWrapper, forList, hasError } = this.props;
139+
const { field, forID, classNameWrapper, forList, hasError, t } = this.props;
139140
const collapsed = forList ? this.props.collapsed : this.state.collapsed;
140141
const multiFields = field.get('fields');
141142
const singleField = field.get('field');
@@ -168,6 +169,7 @@ export default class ObjectControl extends React.Component {
168169
collapsed={collapsed}
169170
onCollapseToggle={this.handleCollapseToggle}
170171
heading={collapsed && this.objectLabel()}
172+
t={t}
171173
/>
172174
)}
173175
<div

0 commit comments

Comments
 (0)