Skip to content

Commit 019e7a0

Browse files
authored
Fix labels (#40)
1 parent 1c24df5 commit 019e7a0

4 files changed

Lines changed: 21 additions & 11 deletions

File tree

admin/src/components/Input.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const Tags = ({
1313
attribute,
1414
description,
1515
error,
16-
intlLabel,
16+
label,
1717
labelAction,
1818
name,
1919
onChange,
@@ -176,9 +176,7 @@ const Tags = ({
176176
style={{ position: "relative" }}
177177
ref={inputEle}
178178
>
179-
<Field.Label action={labelAction}>
180-
{intlLabel && formatMessage({ id: intlLabel })}
181-
</Field.Label>
179+
{label && <Field.Label action={labelAction}>{formatMessage({ id: label, defaultMessage: "Tags" })}</Field.Label>}
182180
<ThemeStyle />
183181
<Flex direction="column">
184182
<TagsInput
@@ -206,7 +204,7 @@ Tags.defaultProps = {
206204
};
207205

208206
Tags.propTypes = {
209-
intlLabel: PropTypes.object.isRequired,
207+
label: PropTypes.object.isRequired,
210208
onChange: PropTypes.func.isRequired,
211209
attribute: PropTypes.object.isRequired,
212210
name: PropTypes.string.isRequired,

admin/src/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pluginId from "./pluginId";
2+
import { getTranslation } from './utils/getTranslation';
23

34
export default {
45
register(app) {
@@ -7,12 +8,12 @@ export default {
78
pluginId: pluginId,
89
type: "text",
910
intlLabel: {
10-
id: "tagsinput.tag.label",
11-
defaultMessage: "TagsInput",
11+
id: getTranslation('form.label'),
12+
defaultMessage: 'TagsInput',
1213
},
1314
intlDescription: {
14-
id: "tagsinput.tag.description",
15-
defaultMessage: "TagsInput to add custom tags",
15+
id: getTranslation('form.description'),
16+
defaultMessage: 'TagsInput to add custom tags',
1617
},
1718
components: {
1819
Input: async () =>
@@ -24,13 +25,13 @@ export default {
2425
base: [
2526
{
2627
sectionTitle: {
27-
id: "tagsinput.tags.section.apiUrl",
28+
id: "form.section.apiUrl",
2829
defaultMessage: "API Url",
2930
},
3031
items: [
3132
{
3233
intlLabel: {
33-
id: "tagsinput.tags.section.apiUrl",
34+
id: "form.apiUrl",
3435
defaultMessage: "Rest API URL for suggestions",
3536
},
3637
name: "options.apiUrl",

admin/src/translations/en.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"form.label": "TagsInput",
3+
"form.description": "TagsInput to add custom tags",
4+
"form.section.apiUrl": "API Url",
5+
"form.apiUrl": "Rest API URL for suggestions"
6+
}

admin/src/utils/getTranslation.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import pluginId from '../pluginId';
2+
3+
const getTranslation = (id) => `${pluginId}.${id}`;
4+
5+
export { getTranslation };

0 commit comments

Comments
 (0)