Skip to content

Commit 2cde8c8

Browse files
authored
feat(plugin-form-builder): v3 backport to support translations (#17255)
3.x backport of #16794.
1 parent 7de11b2 commit 2cde8c8

57 files changed

Lines changed: 5186 additions & 112 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/plugin-form-builder/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@
4444
"import": "./src/exports/client.ts",
4545
"types": "./src/exports/client.ts",
4646
"default": "./src/exports/client.ts"
47+
},
48+
"./translations/languages/all": {
49+
"import": "./src/translations/index.ts",
50+
"types": "./src/translations/index.ts",
51+
"default": "./src/translations/index.ts"
52+
},
53+
"./translations/languages/*": {
54+
"import": "./src/translations/languages/*.ts",
55+
"types": "./src/translations/languages/*.ts",
56+
"default": "./src/translations/languages/*.ts"
4757
}
4858
},
4959
"main": "./src/index.ts",
@@ -62,6 +72,7 @@
6272
"test": "echo \"No tests available.\""
6373
},
6474
"dependencies": {
75+
"@payloadcms/translations": "workspace:*",
6576
"@payloadcms/ui": "workspace:*",
6677
"escape-html": "^1.0.3"
6778
},
@@ -95,6 +106,16 @@
95106
"import": "./dist/exports/client.js",
96107
"types": "./dist/exports/client.d.ts",
97108
"default": "./dist/exports/client.js"
109+
},
110+
"./translations/languages/all": {
111+
"import": "./dist/translations/index.js",
112+
"types": "./dist/translations/index.d.ts",
113+
"default": "./dist/translations/index.js"
114+
},
115+
"./translations/languages/*": {
116+
"import": "./dist/translations/languages/*.js",
117+
"types": "./dist/translations/languages/*.d.ts",
118+
"default": "./dist/translations/languages/*.js"
98119
}
99120
},
100121
"main": "./dist/index.js",

packages/plugin-form-builder/src/collections/FormSubmissions/fields/defaultPaymentFields.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ export const defaultPaymentFields: Field = {
77
{
88
name: 'field',
99
type: 'text',
10-
label: 'Field',
10+
label: ({ t }) =>
11+
// @ts-expect-error - translations are not typed in plugins yet
12+
t('plugin-form-builder:field'),
1113
},
1214
{
1315
name: 'status',
1416
type: 'text',
15-
label: 'Status',
17+
label: ({ t }) =>
18+
// @ts-expect-error - translations are not typed in plugins yet
19+
t('plugin-form-builder:paymentStatus'),
1620
},
1721
{
1822
name: 'amount',
1923
type: 'number',
2024
admin: {
21-
description: 'Amount in cents',
25+
description: ({ t }) =>
26+
// @ts-expect-error - translations are not typed in plugins yet
27+
t('plugin-form-builder:amountInCents'),
2228
},
2329
},
2430
{
@@ -32,20 +38,28 @@ export const defaultPaymentFields: Field = {
3238
{
3339
name: 'token',
3440
type: 'text',
35-
label: 'token',
41+
label: ({ t }) =>
42+
// @ts-expect-error - translations are not typed in plugins yet
43+
t('plugin-form-builder:token'),
3644
},
3745
{
3846
name: 'brand',
3947
type: 'text',
40-
label: 'Brand',
48+
label: ({ t }) =>
49+
// @ts-expect-error - translations are not typed in plugins yet
50+
t('plugin-form-builder:brand'),
4151
},
4252
{
4353
name: 'number',
4454
type: 'text',
45-
label: 'Number',
55+
label: ({ t }) =>
56+
// @ts-expect-error - translations are not typed in plugins yet
57+
t('plugin-form-builder:numberSingular'),
4658
},
4759
],
48-
label: 'Credit Card',
60+
label: ({ t }) =>
61+
// @ts-expect-error - translations are not typed in plugins yet
62+
t('plugin-form-builder:creditCard'),
4963
},
5064
],
5165
}

0 commit comments

Comments
 (0)