Skip to content

Commit a8000f6

Browse files
authored
feat(richtext-lexical): i18n (#6542)
Continuation of #6524
1 parent 7d0e909 commit a8000f6

Some content is hidden

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

42 files changed

+1764
-153
lines changed

packages/richtext-lexical/src/field/features/align/feature.client.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ const toolbarGroups: ToolbarGroup[] = [
3939
return true
4040
},
4141
key: 'alignLeft',
42-
label: `Align Left`,
42+
label: ({ i18n }) => {
43+
return i18n.t('lexical:align:alignLeftLabel')
44+
},
4345
onSelect: ({ editor }) => {
4446
editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'left')
4547
},
@@ -70,7 +72,9 @@ const toolbarGroups: ToolbarGroup[] = [
7072
return true
7173
},
7274
key: 'alignCenter',
73-
label: `Align Center`,
75+
label: ({ i18n }) => {
76+
return i18n.t('lexical:align:alignCenterLabel')
77+
},
7478
onSelect: ({ editor }) => {
7579
editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'center')
7680
},
@@ -101,7 +105,9 @@ const toolbarGroups: ToolbarGroup[] = [
101105
return true
102106
},
103107
key: 'alignRight',
104-
label: `Align Right`,
108+
label: ({ i18n }) => {
109+
return i18n.t('lexical:align:alignRightLabel')
110+
},
105111
onSelect: ({ editor }) => {
106112
editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'right')
107113
},
@@ -132,7 +138,9 @@ const toolbarGroups: ToolbarGroup[] = [
132138
return true
133139
},
134140
key: 'alignJustify',
135-
label: `Align Justify`,
141+
label: ({ i18n }) => {
142+
return i18n.t('lexical:align:alignJustifyLabel')
143+
},
136144
onSelect: ({ editor }) => {
137145
editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'justify')
138146
},

packages/richtext-lexical/src/field/features/align/feature.server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import type { FeatureProviderProviderServer } from '../types.js'
22

33
import { AlignFeatureClientComponent } from './feature.client.js'
4+
import { i18n } from './i18n.js'
45

56
export const AlignFeature: FeatureProviderProviderServer<undefined, undefined> = (props) => {
67
return {
78
feature: () => {
89
return {
910
ClientComponent: AlignFeatureClientComponent,
1011
clientFeatureProps: null,
12+
i18n,
1113
serverFeatureProps: props,
1214
}
1315
},
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
import type { GenericLanguages } from '@payloadcms/translations'
2+
3+
export const i18n: Partial<GenericLanguages> = {
4+
ar: {
5+
alignCenterLabel: 'محاذاة في الوسط',
6+
alignJustifyLabel: 'محاذاة التبرير',
7+
alignLeftLabel: 'محاذاة إلى اليسار',
8+
alignRightLabel: 'محاذاة إلى اليمين',
9+
},
10+
az: {
11+
alignCenterLabel: 'Mərkəzə Düzəlt',
12+
alignJustifyLabel: 'Düzəldin Səsləndirin',
13+
alignLeftLabel: 'Sola Doğru Hizalama',
14+
alignRightLabel: 'Sağa Doğru Hizalama',
15+
},
16+
bg: {
17+
alignCenterLabel: 'Центрирай',
18+
alignJustifyLabel: 'Подравняване по двата края',
19+
alignLeftLabel: 'Подравняване отляво',
20+
alignRightLabel: 'Подравняване вдясно',
21+
},
22+
cs: {
23+
alignCenterLabel: 'Zarovnat na střed',
24+
alignJustifyLabel: 'Zarovnat do bloku',
25+
alignLeftLabel: 'Zarovnat vlevo',
26+
alignRightLabel: 'Zarovnat vpravo',
27+
},
28+
de: {
29+
alignCenterLabel: 'Zentrieren',
30+
alignJustifyLabel: 'Blocksatz',
31+
alignLeftLabel: 'Linksbündig',
32+
alignRightLabel: 'Rechtsbündig',
33+
},
34+
en: {
35+
alignCenterLabel: 'Align Center',
36+
alignJustifyLabel: 'Align Justify',
37+
alignLeftLabel: 'Align Left',
38+
alignRightLabel: 'Align Right',
39+
},
40+
es: {
41+
alignCenterLabel: 'Alinear al centro',
42+
alignJustifyLabel: 'Alinear Justificar',
43+
alignLeftLabel: 'Alinear a la izquierda',
44+
alignRightLabel: 'Alinear a la derecha',
45+
},
46+
fa: {
47+
alignCenterLabel: 'تراز در مرکز',
48+
alignJustifyLabel: 'تراز کردن از دو طرف',
49+
alignLeftLabel: 'چپ تراز',
50+
alignRightLabel: 'راست چین',
51+
},
52+
fr: {
53+
alignCenterLabel: 'Aligner au centre',
54+
alignJustifyLabel: 'Aligner Justifier',
55+
alignLeftLabel: 'Aligner à gauche',
56+
alignRightLabel: 'Aligner à droite',
57+
},
58+
he: {
59+
alignCenterLabel: 'ממורכז',
60+
alignJustifyLabel: 'יישור דו-צדדי',
61+
alignLeftLabel: 'הסב לשמאל',
62+
alignRightLabel: 'יישור לימין',
63+
},
64+
hr: {
65+
alignCenterLabel: 'Poravnaj središnje',
66+
alignJustifyLabel: 'Poravnaj opravdaj',
67+
alignLeftLabel: 'Poravnaj lijevo',
68+
alignRightLabel: 'Poravnaj desno',
69+
},
70+
hu: {
71+
alignCenterLabel: 'Középre igazítás',
72+
alignJustifyLabel: 'Igazítás Sorkizárás',
73+
alignLeftLabel: 'Igazítás balra',
74+
alignRightLabel: 'Igazítás jobbra',
75+
},
76+
it: {
77+
alignCenterLabel: 'Allinea al centro',
78+
alignJustifyLabel: 'Allinea Giustifica',
79+
alignLeftLabel: 'Allinea a sinistra',
80+
alignRightLabel: 'Allinea a destra',
81+
},
82+
ja: {
83+
alignCenterLabel: '中央揃え',
84+
alignJustifyLabel: '両端揃え',
85+
alignLeftLabel: '左揃え',
86+
alignRightLabel: '右揃え',
87+
},
88+
ko: {
89+
alignCenterLabel: '중앙 정렬',
90+
alignJustifyLabel: '정렬 맞춤',
91+
alignLeftLabel: '왼쪽 정렬',
92+
alignRightLabel: '오른쪽 정렬',
93+
},
94+
my: {
95+
alignCenterLabel: 'Pusat Selaras',
96+
alignJustifyLabel: 'Penjajaran Justify',
97+
alignLeftLabel: 'ဘယ်ဘက်ဦးတည်ခြင်း',
98+
alignRightLabel: 'Penjajaran Kanan',
99+
},
100+
nb: {
101+
alignCenterLabel: 'Sentrer tekst',
102+
alignJustifyLabel: 'Juster linje',
103+
alignLeftLabel: 'Juster til venstre',
104+
alignRightLabel: 'Juster til høyre',
105+
},
106+
nl: {
107+
alignCenterLabel: 'Centreer uitlijnen',
108+
alignJustifyLabel: 'Uitlijnen Rechtvaardigen',
109+
alignLeftLabel: 'Links uitlijnen',
110+
alignRightLabel: 'Rechts uitlijnen',
111+
},
112+
pl: {
113+
alignCenterLabel: 'Wyśrodkuj',
114+
alignJustifyLabel: 'Wyjustuj wyrównanie',
115+
alignLeftLabel: 'Wyrównaj do lewej',
116+
alignRightLabel: 'Wyrównaj do prawej',
117+
},
118+
pt: {
119+
alignCenterLabel: 'Alinhar ao Centro',
120+
alignJustifyLabel: 'Alinhar Justificar',
121+
alignLeftLabel: 'Alinhar à Esquerda',
122+
alignRightLabel: 'Alinhar à Direita',
123+
},
124+
ro: {
125+
alignCenterLabel: 'Aliniați Centrul',
126+
alignJustifyLabel: 'Aliniaza Justifica',
127+
alignLeftLabel: 'Aliniați la stânga',
128+
alignRightLabel: 'Aliniați la dreapta',
129+
},
130+
rs: {
131+
alignCenterLabel: 'Centriraj',
132+
alignJustifyLabel: 'Poravnaj opravdaj',
133+
alignLeftLabel: 'Poravnaj levo',
134+
alignRightLabel: 'Poravnaj desno',
135+
},
136+
'rs-latin': {
137+
alignCenterLabel: 'Poravnaj centar',
138+
alignJustifyLabel: 'Poravnaj opravdanje',
139+
alignLeftLabel: 'Poravnaj levo',
140+
alignRightLabel: 'Poravnaj desno',
141+
},
142+
ru: {
143+
alignCenterLabel: 'Выровнять по центру',
144+
alignJustifyLabel: 'Выровнять по ширине',
145+
alignLeftLabel: 'Выровнять по левому краю',
146+
alignRightLabel: 'Выровнять по правому краю',
147+
},
148+
sk: {
149+
alignCenterLabel: 'Vycentrovať',
150+
alignJustifyLabel: 'Zarovnať do bloku',
151+
alignLeftLabel: 'Zarovnať doľava',
152+
alignRightLabel: 'Zarovnať doprava',
153+
},
154+
sv: {
155+
alignCenterLabel: 'Centrera',
156+
alignJustifyLabel: 'Justera Justify',
157+
alignLeftLabel: 'Justera till vänster',
158+
alignRightLabel: 'Justera till höger',
159+
},
160+
th: {
161+
alignCenterLabel: 'จัดแนวกึ่งกลาง',
162+
alignJustifyLabel: 'จัดแนวตรง',
163+
alignLeftLabel: 'จัดชิดซ้าย',
164+
alignRightLabel: 'จัดชิดขวา',
165+
},
166+
tr: {
167+
alignCenterLabel: 'Ortaya Hizala',
168+
alignJustifyLabel: 'Hizala Yasla',
169+
alignLeftLabel: 'Sola Hizala',
170+
alignRightLabel: 'Sağa Hizala',
171+
},
172+
uk: {
173+
alignCenterLabel: 'Вирівняти по центру',
174+
alignJustifyLabel: 'Вирівняти за шириною',
175+
alignLeftLabel: 'Вирівняти по лівому краю',
176+
alignRightLabel: 'Вирівняти по правому краю',
177+
},
178+
vi: {
179+
alignCenterLabel: 'Căn giữa',
180+
alignJustifyLabel: 'Căn đều',
181+
alignLeftLabel: 'Căn lề trái',
182+
alignRightLabel: 'Căn phải',
183+
},
184+
zh: {
185+
alignCenterLabel: '居中对齐',
186+
alignJustifyLabel: '对齐调整',
187+
alignLeftLabel: '向左对齐',
188+
alignRightLabel: '向右对齐',
189+
},
190+
'zh-TW': {
191+
alignCenterLabel: '對齊中心',
192+
alignJustifyLabel: '對齊並排列',
193+
alignLeftLabel: '向左對齊',
194+
alignRightLabel: '向右對齊',
195+
},
196+
}

packages/richtext-lexical/src/field/features/blockquote/feature.client.tsx

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { FeatureProviderProviderClient } from '../types.js'
99

1010
import { BlockquoteIcon } from '../../lexical/ui/icons/Blockquote/index.js'
1111
import { createClientComponent } from '../createClientComponent.js'
12+
import { slashMenuBasicGroupWithItems } from '../shared/slashMenu/basicGroup.js'
1213
import { toolbarTextDropdownGroupWithItems } from '../shared/toolbar/textDropdownGroup.js'
1314
import { MarkdownTransformer } from './markdownTransformer.js'
1415

@@ -28,7 +29,9 @@ const toolbarGroups: ToolbarGroup[] = [
2829
return true
2930
},
3031
key: 'blockquote',
31-
label: `Blockquote`,
32+
label: ({ i18n }) => {
33+
return i18n.t('lexical:blockquote:label')
34+
},
3235
onSelect: ({ editor }) => {
3336
editor.update(() => {
3437
const selection = $getSelection()
@@ -50,24 +53,22 @@ const BlockquoteFeatureClient: FeatureProviderProviderClient<undefined> = (props
5053

5154
slashMenu: {
5255
groups: [
53-
{
54-
items: [
55-
{
56-
Icon: BlockquoteIcon,
57-
key: 'blockquote',
58-
keywords: ['quote', 'blockquote'],
59-
label: 'Blockquote',
60-
onSelect: ({ editor }) => {
61-
editor.update(() => {
62-
const selection = $getSelection()
63-
$setBlocksType(selection, () => $createQuoteNode())
64-
})
65-
},
56+
slashMenuBasicGroupWithItems([
57+
{
58+
Icon: BlockquoteIcon,
59+
key: 'blockquote',
60+
keywords: ['quote', 'blockquote'],
61+
label: ({ i18n }) => {
62+
return i18n.t('lexical:blockquote:label')
63+
},
64+
onSelect: ({ editor }) => {
65+
editor.update(() => {
66+
const selection = $getSelection()
67+
$setBlocksType(selection, () => $createQuoteNode())
68+
})
6669
},
67-
],
68-
key: 'basic',
69-
label: 'Basic',
70-
},
70+
},
71+
]),
7172
],
7273
},
7374
toolbarFixed: {

packages/richtext-lexical/src/field/features/blockquote/feature.server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { FeatureProviderProviderServer } from '../types.js'
55
import { convertLexicalNodesToHTML } from '../converters/html/converter/index.js'
66
import { createNode } from '../typeUtilities.js'
77
import { BlockquoteFeatureClientComponent } from './feature.client.js'
8+
import { i18n } from './i18n.js'
89
import { MarkdownTransformer } from './markdownTransformer.js'
910

1011
export const BlockquoteFeature: FeatureProviderProviderServer<undefined, undefined> = (props) => {
@@ -13,6 +14,7 @@ export const BlockquoteFeature: FeatureProviderProviderServer<undefined, undefin
1314
return {
1415
ClientComponent: BlockquoteFeatureClientComponent,
1516
clientFeatureProps: null,
17+
i18n,
1618
markdownTransformers: [MarkdownTransformer],
1719
nodes: [
1820
createNode({

0 commit comments

Comments
 (0)