@plone/volto 17.0.0-alpha.6 → 17.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/CHANGELOG.md +58 -0
  3. package/locales/ca/LC_MESSAGES/volto.po +146 -0
  4. package/locales/ca.json +1 -1
  5. package/locales/de/LC_MESSAGES/volto.po +146 -0
  6. package/locales/de.json +1 -1
  7. package/locales/en/LC_MESSAGES/volto.po +146 -0
  8. package/locales/en.json +1 -1
  9. package/locales/es/LC_MESSAGES/volto.po +146 -0
  10. package/locales/es.json +1 -1
  11. package/locales/eu/LC_MESSAGES/volto.po +146 -0
  12. package/locales/eu.json +1 -1
  13. package/locales/fi/LC_MESSAGES/volto.po +4762 -0
  14. package/locales/fi.json +1 -1
  15. package/locales/fr/LC_MESSAGES/volto.po +146 -0
  16. package/locales/fr.json +1 -1
  17. package/locales/it/LC_MESSAGES/volto.po +146 -0
  18. package/locales/it.json +1 -1
  19. package/locales/ja/LC_MESSAGES/volto.po +146 -0
  20. package/locales/ja.json +1 -1
  21. package/locales/nl/LC_MESSAGES/volto.po +801 -643
  22. package/locales/nl.json +1 -1
  23. package/locales/pt/LC_MESSAGES/volto.po +146 -0
  24. package/locales/pt.json +1 -1
  25. package/locales/pt_BR/LC_MESSAGES/volto.po +146 -0
  26. package/locales/pt_BR.json +1 -1
  27. package/locales/ro/LC_MESSAGES/volto.po +146 -0
  28. package/locales/ro.json +1 -1
  29. package/locales/volto.pot +147 -1
  30. package/locales/zh_CN/LC_MESSAGES/volto.po +146 -0
  31. package/locales/zh_CN.json +1 -1
  32. package/package.json +1 -1
  33. package/packages/volto-slate/build/messages/src/blocks/Table/TableBlockEdit.json +1 -1
  34. package/packages/volto-slate/build/messages/src/blocks/Text/DefaultTextBlockEditor.json +1 -1
  35. package/packages/volto-slate/build/messages/src/blocks/Text/DetachedTextBlockEditor.json +1 -1
  36. package/packages/volto-slate/build/messages/src/blocks/Text/SlashMenu.json +1 -1
  37. package/packages/volto-slate/build/messages/src/editor/plugins/AdvancedLink/index.json +1 -1
  38. package/packages/volto-slate/build/messages/src/editor/plugins/Link/index.json +1 -1
  39. package/packages/volto-slate/build/messages/src/editor/plugins/Table/index.json +1 -1
  40. package/packages/volto-slate/build/messages/src/elementEditor/messages.json +1 -1
  41. package/packages/volto-slate/build/messages/src/widgets/HtmlSlateWidget.json +1 -1
  42. package/packages/volto-slate/build/messages/src/widgets/RichTextWidgetView.json +1 -1
  43. package/packages/volto-slate/package.json +1 -1
  44. package/packages/volto-slate/src/blocks/Text/SlashMenu.jsx +4 -3
  45. package/packages/volto-slate/src/editor/deserialize.js +0 -1
  46. package/razzle.config.js +5 -0
  47. package/src/actions/index.js +6 -0
  48. package/src/actions/language/language.js +8 -8
  49. package/src/actions/relations/rebuild.js +25 -0
  50. package/src/actions/relations/relations.js +86 -0
  51. package/src/actions/relations/relations.test.js +15 -0
  52. package/src/components/index.js +1 -0
  53. package/src/components/manage/Add/Add.jsx +2 -2
  54. package/src/components/manage/BlockChooser/BlockChooser.jsx +8 -3
  55. package/src/components/manage/BlockChooser/BlockChooser.test.jsx +5 -0
  56. package/src/components/manage/Blocks/Search/components/DateRangeFacet.jsx +4 -1
  57. package/src/components/manage/Contents/Contents.jsx +5 -1
  58. package/src/components/manage/Contents/ContentsItem.jsx +6 -0
  59. package/src/components/manage/Controlpanels/Controlpanels.jsx +9 -0
  60. package/src/components/manage/Controlpanels/Relations/BrokenRelations.jsx +66 -0
  61. package/src/components/manage/Controlpanels/Relations/Relations.jsx +114 -0
  62. package/src/components/manage/Controlpanels/Relations/RelationsListing.jsx +479 -0
  63. package/src/components/manage/Controlpanels/Relations/RelationsMatrix.jsx +531 -0
  64. package/src/components/manage/Controlpanels/Users/UserGroupMembershipControlPanel.jsx +3 -3
  65. package/src/components/manage/Controlpanels/Users/UserGroupMembershipListing.jsx +51 -82
  66. package/src/components/manage/Controlpanels/Users/UserGroupMembershipMatrix.jsx +79 -75
  67. package/src/components/manage/Multilingual/CreateTranslation.jsx +2 -2
  68. package/src/components/manage/Multilingual/TranslationObject.jsx +4 -3
  69. package/src/components/manage/Preferences/PersonalPreferences.jsx +2 -2
  70. package/src/components/manage/Toast/Toast.jsx +1 -1
  71. package/src/components/manage/Toolbar/Types.jsx +2 -2
  72. package/src/components/manage/Widgets/DatetimeWidget.jsx +9 -5
  73. package/src/components/manage/Widgets/RecurrenceWidget/ByDayField.jsx +2 -1
  74. package/src/components/manage/Widgets/RecurrenceWidget/MonthOfTheYearField.jsx +2 -1
  75. package/src/components/manage/Widgets/RecurrenceWidget/Occurences.jsx +2 -1
  76. package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +7 -2
  77. package/src/components/manage/Widgets/RecurrenceWidget/WeekdayOfTheMonthField.jsx +2 -1
  78. package/src/components/theme/Footer/Footer.jsx +2 -13
  79. package/src/components/theme/LanguageSelector/LanguageSelector.js +8 -3
  80. package/src/components/theme/Logo/Logo.jsx +2 -1
  81. package/src/components/theme/MultilingualRedirector/MultilingualRedirector.jsx +2 -2
  82. package/src/components/theme/Navigation/NavItem.jsx +4 -2
  83. package/src/components/theme/Sitemap/Sitemap.jsx +5 -3
  84. package/src/components/theme/View/EventDatesInfo.jsx +2 -1
  85. package/src/components/theme/Widgets/DateWidget.jsx +2 -1
  86. package/src/components/theme/Widgets/DatetimeWidget.jsx +2 -1
  87. package/src/components/theme/Widgets/RelationsWidget.jsx +13 -11
  88. package/src/config/ControlPanels.js +2 -0
  89. package/src/constants/ActionTypes.js +4 -0
  90. package/src/constants/Languages.js +8 -4
  91. package/src/helpers/Html/Html.jsx +3 -1
  92. package/src/helpers/Html/Html.test.jsx +5 -0
  93. package/src/helpers/MessageLabels/MessageLabels.js +72 -0
  94. package/src/helpers/Utils/Utils.js +21 -9
  95. package/src/helpers/Utils/Utils.test.js +4 -4
  96. package/src/helpers/index.js +5 -2
  97. package/src/middleware/api.js +7 -3
  98. package/src/reducers/actions/actions.js +1 -1
  99. package/src/reducers/breadcrumbs/breadcrumbs.js +1 -1
  100. package/src/reducers/index.js +2 -0
  101. package/src/reducers/navigation/navigation.js +1 -1
  102. package/src/reducers/relations/relations.js +173 -0
  103. package/src/reducers/types/types.js +1 -1
  104. package/src/routes.js +5 -0
  105. package/src/server.jsx +28 -23
  106. package/theme/themes/pastanaga/extras/userscontrolpanel.less +99 -76
  107. package/.changelog.draft +0 -33
  108. package/.editorconfig +0 -36
  109. package/.storybook/main.js +0 -127
  110. package/.storybook/manager.js +0 -15
  111. package/.storybook/preview.js +0 -21
  112. package/.storybook/static/previewImage.svg +0 -48
  113. package/.vale.ini +0 -10
  114. package/.yarnrc.yml +0 -5
  115. package/jsdoc.json +0 -16
  116. package/netlify.toml +0 -5
  117. package/pyvenv.cfg +0 -3
  118. package/share/man/man1/ttx.1 +0 -225
  119. package/styles/Vocab/Base/accept.txt +0 -0
  120. package/styles/Vocab/Base/reject.txt +0 -0
  121. package/styles/Vocab/Plone/accept.txt +0 -10
  122. package/styles/Vocab/Plone/reject.txt +0 -5
  123. package/towncrier.toml +0 -33
@@ -9,8 +9,6 @@ import { listGroups } from '@plone/volto/actions';
9
9
  import { Icon, Toast } from '@plone/volto/components';
10
10
  import { updateGroup, listUsers } from '@plone/volto/actions';
11
11
 
12
- import add from '@plone/volto/icons/add.svg';
13
- import remove from '@plone/volto/icons/remove.svg';
14
12
  import down_key from '@plone/volto/icons/down-key.svg';
15
13
 
16
14
  const ListingTemplate = ({
@@ -116,7 +114,7 @@ const ListingTemplate = ({
116
114
  }
117
115
  }, [dispatch, query_group, show_matrix_options, groups_filter]);
118
116
 
119
- const onSelectOptionHandler = (item, selectedvalue, checked, singleClick) => {
117
+ const onSelectOptionHandler = (selectedvalue, checked, singleClick) => {
120
118
  singleClick = singleClick ?? false;
121
119
  let group = selectedvalue.y;
122
120
  let username = selectedvalue.x;
@@ -150,17 +148,14 @@ const ListingTemplate = ({
150
148
  });
151
149
  };
152
150
 
153
- const onSelectAllHandler = (mtxoption, checked) => {
154
- let elements = document.querySelectorAll(`div.checkbox_${mtxoption} input`);
155
- let identifier;
151
+ const onSelectAllHandler = (group, items_ids, checked) => {
156
152
  let usersgroupmapping = {};
157
- elements.forEach((element) => {
158
- identifier = element.name.split('_-_');
159
- usersgroupmapping[identifier[1]] = checked ? true : false;
153
+ items_ids.forEach((el) => {
154
+ usersgroupmapping[el] = checked ? true : false;
160
155
  });
161
156
 
162
157
  dispatch(
163
- updateGroup(identifier[2], {
158
+ updateGroup(group, {
164
159
  users: usersgroupmapping,
165
160
  }),
166
161
  )
@@ -188,93 +183,68 @@ const ListingTemplate = ({
188
183
  <div className="administration_matrix">
189
184
  {matrix_options && matrix_options?.length > 0 && (
190
185
  <div className="label-options">
191
- {matrix_options?.map((matrix_option) => (
192
- <div
193
- className="label-options-label inclined"
194
- key={matrix_option.value}
195
- >
196
- <div>
197
- <span className="label">{matrix_option.label}</span>
186
+ <div className="target-labels">
187
+ <div>
188
+ <h3>{items.length} users</h3>
189
+ </div>
190
+ <div>
191
+ {matrix_options?.map((matrix_option) => (
192
+ <div
193
+ className="label-options-label inclined"
194
+ key={matrix_option.value}
195
+ >
196
+ <div>
197
+ <span className="label">{matrix_option.label}</span>
198
+ </div>
199
+ </div>
200
+ ))}
201
+ </div>
202
+ </div>
203
+ <div className="listing-row selectall" key="selectall">
204
+ <div className="listing-item">
205
+ <div />
206
+ <div className="matrix_options">
207
+ {matrix_options?.map((matrix_option) => (
208
+ <div key={matrix_option.value}>
209
+ <Checkbox
210
+ className="toggle-target"
211
+ defaultChecked={false}
212
+ onChange={(event, { checked }) =>
213
+ onSelectAllHandler(
214
+ matrix_option.value,
215
+ items.map((el) => el.id),
216
+ checked,
217
+ )
218
+ }
219
+ />
220
+ </div>
221
+ ))}
198
222
  </div>
199
223
  </div>
200
- ))}
224
+ </div>
201
225
  </div>
202
226
  )}
203
227
 
204
228
  <div className="items">
205
229
  {items.length > 0 ? (
206
230
  <>
207
- <div className="listing-row selectall" key="selectall">
208
- <div className="listing-item">
209
- <div />
210
- <div className="matrix_options">
211
- {matrix_options?.map((matrix_option) => (
212
- <div key={matrix_option.value}>
213
- <Button
214
- icon
215
- basic
216
- onClick={() =>
217
- onSelectAllHandler(matrix_option.value, true)
218
- }
219
- className="add-button"
220
- aria-label={
221
- intl.formatMessage(messages.addUsersToGroup) +
222
- ` ${matrix_option.label}`
223
- }
224
- title={
225
- intl.formatMessage(messages.addUsersToGroup) +
226
- ` ${matrix_option.label}`
227
- }
228
- >
229
- <Icon
230
- name={add}
231
- size="10px"
232
- className="circled"
233
- color="unset"
234
- />
235
- </Button>
236
- <Button
237
- icon
238
- basic
239
- onClick={() =>
240
- onSelectAllHandler(matrix_option.value, false)
241
- }
242
- className="remove-button"
243
- aria-label={
244
- intl.formatMessage(messages.removeUsersFromGroup) +
245
- ` ${matrix_option.label}`
246
- }
247
- title={
248
- intl.formatMessage(messages.removeUsersFromGroup) +
249
- ` ${matrix_option.label}`
250
- }
251
- >
252
- <Icon
253
- name={remove}
254
- size="10px"
255
- className="circled"
256
- color="unset"
257
- />
258
- </Button>
259
- </div>
260
- ))}
261
- </div>
262
- </div>
263
- </div>
264
-
265
- <h3>{items.length} users </h3>
266
231
  {items.map((item) => (
267
- <div className="listing-row" key={item.id}>
232
+ <div
233
+ className="listing-row"
234
+ key={item.id}
235
+ id={`source-row-${item.id}`}
236
+ >
268
237
  <div className="listing-item" key={item['@id']}>
269
238
  <div>
270
- <h4>
271
- {item.fullname} ({item.id})
239
+ <h4 title={`${item.fullname} ${item.id}`}>
240
+ {item.fullname?.length > 25
241
+ ? item.fullname.slice(0, 22) + '...'
242
+ : item.fullname || item.id}
272
243
  </h4>
273
244
  </div>
274
245
  <div className="matrix_options">
275
246
  {matrix_options?.map((matrix_option) => (
276
247
  <Checkbox
277
- name={`member_-_${item.id}_-_${matrix_option.value}`}
278
248
  className={`checkbox_${matrix_option.value}`}
279
249
  key={matrix_option.value}
280
250
  title={matrix_option.title}
@@ -283,7 +253,6 @@ const ListingTemplate = ({
283
253
  .includes(matrix_option.value)}
284
254
  onChange={(event, { checked }) => {
285
255
  onSelectOptionHandler(
286
- item,
287
256
  { y: matrix_option.value, x: item.id },
288
257
  checked,
289
258
  true,
@@ -122,83 +122,87 @@ const UserGroupMembershipMatrix = ({ many_users, many_groups }) => {
122
122
 
123
123
  return (
124
124
  <div className="controlpanel_matrix">
125
- <div className="controlpanel_search_y">
126
- <Form className="search_users" onSubmit={onReset}>
127
- <Form.Field>
128
- <Input
129
- name="SearchUser"
130
- action={{ icon: 'delete' }}
131
- placeholder={intl.formatMessage(messages.searchUsers)}
132
- onChange={onChangeSearchUsers}
133
- onKeyDown={onChangeSearchUsers}
134
- id="user-search-input"
135
- />
136
- </Form.Field>
137
- </Form>
125
+ <div className="controlpanel_search_wrapper">
126
+ <div className="controlpanel_search_y">
127
+ <Form className="search_users" onSubmit={onReset}>
128
+ <Form.Field>
129
+ <Input
130
+ name="SearchUser"
131
+ action={{ icon: 'delete' }}
132
+ placeholder={intl.formatMessage(messages.searchUsers)}
133
+ onChange={onChangeSearchUsers}
134
+ onKeyDown={onChangeSearchUsers}
135
+ id="user-search-input"
136
+ />
137
+ </Form.Field>
138
+ </Form>
139
+ </div>
140
+ <div className="controlpanel_search_x">
141
+ <Form className="search_groups" onSubmit={onReset}>
142
+ <Form.Field>
143
+ <Input
144
+ name="SearchGroup"
145
+ action={{ icon: 'delete' }}
146
+ placeholder={intl.formatMessage(messages.searchGroups)}
147
+ onChange={onChangeSearchGroups}
148
+ onKeyDown={onChangeSearchGroups}
149
+ id="group-search-input"
150
+ />
151
+ </Form.Field>
152
+ <Form.Field>
153
+ <Checkbox
154
+ name="addJoinedGroups"
155
+ label={intl.formatMessage(messages.addJoinedGroups)}
156
+ title={intl.formatMessage(messages.addJoinedGroups)}
157
+ defaultChecked={false}
158
+ onChange={(event, { checked }) => {
159
+ onToggleJoinedGroups(checked);
160
+ }}
161
+ />
162
+ </Form.Field>
163
+ </Form>
164
+ </div>
138
165
  </div>
139
- <div className="controlpanel_search_x">
140
- <Form className="search_groups" onSubmit={onReset}>
141
- <Form.Field>
142
- <Input
143
- name="SearchGroup"
144
- action={{ icon: 'delete' }}
145
- placeholder={intl.formatMessage(messages.searchGroups)}
146
- onChange={onChangeSearchGroups}
147
- onKeyDown={onChangeSearchGroups}
148
- id="group-search-input"
149
- />
150
- </Form.Field>
151
- <Form.Field>
152
- <Checkbox
153
- name="addJoinedGroups"
154
- label={intl.formatMessage(messages.addJoinedGroups)}
155
- title={intl.formatMessage(messages.addJoinedGroups)}
156
- defaultChecked={false}
157
- onChange={(event, { checked }) => {
158
- onToggleJoinedGroups(checked);
159
- }}
160
- />
161
- </Form.Field>
162
- </Form>
166
+ <div className="controlpanel_listing_wrapper">
167
+ <div className="controlpanel_filter">
168
+ <h3>{intl.formatMessage(messages.filterByGroups)}</h3>
169
+ <Form className="search_filter_groups" onSubmit={onReset}>
170
+ <Form.Field>
171
+ <Input
172
+ name="SearchGroupFilter"
173
+ action={{ icon: 'delete' }}
174
+ placeholder={intl.formatMessage(messages.searchGroups)}
175
+ onChange={onChangeSearchGroupsFilter}
176
+ onKeyDown={onChangeSearchGroupsFilter}
177
+ id="groupfilter-search-input"
178
+ />
179
+ </Form.Field>
180
+ </Form>
181
+ {(!many_groups || query_group_filter.length > 1) &&
182
+ filter_options?.map((filter_option) => (
183
+ <Form.Field>
184
+ <Checkbox
185
+ name={`filter_option_${filter_option.value}`}
186
+ key={filter_option.value}
187
+ title={filter_option.label}
188
+ label={filter_option.label}
189
+ defaultChecked={false}
190
+ onChange={(event, { checked }) => {
191
+ onSelectOptionHandler(filter_option, checked);
192
+ }}
193
+ />
194
+ </Form.Field>
195
+ ))}
196
+ </div>
197
+ <UserGroupMembershipListing
198
+ query_user={query_user}
199
+ query_group={query_group}
200
+ groups_filter={groups_filter}
201
+ add_joined_groups={add_joined_groups}
202
+ many_users={many_users}
203
+ many_groups={many_groups}
204
+ />
163
205
  </div>
164
- <div className="controlpanel_filter">
165
- <h3>{intl.formatMessage(messages.filterByGroups)}</h3>
166
-
167
- <Form className="search_filter_groups" onSubmit={onReset}>
168
- <Form.Field>
169
- <Input
170
- name="SearchGroupFilter"
171
- action={{ icon: 'delete' }}
172
- placeholder={intl.formatMessage(messages.searchGroups)}
173
- onChange={onChangeSearchGroupsFilter}
174
- onKeyDown={onChangeSearchGroupsFilter}
175
- id="groupfilter-search-input"
176
- />
177
- </Form.Field>
178
- </Form>
179
-
180
- {(!many_groups || query_group_filter.length > 1) &&
181
- filter_options?.map((filter_option) => (
182
- <Checkbox
183
- name={`filter_option_${filter_option.value}`}
184
- key={filter_option.value}
185
- title={filter_option.label}
186
- label={filter_option.label}
187
- defaultChecked={false}
188
- onChange={(event, { checked }) => {
189
- onSelectOptionHandler(filter_option, checked);
190
- }}
191
- />
192
- ))}
193
- </div>
194
- <UserGroupMembershipListing
195
- query_user={query_user}
196
- query_group={query_group}
197
- groups_filter={groups_filter}
198
- add_joined_groups={add_joined_groups}
199
- many_users={many_users}
200
- many_groups={many_groups}
201
- />
202
206
  </div>
203
207
  );
204
208
  };
@@ -6,7 +6,7 @@ import {
6
6
  getTranslationLocator,
7
7
  getContent,
8
8
  } from '@plone/volto/actions';
9
- import { flattenToAppURL, normalizeLanguageName } from '@plone/volto/helpers';
9
+ import { flattenToAppURL, toGettextLang } from '@plone/volto/helpers';
10
10
  import config from '@plone/volto/registry';
11
11
 
12
12
  const CreateTranslation = (props) => {
@@ -33,7 +33,7 @@ const CreateTranslation = (props) => {
33
33
  return () => {
34
34
  // We change the interface language
35
35
  if (config.settings.supportedLanguages.includes(language)) {
36
- const langFileName = normalizeLanguageName(language);
36
+ const langFileName = toGettextLang(language);
37
37
  import('@root/../locales/' + langFileName + '.json').then((locale) => {
38
38
  dispatch(changeLanguage(language, locale.default));
39
39
  });
@@ -15,7 +15,8 @@ import {
15
15
  Api,
16
16
  flattenToAppURL,
17
17
  langmap,
18
- normalizeLanguageName,
18
+ toGettextLang,
19
+ toReactIntlLang,
19
20
  } from '@plone/volto/helpers';
20
21
  import { createBrowserHistory } from 'history';
21
22
  const messages = defineMessages({
@@ -55,9 +56,9 @@ const TranslationObject = ({
55
56
  setLoadingLocale(true);
56
57
  let lang =
57
58
  config.settings.supportedLanguages[Object.keys(locales).length];
58
- const langFileName = normalizeLanguageName(lang);
59
+ const langFileName = toGettextLang(lang);
59
60
  import('@root/../locales/' + langFileName + '.json').then((locale) => {
60
- setLocales({ ...locales, [lang]: locale.default });
61
+ setLocales({ ...locales, [toReactIntlLang(lang)]: locale.default });
61
62
  setLoadingLocale(false);
62
63
  });
63
64
  }
@@ -15,7 +15,7 @@ import { toast } from 'react-toastify';
15
15
  import { Form, Toast } from '@plone/volto/components';
16
16
  import languages from '@plone/volto/constants/Languages';
17
17
  import { changeLanguage } from '@plone/volto/actions';
18
- import { normalizeLanguageName } from '@plone/volto/helpers';
18
+ import { toGettextLang } from '@plone/volto/helpers';
19
19
  import config from '@plone/volto/registry';
20
20
 
21
21
  const messages = defineMessages({
@@ -86,7 +86,7 @@ class PersonalPreferences extends Component {
86
86
  onSubmit(data) {
87
87
  let language = data.language || 'en';
88
88
  if (config.settings.supportedLanguages.includes(language)) {
89
- const langFileName = normalizeLanguageName(language);
89
+ const langFileName = toGettextLang(language);
90
90
  import('@root/../locales/' + langFileName + '.json').then((locale) => {
91
91
  this.props.changeLanguage(language, locale.default);
92
92
  });
@@ -15,7 +15,7 @@ const Toast = (props) => {
15
15
  return successSVG;
16
16
  } else if (props.error) {
17
17
  return errorSVG;
18
- } else if (props.error) {
18
+ } else if (props.warning) {
19
19
  return warningSVG;
20
20
  } else {
21
21
  return successSVG;
@@ -4,7 +4,7 @@ import { connect } from 'react-redux';
4
4
  import { Link } from 'react-router-dom';
5
5
  import { filter, find, isEmpty, map } from 'lodash';
6
6
  import { FormattedMessage } from 'react-intl';
7
- import { flattenToAppURL, langmap } from '@plone/volto/helpers';
7
+ import { flattenToAppURL, langmap, toBackendLang } from '@plone/volto/helpers';
8
8
  import config from '@plone/volto/registry';
9
9
 
10
10
  const Types = ({ types, pathname, content, currentLanguage }) => {
@@ -59,7 +59,7 @@ const Types = ({ types, pathname, content, currentLanguage }) => {
59
59
  find(content['@components'].translations.items, {
60
60
  language: lang,
61
61
  }),
62
- ) && currentLanguage !== lang,
62
+ ) && toBackendLang(currentLanguage) !== lang,
63
63
  );
64
64
 
65
65
  return (
@@ -10,7 +10,7 @@ import { connect } from 'react-redux';
10
10
  import loadable from '@loadable/component';
11
11
  import cx from 'classnames';
12
12
  import { Icon, FormFieldWrapper } from '@plone/volto/components';
13
- import { parseDateTime } from '@plone/volto/helpers';
13
+ import { parseDateTime, toBackendLang } from '@plone/volto/helpers';
14
14
  import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
15
15
 
16
16
  import leftKey from '@plone/volto/icons/left-key.svg';
@@ -101,7 +101,7 @@ export class DatetimeWidgetComponent extends Component {
101
101
  // if passed value matches the construction time, we guess it's a default
102
102
  isDefault:
103
103
  parseDateTime(
104
- this.props.lang,
104
+ toBackendLang(this.props.lang),
105
105
  this.props.value,
106
106
  undefined,
107
107
  this.moment,
@@ -111,7 +111,7 @@ export class DatetimeWidgetComponent extends Component {
111
111
 
112
112
  getInternalValue() {
113
113
  return parseDateTime(
114
- this.props.lang,
114
+ toBackendLang(this.props.lang),
115
115
  this.props.value,
116
116
  undefined,
117
117
  this.moment,
@@ -211,7 +211,9 @@ export class DatetimeWidgetComponent extends Component {
211
211
  {...(noPastDates ? {} : { isOutsideRange: () => false })}
212
212
  onFocusChange={this.onFocusChange}
213
213
  noBorder
214
- displayFormat={moment.localeData(lang).longDateFormat('L')}
214
+ displayFormat={moment
215
+ .localeData(toBackendLang(lang))
216
+ .longDateFormat('L')}
215
217
  navPrev={<PrevIcon />}
216
218
  navNext={<NextIcon />}
217
219
  id={`${id}-date`}
@@ -233,7 +235,9 @@ export class DatetimeWidgetComponent extends Component {
233
235
  showSecond={false}
234
236
  use12Hours={lang === 'en'}
235
237
  id={`${id}-time`}
236
- format={moment.localeData(lang).longDateFormat('LT')}
238
+ format={moment
239
+ .localeData(toBackendLang(lang))
240
+ .longDateFormat('LT')}
237
241
  placeholder={intl.formatMessage(messages.time)}
238
242
  focusOnOpen
239
243
  placement="bottomRight"
@@ -7,6 +7,7 @@ import React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { Form, Grid, Button } from 'semantic-ui-react';
9
9
  import { Days } from './Utils';
10
+ import { toBackendLang } from '@plone/volto/helpers';
10
11
  import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
11
12
  import { useSelector } from 'react-redux';
12
13
 
@@ -18,7 +19,7 @@ import { useSelector } from 'react-redux';
18
19
  const ByDayField = ({ label, value, onChange, moment: momentlib }) => {
19
20
  const lang = useSelector((state) => state.intl.locale);
20
21
  const moment = momentlib.default;
21
- moment.locale(lang);
22
+ moment.locale(toBackendLang(lang));
22
23
 
23
24
  const toggleWeekDay = (dayName) => {
24
25
  var day = Days[dayName];
@@ -8,6 +8,7 @@ import PropTypes from 'prop-types';
8
8
  import { map } from 'lodash';
9
9
  import { Form } from 'semantic-ui-react';
10
10
  import SelectInput from './SelectInput';
11
+ import { toBackendLang } from '@plone/volto/helpers';
11
12
  import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
12
13
  import { useSelector } from 'react-redux';
13
14
 
@@ -25,7 +26,7 @@ const MonthOfTheYearField = ({
25
26
  }) => {
26
27
  const moment = momentlib.default;
27
28
  const lang = useSelector((state) => state.intl.locale);
28
- moment.locale(lang);
29
+ moment.locale(toBackendLang(lang));
29
30
  const monthList = [
30
31
  ...map(moment.months(), (m, i) => ({
31
32
  value: i + 1,
@@ -11,6 +11,7 @@ import { List, Button, Header, Label } from 'semantic-ui-react';
11
11
  import { Icon } from '@plone/volto/components';
12
12
  import addSVG from '@plone/volto/icons/circle-plus.svg';
13
13
  import trashSVG from '@plone/volto/icons/delete.svg';
14
+ import { toBackendLang } from '@plone/volto/helpers';
14
15
  import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
15
16
 
16
17
  import { useSelector } from 'react-redux';
@@ -68,7 +69,7 @@ const Occurences_ = ({
68
69
  }) => {
69
70
  const moment = momentlib.default;
70
71
  const lang = useSelector((state) => state.intl.locale);
71
- moment.locale(lang);
72
+ moment.locale(toBackendLang(lang));
72
73
  let all = [];
73
74
  const isExcluded = (date) => {
74
75
  var dateISO = toISOString(date);
@@ -23,6 +23,7 @@ import {
23
23
  } from 'semantic-ui-react';
24
24
 
25
25
  import { SelectWidget, Icon, DatetimeWidget } from '@plone/volto/components';
26
+ import { toBackendLang } from '@plone/volto/helpers';
26
27
  import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
27
28
 
28
29
  import saveSVG from '@plone/volto/icons/save.svg';
@@ -183,7 +184,7 @@ class RecurrenceWidget extends Component {
183
184
  const { RRuleSet, rrulestr } = props.rrule;
184
185
 
185
186
  this.moment = this.props.moment.default;
186
- this.moment.locale(this.props.lang);
187
+ this.moment.locale(toBackendLang(this.props.lang));
187
188
 
188
189
  let rruleSet = this.props.value
189
190
  ? rrulestr(props.value, {
@@ -201,7 +202,11 @@ class RecurrenceWidget extends Component {
201
202
  open: false,
202
203
  rruleSet: rruleSet,
203
204
  formValues: this.getFormValues(rruleSet),
204
- RRULE_LANGUAGE: rrulei18n(this.props.intl, this.moment, this.props.lang),
205
+ RRULE_LANGUAGE: rrulei18n(
206
+ this.props.intl,
207
+ this.moment,
208
+ toBackendLang(this.props.lang),
209
+ ),
205
210
  };
206
211
  }
207
212
 
@@ -8,6 +8,7 @@ import { map } from 'lodash';
8
8
  import { Days } from './Utils';
9
9
  import SelectInput from './SelectInput';
10
10
  import { Form } from 'semantic-ui-react';
11
+ import { toBackendLang } from '@plone/volto/helpers';
11
12
  import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
12
13
  import { useSelector } from 'react-redux';
13
14
 
@@ -22,7 +23,7 @@ const WeekdayOfTheMonthField = (props) => {
22
23
  const lang = useSelector((state) => state.intl.locale);
23
24
 
24
25
  const moment = momentlib.default;
25
- moment.locale(lang);
26
+ moment.locale(toBackendLang(lang));
26
27
 
27
28
  const weekdayOfTheMonthList = [
28
29
  ...map(Object.keys(Days), (d) => ({
@@ -9,7 +9,6 @@ import { map } from 'lodash';
9
9
  import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
10
10
  import { useSelector, shallowEqual } from 'react-redux';
11
11
  import { UniversalLink } from '@plone/volto/components';
12
- import config from '@plone/volto/registry';
13
12
  import { flattenToAppURL, addAppURL } from '@plone/volto/helpers';
14
13
 
15
14
  const messages = defineMessages({
@@ -26,10 +25,8 @@ const messages = defineMessages({
26
25
  * @returns {string} Markup of the component
27
26
  */
28
27
  const Footer = ({ intl }) => {
29
- const { settings } = config;
30
- const { lang, siteActions = [] } = useSelector(
28
+ const { siteActions = [] } = useSelector(
31
29
  (state) => ({
32
- lang: state.intl.locale,
33
30
  siteActions: state.actions?.actions?.site_actions,
34
31
  }),
35
32
  shallowEqual,
@@ -97,15 +94,7 @@ const Footer = ({ intl }) => {
97
94
  <UniversalLink
98
95
  className="item"
99
96
  href={
100
- settings.isMultilingual
101
- ? `/${lang}/${
102
- item.url
103
- ? flattenToAppURL(item.url)
104
- : addAppURL(item.id)
105
- }`
106
- : item.url
107
- ? flattenToAppURL(item.url)
108
- : addAppURL(item.id)
97
+ item.url ? flattenToAppURL(item.url) : addAppURL(item.id)
109
98
  }
110
99
  >
111
100
  {item?.title}
@@ -11,7 +11,12 @@ import { useSelector } from 'react-redux';
11
11
  import cx from 'classnames';
12
12
  import { find, map } from 'lodash';
13
13
 
14
- import { Helmet, langmap, flattenToAppURL } from '@plone/volto/helpers';
14
+ import {
15
+ Helmet,
16
+ langmap,
17
+ flattenToAppURL,
18
+ toReactIntlLang,
19
+ } from '@plone/volto/helpers';
15
20
 
16
21
  import config from '@plone/volto/registry';
17
22
 
@@ -42,7 +47,7 @@ const LanguageSelector = (props) => {
42
47
  aria-label={`${intl.formatMessage(
43
48
  messages.switchLanguageTo,
44
49
  )} ${langmap[lang].nativeName.toLowerCase()}`}
45
- className={cx({ selected: lang === currentLang })}
50
+ className={cx({ selected: toReactIntlLang(lang) === currentLang })}
46
51
  to={translation ? flattenToAppURL(translation['@id']) : `/${lang}`}
47
52
  title={langmap[lang].nativeName}
48
53
  onClick={() => {
@@ -57,7 +62,7 @@ const LanguageSelector = (props) => {
57
62
  </div>
58
63
  ) : (
59
64
  <Helmet>
60
- <html lang={settings.defaultLanguage} />
65
+ <html lang={toReactIntlLang(settings.defaultLanguage)} />
61
66
  </Helmet>
62
67
  );
63
68
  };