@strapi/i18n 0.0.0 → 5.0.0-beta.11

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 (165) hide show
  1. package/README.md +17 -1
  2. package/dist/_chunks/SettingsPage-B5sTcP82.mjs +554 -0
  3. package/dist/_chunks/SettingsPage-B5sTcP82.mjs.map +1 -0
  4. package/dist/_chunks/SettingsPage-DT1sxWa2.js +574 -0
  5. package/dist/_chunks/SettingsPage-DT1sxWa2.js.map +1 -0
  6. package/dist/_chunks/de-9eCAqqrB.mjs +66 -0
  7. package/dist/_chunks/de-9eCAqqrB.mjs.map +1 -0
  8. package/dist/_chunks/de-DtWiGdHl.js +66 -0
  9. package/dist/_chunks/de-DtWiGdHl.js.map +1 -0
  10. package/dist/_chunks/dk-2qBjxt-P.mjs +66 -0
  11. package/dist/_chunks/dk-2qBjxt-P.mjs.map +1 -0
  12. package/dist/_chunks/dk-D8C-casx.js +66 -0
  13. package/dist/_chunks/dk-D8C-casx.js.map +1 -0
  14. package/dist/_chunks/en-BsOU9o5z.js +74 -0
  15. package/dist/_chunks/en-BsOU9o5z.js.map +1 -0
  16. package/dist/_chunks/en-CM6Pjfyv.mjs +74 -0
  17. package/dist/_chunks/en-CM6Pjfyv.mjs.map +1 -0
  18. package/dist/_chunks/es-DS-XFGSw.js +66 -0
  19. package/dist/_chunks/es-DS-XFGSw.js.map +1 -0
  20. package/dist/_chunks/es-DlmMVaBG.mjs +66 -0
  21. package/dist/_chunks/es-DlmMVaBG.mjs.map +1 -0
  22. package/dist/_chunks/fr-3S6ke71d.mjs +66 -0
  23. package/dist/_chunks/fr-3S6ke71d.mjs.map +1 -0
  24. package/dist/_chunks/fr-BTjekDpq.js +66 -0
  25. package/dist/_chunks/fr-BTjekDpq.js.map +1 -0
  26. package/dist/_chunks/index-DsNqyQKx.mjs +1369 -0
  27. package/dist/_chunks/index-DsNqyQKx.mjs.map +1 -0
  28. package/dist/_chunks/index-jMrzaEb9.js +1391 -0
  29. package/dist/_chunks/index-jMrzaEb9.js.map +1 -0
  30. package/dist/_chunks/ko-DmcGUBQ3.js +65 -0
  31. package/dist/_chunks/ko-DmcGUBQ3.js.map +1 -0
  32. package/dist/_chunks/ko-qTjQ8IMw.mjs +65 -0
  33. package/dist/_chunks/ko-qTjQ8IMw.mjs.map +1 -0
  34. package/dist/_chunks/pl-B67TSHqT.mjs +66 -0
  35. package/dist/_chunks/pl-B67TSHqT.mjs.map +1 -0
  36. package/dist/_chunks/pl-Cn5RYonZ.js +66 -0
  37. package/dist/_chunks/pl-Cn5RYonZ.js.map +1 -0
  38. package/dist/_chunks/ru-BMBgVL3s.js +68 -0
  39. package/dist/_chunks/ru-BMBgVL3s.js.map +1 -0
  40. package/dist/_chunks/ru-hagMa57T.mjs +68 -0
  41. package/dist/_chunks/ru-hagMa57T.mjs.map +1 -0
  42. package/dist/_chunks/tr-CarUU76c.js +66 -0
  43. package/dist/_chunks/tr-CarUU76c.js.map +1 -0
  44. package/dist/_chunks/tr-Dw_jmkG-.mjs +66 -0
  45. package/dist/_chunks/tr-Dw_jmkG-.mjs.map +1 -0
  46. package/dist/_chunks/zh-57YM4amO.mjs +66 -0
  47. package/dist/_chunks/zh-57YM4amO.mjs.map +1 -0
  48. package/dist/_chunks/zh-CukOviB0.js +66 -0
  49. package/dist/_chunks/zh-CukOviB0.js.map +1 -0
  50. package/dist/_chunks/zh-Hans-DSHIXAa3.js +57 -0
  51. package/dist/_chunks/zh-Hans-DSHIXAa3.js.map +1 -0
  52. package/dist/_chunks/zh-Hans-Dyc-aR-h.mjs +57 -0
  53. package/dist/_chunks/zh-Hans-Dyc-aR-h.mjs.map +1 -0
  54. package/dist/admin/index.js +6 -0
  55. package/dist/admin/index.js.map +1 -0
  56. package/dist/admin/index.mjs +7 -0
  57. package/dist/admin/index.mjs.map +1 -0
  58. package/dist/admin/src/components/BulkLocaleActionModal.d.ts +15 -0
  59. package/dist/admin/src/components/CMHeaderActions.d.ts +10 -0
  60. package/dist/admin/src/components/CMListViewModalsAdditionalInformation.d.ts +4 -0
  61. package/dist/admin/src/components/CheckboxConfirmation.d.ts +20 -0
  62. package/dist/admin/src/components/CreateLocale.d.ts +29 -0
  63. package/dist/admin/src/components/DeleteLocale.d.ts +5 -0
  64. package/dist/admin/src/components/EditLocale.d.ts +14 -0
  65. package/dist/admin/src/components/Initializer.d.ts +5 -0
  66. package/dist/admin/src/components/LocaleListCell.d.ts +9 -0
  67. package/dist/admin/src/components/LocalePicker.d.ts +2 -0
  68. package/dist/admin/src/components/LocaleTable.d.ts +11 -0
  69. package/dist/admin/src/constants.d.ts +22 -0
  70. package/dist/admin/src/contentManagerHooks/editView.d.ts +6 -0
  71. package/dist/admin/src/contentManagerHooks/listView.d.ts +22 -0
  72. package/dist/admin/src/contentReleasesHooks/releaseDetailsView.d.ts +40 -0
  73. package/dist/admin/src/hooks/useI18n.d.ts +16 -0
  74. package/dist/admin/src/index.d.ts +16 -0
  75. package/dist/admin/src/middlewares/extendCTBAttributeInitialData.d.ts +4 -0
  76. package/dist/admin/src/middlewares/extendCTBInitialData.d.ts +4 -0
  77. package/dist/admin/src/middlewares/rbac-middleware.d.ts +3 -0
  78. package/dist/admin/src/pages/SettingsPage.d.ts +3 -0
  79. package/dist/admin/src/pluginId.d.ts +1 -0
  80. package/dist/admin/src/services/api.d.ts +2 -0
  81. package/dist/admin/src/services/locales.d.ts +4 -0
  82. package/dist/admin/src/services/relations.d.ts +7 -0
  83. package/dist/admin/src/types.d.ts +9 -0
  84. package/dist/admin/src/utils/baseQuery.d.ts +5 -0
  85. package/dist/admin/src/utils/fields.d.ts +7 -0
  86. package/dist/admin/src/utils/getTranslation.d.ts +2 -0
  87. package/dist/admin/src/utils/prefixPluginTranslations.d.ts +3 -0
  88. package/dist/admin/src/utils/schemas.d.ts +24 -0
  89. package/dist/admin/src/utils/strings.d.ts +2 -0
  90. package/dist/server/index.js +3522 -0
  91. package/dist/server/index.js.map +1 -0
  92. package/dist/server/index.mjs +3503 -0
  93. package/dist/server/index.mjs.map +1 -0
  94. package/dist/server/src/bootstrap.d.ts +6 -0
  95. package/dist/server/src/bootstrap.d.ts.map +1 -0
  96. package/dist/server/src/constants/index.d.ts +15 -0
  97. package/dist/server/src/constants/index.d.ts.map +1 -0
  98. package/dist/server/src/content-types/index.d.ts +37 -0
  99. package/dist/server/src/content-types/index.d.ts.map +1 -0
  100. package/dist/server/src/content-types/locale/index.d.ts +35 -0
  101. package/dist/server/src/content-types/locale/index.d.ts.map +1 -0
  102. package/dist/server/src/controllers/content-types.d.ts +6 -0
  103. package/dist/server/src/controllers/content-types.d.ts.map +1 -0
  104. package/dist/server/src/controllers/index.d.ts +10 -0
  105. package/dist/server/src/controllers/index.d.ts.map +1 -0
  106. package/dist/server/src/controllers/iso-locales.d.ts +4 -0
  107. package/dist/server/src/controllers/iso-locales.d.ts.map +1 -0
  108. package/dist/server/src/controllers/locales.d.ts +4 -0
  109. package/dist/server/src/controllers/locales.d.ts.map +1 -0
  110. package/dist/server/src/controllers/validate-locale-creation.d.ts +4 -0
  111. package/dist/server/src/controllers/validate-locale-creation.d.ts.map +1 -0
  112. package/dist/server/src/domain/locale.d.ts +11 -0
  113. package/dist/server/src/domain/locale.d.ts.map +1 -0
  114. package/dist/server/src/graphql.d.ts +8 -0
  115. package/dist/server/src/graphql.d.ts.map +1 -0
  116. package/dist/server/src/index.d.ts +148 -0
  117. package/dist/server/src/index.d.ts.map +1 -0
  118. package/dist/server/src/migrations/content-type/disable/index.d.ts +3 -0
  119. package/dist/server/src/migrations/content-type/disable/index.d.ts.map +1 -0
  120. package/dist/server/src/migrations/content-type/enable/index.d.ts +3 -0
  121. package/dist/server/src/migrations/content-type/enable/index.d.ts.map +1 -0
  122. package/dist/server/src/register.d.ts +6 -0
  123. package/dist/server/src/register.d.ts.map +1 -0
  124. package/dist/server/src/routes/admin.d.ts +18 -0
  125. package/dist/server/src/routes/admin.d.ts.map +1 -0
  126. package/dist/server/src/routes/content-api.d.ts +10 -0
  127. package/dist/server/src/routes/content-api.d.ts.map +1 -0
  128. package/dist/server/src/routes/index.d.ts +28 -0
  129. package/dist/server/src/routes/index.d.ts.map +1 -0
  130. package/dist/server/src/services/content-types.d.ts +13 -0
  131. package/dist/server/src/services/content-types.d.ts.map +1 -0
  132. package/dist/server/src/services/entity-service-decorator.d.ts +29 -0
  133. package/dist/server/src/services/entity-service-decorator.d.ts.map +1 -0
  134. package/dist/server/src/services/index.d.ts +71 -0
  135. package/dist/server/src/services/index.d.ts.map +1 -0
  136. package/dist/server/src/services/iso-locales.d.ts +10 -0
  137. package/dist/server/src/services/iso-locales.d.ts.map +1 -0
  138. package/dist/server/src/services/locales.d.ts +17 -0
  139. package/dist/server/src/services/locales.d.ts.map +1 -0
  140. package/dist/server/src/services/localizations.d.ts +8 -0
  141. package/dist/server/src/services/localizations.d.ts.map +1 -0
  142. package/dist/server/src/services/metrics.d.ts +8 -0
  143. package/dist/server/src/services/metrics.d.ts.map +1 -0
  144. package/dist/server/src/services/permissions/actions.d.ts +16 -0
  145. package/dist/server/src/services/permissions/actions.d.ts.map +1 -0
  146. package/dist/server/src/services/permissions/conditions.d.ts +15 -0
  147. package/dist/server/src/services/permissions/conditions.d.ts.map +1 -0
  148. package/dist/server/src/services/permissions/engine.d.ts +6 -0
  149. package/dist/server/src/services/permissions/engine.d.ts.map +1 -0
  150. package/dist/server/src/services/permissions/sections-builder.d.ts +6 -0
  151. package/dist/server/src/services/permissions/sections-builder.d.ts.map +1 -0
  152. package/dist/server/src/services/permissions.d.ts +28 -0
  153. package/dist/server/src/services/permissions.d.ts.map +1 -0
  154. package/dist/server/src/utils/index.d.ts +43 -0
  155. package/dist/server/src/utils/index.d.ts.map +1 -0
  156. package/dist/server/src/validation/content-types.d.ts +3 -0
  157. package/dist/server/src/validation/content-types.d.ts.map +1 -0
  158. package/dist/server/src/validation/locales.d.ts +12 -0
  159. package/dist/server/src/validation/locales.d.ts.map +1 -0
  160. package/dist/shared/contracts/content-manager.d.ts +46 -0
  161. package/dist/shared/contracts/iso-locales.d.ts +21 -0
  162. package/dist/shared/contracts/locales.d.ts +77 -0
  163. package/dist/shared/contracts/shared.d.ts +6 -0
  164. package/package.json +82 -4
  165. package/strapi-server.js +3 -0
@@ -0,0 +1,1391 @@
1
+ "use strict";
2
+ const get = require("lodash/get");
3
+ const yup = require("yup");
4
+ const jsxRuntime = require("react/jsx-runtime");
5
+ const React = require("react");
6
+ const designSystem = require("@strapi/design-system");
7
+ const icons = require("@strapi/icons");
8
+ const reactIntl = require("react-intl");
9
+ const styledComponents = require("styled-components");
10
+ const strapiAdmin = require("@strapi/admin/strapi-admin");
11
+ const strapiAdmin$1 = require("@strapi/content-manager/strapi-admin");
12
+ const reactRouterDom = require("react-router-dom");
13
+ const qs = require("qs");
14
+ const omit = require("lodash/omit");
15
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
16
+ function _interopNamespace(e) {
17
+ if (e && e.__esModule)
18
+ return e;
19
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
20
+ if (e) {
21
+ for (const k in e) {
22
+ if (k !== "default") {
23
+ const d = Object.getOwnPropertyDescriptor(e, k);
24
+ Object.defineProperty(n, k, d.get ? d : {
25
+ enumerable: true,
26
+ get: () => e[k]
27
+ });
28
+ }
29
+ }
30
+ }
31
+ n.default = e;
32
+ return Object.freeze(n);
33
+ }
34
+ const get__default = /* @__PURE__ */ _interopDefault(get);
35
+ const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
36
+ const React__namespace = /* @__PURE__ */ _interopNamespace(React);
37
+ const qs__namespace = /* @__PURE__ */ _interopNamespace(qs);
38
+ const omit__default = /* @__PURE__ */ _interopDefault(omit);
39
+ const __variableDynamicImportRuntimeHelper = (glob, path) => {
40
+ const v = glob[path];
41
+ if (v) {
42
+ return typeof v === "function" ? v() : Promise.resolve(v);
43
+ }
44
+ return new Promise((_, reject) => {
45
+ (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(reject.bind(null, new Error("Unknown variable dynamic import: " + path)));
46
+ });
47
+ };
48
+ const pluginId = "i18n";
49
+ const getTranslation = (id) => `${pluginId}.${id}`;
50
+ const TextAlignTypography = styledComponents.styled(designSystem.Typography)`
51
+ text-align: center;
52
+ `;
53
+ const CheckboxConfirmation = ({
54
+ description,
55
+ isCreating = false,
56
+ intlLabel,
57
+ name,
58
+ onChange,
59
+ value
60
+ }) => {
61
+ const { formatMessage } = reactIntl.useIntl();
62
+ const [isOpen, setIsOpen] = React__namespace.useState(false);
63
+ const handleChange = (value2) => {
64
+ if (isCreating || value2) {
65
+ return onChange({ target: { name, value: value2, type: "checkbox" } });
66
+ }
67
+ if (!value2) {
68
+ return setIsOpen(true);
69
+ }
70
+ return null;
71
+ };
72
+ const handleConfirm = () => {
73
+ onChange({ target: { name, value: false, type: "checkbox" } });
74
+ };
75
+ const label = intlLabel.id ? formatMessage(
76
+ { id: intlLabel.id, defaultMessage: intlLabel.defaultMessage },
77
+ { ...intlLabel.values }
78
+ ) : name;
79
+ const hint = description ? formatMessage(
80
+ { id: description.id, defaultMessage: description.defaultMessage },
81
+ { ...description.values }
82
+ ) : "";
83
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Root, { open: isOpen, onOpenChange: setIsOpen, children: [
84
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { hint, name, children: [
85
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Checkbox, { onCheckedChange: handleChange, checked: value, children: label }),
86
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
87
+ ] }),
88
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
89
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage({
90
+ id: getTranslation("CheckboxConfirmation.Modal.title"),
91
+ defaultMessage: "Disable localization"
92
+ }) }),
93
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { icon: /* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, {}), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
94
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(TextAlignTypography, { children: formatMessage({
95
+ id: getTranslation("CheckboxConfirmation.Modal.content"),
96
+ defaultMessage: "Disabling localization will engender the deletion of all your content but the one associated to your default locale (if existing)."
97
+ }) }) }),
98
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", children: formatMessage({
99
+ id: getTranslation("CheckboxConfirmation.Modal.body"),
100
+ defaultMessage: "Do you want to disable it?"
101
+ }) }) })
102
+ ] }) }),
103
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
104
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
105
+ id: "components.popUpWarning.button.cancel",
106
+ defaultMessage: "No, cancel"
107
+ }) }) }),
108
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Action, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "danger-light", onClick: handleConfirm, children: formatMessage({
109
+ id: getTranslation("CheckboxConfirmation.Modal.button-confirm"),
110
+ defaultMessage: "Yes, disable"
111
+ }) }) })
112
+ ] })
113
+ ] })
114
+ ] });
115
+ };
116
+ const LOCALIZED_FIELDS = [
117
+ "biginteger",
118
+ "boolean",
119
+ "component",
120
+ "date",
121
+ "datetime",
122
+ "decimal",
123
+ "dynamiczone",
124
+ "email",
125
+ "enumeration",
126
+ "float",
127
+ "integer",
128
+ "json",
129
+ "media",
130
+ "number",
131
+ "password",
132
+ "richtext",
133
+ "blocks",
134
+ "string",
135
+ "text",
136
+ "time"
137
+ ];
138
+ const doesPluginOptionsHaveI18nLocalized = (opts) => typeof opts === "object" && opts !== null && "i18n" in opts && typeof opts.i18n === "object" && opts.i18n !== null && "localized" in opts.i18n && typeof opts.i18n.localized === "boolean";
139
+ const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
140
+ const useI18n = () => {
141
+ const params = reactRouterDom.useParams();
142
+ const userPermissions = strapiAdmin.useAuth("useI18n", (state) => state.permissions);
143
+ const actions = React__namespace.useMemo(() => {
144
+ const permissions = userPermissions.filter((permission) => permission.subject === params.slug);
145
+ return permissions.reduce(
146
+ (acc, permission) => {
147
+ const [actionShorthand] = permission.action.split(".").slice(-1);
148
+ return {
149
+ ...acc,
150
+ [`can${capitalize(actionShorthand)}`]: permission.properties?.locales ?? []
151
+ };
152
+ },
153
+ { canCreate: [], canRead: [], canUpdate: [], canDelete: [], canPublish: [] }
154
+ );
155
+ }, [params.slug, userPermissions]);
156
+ const { schema } = strapiAdmin$1.unstable_useDocument(
157
+ {
158
+ // We can non-null assert these because below we skip the query if they are not present
159
+ collectionType: params.collectionType,
160
+ model: params.slug
161
+ },
162
+ {
163
+ skip: !params.slug || !params.collectionType
164
+ }
165
+ );
166
+ if (doesPluginOptionsHaveI18nLocalized(schema?.pluginOptions)) {
167
+ return {
168
+ hasI18n: schema.pluginOptions.i18n.localized,
169
+ ...actions
170
+ };
171
+ }
172
+ return {
173
+ hasI18n: false,
174
+ ...actions
175
+ };
176
+ };
177
+ const i18nApi = strapiAdmin.adminApi.enhanceEndpoints({
178
+ addTagTypes: ["Locale"]
179
+ });
180
+ const localesApi = i18nApi.injectEndpoints({
181
+ endpoints: (builder) => ({
182
+ createLocale: builder.mutation({
183
+ query: (data) => ({
184
+ url: "/i18n/locales",
185
+ method: "POST",
186
+ data
187
+ }),
188
+ invalidatesTags: [{ type: "Locale", id: "LIST" }]
189
+ }),
190
+ deleteLocale: builder.mutation({
191
+ query: (id) => ({
192
+ url: `/i18n/locales/${id}`,
193
+ method: "DELETE"
194
+ }),
195
+ invalidatesTags: (result, error, id) => [{ type: "Locale", id }]
196
+ }),
197
+ getLocales: builder.query({
198
+ query: () => "/i18n/locales",
199
+ providesTags: (res) => [
200
+ { type: "Locale", id: "LIST" },
201
+ ...Array.isArray(res) ? res.map((locale) => ({
202
+ type: "Locale",
203
+ id: locale.id
204
+ })) : []
205
+ ]
206
+ }),
207
+ getDefaultLocales: builder.query({
208
+ query: () => "/i18n/iso-locales"
209
+ }),
210
+ updateLocale: builder.mutation({
211
+ query: ({ id, ...data }) => ({
212
+ url: `/i18n/locales/${id}`,
213
+ method: "PUT",
214
+ data
215
+ }),
216
+ invalidatesTags: (result, error, { id }) => [{ type: "Locale", id }]
217
+ })
218
+ })
219
+ });
220
+ const {
221
+ useCreateLocaleMutation,
222
+ useDeleteLocaleMutation,
223
+ useGetLocalesQuery,
224
+ useGetDefaultLocalesQuery,
225
+ useUpdateLocaleMutation
226
+ } = localesApi;
227
+ const relationsApi = i18nApi.injectEndpoints({
228
+ overrideExisting: true,
229
+ endpoints: (builder) => ({
230
+ getManyDraftRelationCount: builder.query({
231
+ query: ({ model, ...params }) => ({
232
+ url: `/content-manager/collection-types/${model}/actions/countManyEntriesDraftRelations`,
233
+ method: "GET",
234
+ config: {
235
+ params
236
+ }
237
+ }),
238
+ transformResponse: (response) => response.data
239
+ })
240
+ })
241
+ });
242
+ const { useGetManyDraftRelationCountQuery } = relationsApi;
243
+ const isErrorMessageDescriptor = (object) => {
244
+ return typeof object === "object" && object !== null && "id" in object && "defaultMessage" in object;
245
+ };
246
+ const EntryValidationText = ({ status = "draft", validationErrors }) => {
247
+ const { formatMessage } = reactIntl.useIntl();
248
+ const getErrorStr = (key, value) => {
249
+ if (typeof value === "string") {
250
+ return `${key}: ${value}`;
251
+ } else if (isErrorMessageDescriptor(value)) {
252
+ return `${key}: ${formatMessage(value)}`;
253
+ } else if (Array.isArray(value)) {
254
+ return value.map((v) => getErrorStr(key, v)).join(" ");
255
+ } else if (typeof value === "object" && !Array.isArray(value)) {
256
+ return Object.entries(value).map(([k, v]) => getErrorStr(k, v)).join(" ");
257
+ } else {
258
+ return "";
259
+ }
260
+ };
261
+ if (validationErrors) {
262
+ const validationErrorsMessages = Object.entries(validationErrors).map(([key, value]) => {
263
+ return getErrorStr(key, value);
264
+ }).join(" ");
265
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
266
+ /* @__PURE__ */ jsxRuntime.jsx(icons.CrossCircle, { fill: "danger600" }),
267
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { label: validationErrorsMessages, children: /* @__PURE__ */ jsxRuntime.jsx(
268
+ designSystem.Typography,
269
+ {
270
+ maxWidth: "30rem",
271
+ textColor: "danger600",
272
+ variant: "omega",
273
+ fontWeight: "semiBold",
274
+ ellipsis: true,
275
+ children: validationErrorsMessages
276
+ }
277
+ ) })
278
+ ] });
279
+ }
280
+ if (status === "published") {
281
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
282
+ /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
283
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "success600", fontWeight: "bold", children: formatMessage({
284
+ id: "content-manager.bulk-publish.already-published",
285
+ defaultMessage: "Already Published"
286
+ }) })
287
+ ] });
288
+ }
289
+ if (status === "modified") {
290
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
291
+ /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowsCounterClockwise, { fill: "alternative600" }),
292
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
293
+ id: "app.utils.ready-to-publish-changes",
294
+ defaultMessage: "Ready to publish changes"
295
+ }) })
296
+ ] });
297
+ }
298
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
299
+ /* @__PURE__ */ jsxRuntime.jsx(icons.CheckCircle, { fill: "success600" }),
300
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
301
+ id: "app.utils.ready-to-publish",
302
+ defaultMessage: "Ready to publish"
303
+ }) })
304
+ ] });
305
+ };
306
+ const BoldChunk = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
307
+ const BulkLocaleActionModal = ({
308
+ headers,
309
+ rows,
310
+ localesMetadata,
311
+ validationErrors = {}
312
+ }) => {
313
+ const { formatMessage } = reactIntl.useIntl();
314
+ const selectedRows = strapiAdmin.useTable(
315
+ "BulkLocaleActionModal",
316
+ (state) => state.selectedRows
317
+ );
318
+ const getFormattedCountMessage = () => {
319
+ const currentStatusByLocale = rows.reduce((acc, { locale, status }) => {
320
+ acc[locale] = status;
321
+ return acc;
322
+ }, {});
323
+ const localesWithErrors = Object.keys(validationErrors);
324
+ const alreadyPublishedCount = selectedRows.filter(
325
+ ({ locale }) => currentStatusByLocale[locale] === "published"
326
+ ).length;
327
+ const readyToPublishCount = selectedRows.filter(
328
+ ({ locale }) => (currentStatusByLocale[locale] === "draft" || currentStatusByLocale[locale] === "modified") && !localesWithErrors.includes(locale)
329
+ ).length;
330
+ const withErrorsCount = localesWithErrors.length;
331
+ return formatMessage(
332
+ {
333
+ id: "content-manager.containers.list.selectedEntriesModal.selectedCount",
334
+ defaultMessage: "<b>{alreadyPublishedCount}</b> {alreadyPublishedCount, plural, =0 {entries} one {entry} other {entries}} already published. <b>{readyToPublishCount}</b> {readyToPublishCount, plural, =0 {entries} one {entry} other {entries}} ready to publish. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action."
335
+ },
336
+ {
337
+ withErrorsCount,
338
+ readyToPublishCount,
339
+ alreadyPublishedCount,
340
+ b: BoldChunk
341
+ }
342
+ );
343
+ };
344
+ return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
345
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: getFormattedCountMessage() }),
346
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 5, children: /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Content, { children: [
347
+ /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Head, { children: [
348
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.HeaderCheckboxCell, {}),
349
+ headers.map((head) => /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.HeaderCell, { ...head }, head.name))
350
+ ] }),
351
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Body, { children: rows.map(({ locale, status }, index2) => {
352
+ const error = validationErrors?.[locale] ?? null;
353
+ const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
354
+ return /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Row, { children: [
355
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.CheckboxCell, { id: locale, "aria-label": `Select ${locale}` }),
356
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: Array.isArray(localesMetadata) ? localesMetadata.find((localeEntry) => localeEntry.code === locale)?.name : locale }) }),
357
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { display: "flex", children: /* @__PURE__ */ jsxRuntime.jsx(
358
+ designSystem.Status,
359
+ {
360
+ display: "flex",
361
+ paddingLeft: "6px",
362
+ paddingRight: "6px",
363
+ paddingTop: "2px",
364
+ paddingBottom: "2px",
365
+ showBullet: false,
366
+ size: "S",
367
+ variant: statusVariant,
368
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
369
+ }
370
+ ) }) }),
371
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(EntryValidationText, { validationErrors: error, status }) }),
372
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(
373
+ designSystem.IconButton,
374
+ {
375
+ tag: reactRouterDom.Link,
376
+ to: {
377
+ search: qs.stringify({ plugins: { i18n: { locale } } })
378
+ },
379
+ label: formatMessage(
380
+ {
381
+ id: getTranslation("Settings.list.actions.edit"),
382
+ defaultMessage: "Edit {name} locale"
383
+ },
384
+ {
385
+ name: locale
386
+ }
387
+ ),
388
+ borderWidth: 0,
389
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {})
390
+ }
391
+ ) })
392
+ ] }, index2);
393
+ }) })
394
+ ] }) })
395
+ ] });
396
+ };
397
+ const LocalePickerAction = ({
398
+ document,
399
+ meta,
400
+ model,
401
+ collectionType,
402
+ documentId
403
+ }) => {
404
+ const { formatMessage } = reactIntl.useIntl();
405
+ const [{ query }, setQuery] = strapiAdmin.useQueryParams();
406
+ const { hasI18n, canCreate, canRead } = useI18n();
407
+ const { data: locales = [] } = useGetLocalesQuery();
408
+ const { schema } = strapiAdmin$1.unstable_useDocument({ model, collectionType, documentId });
409
+ const handleSelect = React__namespace.useCallback(
410
+ (value) => {
411
+ setQuery({
412
+ plugins: {
413
+ ...query.plugins,
414
+ i18n: {
415
+ locale: value
416
+ }
417
+ }
418
+ });
419
+ },
420
+ [query.plugins, setQuery]
421
+ );
422
+ React__namespace.useEffect(() => {
423
+ if (!Array.isArray(locales) || !hasI18n) {
424
+ return;
425
+ }
426
+ const currentDesiredLocale = query.plugins?.i18n?.locale;
427
+ const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);
428
+ const defaultLocale = locales.find((locale) => locale.isDefault);
429
+ if (!doesLocaleExist && defaultLocale?.code) {
430
+ handleSelect(defaultLocale.code);
431
+ }
432
+ }, [handleSelect, hasI18n, locales, query.plugins?.i18n?.locale]);
433
+ if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
434
+ return null;
435
+ }
436
+ const currentLocale = query.plugins?.i18n?.locale || locales.find((loc) => loc.isDefault)?.code;
437
+ const allCurrentLocales = [
438
+ { status: getDocumentStatus(document, meta), locale: currentLocale },
439
+ ...meta?.availableLocales ?? []
440
+ ];
441
+ return {
442
+ label: formatMessage({
443
+ id: getTranslation("Settings.locales.modal.locales.label"),
444
+ defaultMessage: "Locales"
445
+ }),
446
+ options: locales.map((locale) => {
447
+ const currentLocaleDoc = allCurrentLocales.find(
448
+ (doc) => "locale" in doc ? doc.locale === locale.code : false
449
+ );
450
+ const status = currentLocaleDoc?.status ?? "draft";
451
+ const permissionsToCheck = currentLocaleDoc ? canCreate : canRead;
452
+ const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
453
+ return {
454
+ disabled: !permissionsToCheck.includes(locale.code),
455
+ value: locale.code,
456
+ label: locale.name,
457
+ startIcon: schema?.options?.draftAndPublish ? /* @__PURE__ */ jsxRuntime.jsx(
458
+ designSystem.Status,
459
+ {
460
+ display: "flex",
461
+ paddingLeft: "6px",
462
+ paddingRight: "6px",
463
+ paddingTop: "2px",
464
+ paddingBottom: "2px",
465
+ showBullet: false,
466
+ size: "S",
467
+ variant: statusVariant,
468
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "pi", fontWeight: "bold", children: capitalize(status) })
469
+ }
470
+ ) : null
471
+ };
472
+ }),
473
+ onSelect: handleSelect,
474
+ value: currentLocale
475
+ };
476
+ };
477
+ const getDocumentStatus = (document, meta) => {
478
+ const docStatus = document?.status;
479
+ const statuses = meta?.availableStatus ?? [];
480
+ if (!docStatus) {
481
+ return "draft";
482
+ }
483
+ if (docStatus === "draft" && statuses.find((doc) => doc.publishedAt !== null)) {
484
+ return "published";
485
+ }
486
+ return docStatus;
487
+ };
488
+ const DeleteLocaleAction = ({
489
+ document,
490
+ documentId,
491
+ model,
492
+ collectionType
493
+ }) => {
494
+ const { formatMessage } = reactIntl.useIntl();
495
+ const navigate = reactRouterDom.useNavigate();
496
+ const { toggleNotification } = strapiAdmin.useNotification();
497
+ const { delete: deleteAction } = strapiAdmin$1.unstable_useDocumentActions();
498
+ const { hasI18n, canDelete } = useI18n();
499
+ if (!hasI18n) {
500
+ return null;
501
+ }
502
+ return {
503
+ disabled: document?.locale && !canDelete.includes(document.locale) || !document || !document.id,
504
+ position: ["header", "table-row"],
505
+ label: formatMessage({
506
+ id: getTranslation("actions.delete.label"),
507
+ defaultMessage: "Delete locale"
508
+ }),
509
+ icon: /* @__PURE__ */ jsxRuntime.jsx(StyledTrash, {}),
510
+ variant: "danger",
511
+ dialog: {
512
+ type: "dialog",
513
+ title: formatMessage({
514
+ id: getTranslation("actions.delete.dialog.title"),
515
+ defaultMessage: "Confirmation"
516
+ }),
517
+ content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
518
+ /* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
519
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
520
+ id: getTranslation("actions.delete.dialog.body"),
521
+ defaultMessage: "Are you sure?"
522
+ }) })
523
+ ] }),
524
+ onConfirm: async () => {
525
+ if (!documentId || !document?.locale) {
526
+ console.error(
527
+ "You're trying to delete a document without an id or locale, this is likely a bug with Strapi. Please open an issue."
528
+ );
529
+ toggleNotification({
530
+ message: formatMessage({
531
+ id: getTranslation("actions.delete.error"),
532
+ defaultMessage: "An error occurred while trying to delete the document locale."
533
+ }),
534
+ type: "danger"
535
+ });
536
+ return;
537
+ }
538
+ const res = await deleteAction({
539
+ documentId,
540
+ model,
541
+ collectionType,
542
+ params: { locale: document.locale }
543
+ });
544
+ if (!("error" in res)) {
545
+ navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
546
+ }
547
+ }
548
+ }
549
+ };
550
+ };
551
+ const BulkLocalePublishAction = ({
552
+ document: baseDocument,
553
+ documentId,
554
+ model,
555
+ collectionType
556
+ }) => {
557
+ const baseLocale = baseDocument?.locale ?? null;
558
+ const [{ query }] = strapiAdmin.useQueryParams();
559
+ const params = React__namespace.useMemo(() => strapiAdmin$1.buildValidParams(query), [query]);
560
+ const isPublishedTab = query.status === "published";
561
+ const { formatMessage } = reactIntl.useIntl();
562
+ const { hasI18n, canPublish } = useI18n();
563
+ const { toggleNotification } = strapiAdmin.useNotification();
564
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
565
+ const [selectedRows, setSelectedRows] = React__namespace.useState([]);
566
+ const [isDraftRelationConfirmationOpen, setIsDraftRelationConfirmationOpen] = React__namespace.useState(false);
567
+ const { publishMany: publishManyAction } = strapiAdmin$1.unstable_useDocumentActions();
568
+ const {
569
+ document,
570
+ meta: documentMeta,
571
+ schema,
572
+ validate
573
+ } = strapiAdmin$1.unstable_useDocument({
574
+ model,
575
+ collectionType,
576
+ documentId,
577
+ params: {
578
+ locale: baseLocale
579
+ }
580
+ });
581
+ const { data: localesMetadata = [] } = useGetLocalesQuery();
582
+ const headers = [
583
+ {
584
+ label: formatMessage({
585
+ id: "global.name",
586
+ defaultMessage: "Name"
587
+ }),
588
+ name: "name"
589
+ },
590
+ {
591
+ label: formatMessage({
592
+ id: getTranslation("CMEditViewBulkLocale.status"),
593
+ defaultMessage: "Status"
594
+ }),
595
+ name: "status"
596
+ },
597
+ {
598
+ label: formatMessage({
599
+ id: getTranslation("CMEditViewBulkLocale.publication-status"),
600
+ defaultMessage: "Publication Status"
601
+ }),
602
+ name: "publication-status"
603
+ }
604
+ ];
605
+ const [rows, validationErrors] = React__namespace.useMemo(() => {
606
+ if (!document || !documentMeta?.availableLocales) {
607
+ return [[], {}];
608
+ }
609
+ const rowsFromMeta = documentMeta?.availableLocales.map((doc) => {
610
+ const { locale, status } = doc;
611
+ return { locale, status };
612
+ });
613
+ rowsFromMeta.unshift({
614
+ locale: document.locale,
615
+ status: document.status
616
+ });
617
+ const allDocuments = [document, ...documentMeta?.availableLocales ?? []];
618
+ const errors = allDocuments.reduce((errs, document2) => {
619
+ if (!document2) {
620
+ return errs;
621
+ }
622
+ const validation = validate(document2);
623
+ if (validation !== null) {
624
+ errs[document2.locale] = validation;
625
+ }
626
+ return errs;
627
+ }, {});
628
+ return [rowsFromMeta, errors];
629
+ }, [document, documentMeta?.availableLocales, validate]);
630
+ const localesToPublish = selectedRows.reduce((acc, selectedRow) => {
631
+ if (selectedRow.status !== "published" && !Object.keys(validationErrors).includes(selectedRow.locale)) {
632
+ acc.push(selectedRow.locale);
633
+ }
634
+ return acc;
635
+ }, []);
636
+ const {
637
+ data: draftRelationsCount = 0,
638
+ isLoading: isDraftRelationsLoading,
639
+ error: isDraftRelationsError
640
+ } = useGetManyDraftRelationCountQuery(
641
+ {
642
+ model,
643
+ documentIds: [documentId],
644
+ locale: localesToPublish
645
+ },
646
+ {
647
+ skip: !documentId || localesToPublish.length === 0
648
+ }
649
+ );
650
+ React__namespace.useEffect(() => {
651
+ if (isDraftRelationsError) {
652
+ toggleNotification({
653
+ type: "danger",
654
+ message: formatAPIError(isDraftRelationsError)
655
+ });
656
+ }
657
+ }, [isDraftRelationsError, toggleNotification, formatAPIError]);
658
+ if (!schema?.options?.draftAndPublish) {
659
+ return null;
660
+ }
661
+ if (!hasI18n) {
662
+ return null;
663
+ }
664
+ if (!documentId) {
665
+ return null;
666
+ }
667
+ const publish = async () => {
668
+ await publishManyAction({
669
+ model,
670
+ documentIds: [documentId],
671
+ params: {
672
+ ...params,
673
+ locale: localesToPublish
674
+ }
675
+ });
676
+ setSelectedRows([]);
677
+ };
678
+ const handleAction = async () => {
679
+ if (draftRelationsCount > 0) {
680
+ setIsDraftRelationConfirmationOpen(true);
681
+ } else {
682
+ await publish();
683
+ }
684
+ };
685
+ const isUnpublish = document?.status === "published";
686
+ if (isUnpublish) {
687
+ console.warn(["I18N"], "Bulk locale unpublish modal not implemented");
688
+ }
689
+ if (isDraftRelationConfirmationOpen) {
690
+ return {
691
+ label: formatMessage({
692
+ id: "app.components.ConfirmDialog.title",
693
+ defaultMessage: "Confirmation"
694
+ }),
695
+ variant: "danger",
696
+ dialog: {
697
+ onCancel: () => {
698
+ setIsDraftRelationConfirmationOpen(false);
699
+ },
700
+ onConfirm: async () => {
701
+ await publish();
702
+ setIsDraftRelationConfirmationOpen(false);
703
+ },
704
+ type: "dialog",
705
+ title: formatMessage({
706
+ id: getTranslation("actions.publish.dialog.title"),
707
+ defaultMessage: "Confirmation"
708
+ }),
709
+ content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "center", gap: 2, children: [
710
+ /* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, { width: "2.4rem", height: "2.4rem", fill: "danger600" }),
711
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textAlign: "center", children: formatMessage({
712
+ id: getTranslation("CMEditViewBulkLocale.draft-relation-warning"),
713
+ defaultMessage: "Some locales are related to draft entries. Publishing them could leave broken links in your app."
714
+ }) }),
715
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textAlign: "center", children: formatMessage({
716
+ id: getTranslation("CMEditViewBulkLocale.continue-confirmation"),
717
+ defaultMessage: "Are you sure you want to continue?"
718
+ }) })
719
+ ] })
720
+ }
721
+ };
722
+ }
723
+ return {
724
+ label: formatMessage({
725
+ id: getTranslation("CMEditViewBulkLocale.publish-title"),
726
+ defaultMessage: "Publish Multiple Locales"
727
+ }),
728
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.ListPlus, {}),
729
+ disabled: isPublishedTab || !canPublish,
730
+ position: ["panel"],
731
+ variant: "secondary",
732
+ dialog: {
733
+ type: "modal",
734
+ title: formatMessage({
735
+ id: getTranslation("CMEditViewBulkLocale.publish-title"),
736
+ defaultMessage: "Publish Multiple Locales"
737
+ }),
738
+ content: () => {
739
+ return /* @__PURE__ */ jsxRuntime.jsx(
740
+ strapiAdmin.Table.Root,
741
+ {
742
+ headers,
743
+ rows: rows.map((row) => ({
744
+ ...row,
745
+ id: row.locale
746
+ })),
747
+ selectedRows,
748
+ onSelectedRowsChange: (tableSelectedRows) => setSelectedRows(tableSelectedRows),
749
+ children: /* @__PURE__ */ jsxRuntime.jsx(
750
+ BulkLocaleActionModal,
751
+ {
752
+ validationErrors,
753
+ headers,
754
+ rows,
755
+ localesMetadata
756
+ }
757
+ )
758
+ }
759
+ );
760
+ },
761
+ footer: () => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
762
+ designSystem.Button,
763
+ {
764
+ loading: isDraftRelationsLoading,
765
+ disabled: localesToPublish.length === 0,
766
+ variant: "default",
767
+ onClick: handleAction,
768
+ children: formatMessage({
769
+ id: "app.utils.publish",
770
+ defaultMessage: "Publish"
771
+ })
772
+ }
773
+ ) })
774
+ }
775
+ };
776
+ };
777
+ const StyledTrash = styledComponents.styled(icons.Trash)`
778
+ path {
779
+ fill: currentColor;
780
+ }
781
+ `;
782
+ const Emphasis = (chunks) => {
783
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", textColor: "danger500", children: chunks });
784
+ };
785
+ const DeleteModalAdditionalInfo = () => {
786
+ const { hasI18n } = useI18n();
787
+ const { formatMessage } = reactIntl.useIntl();
788
+ if (!hasI18n) {
789
+ return null;
790
+ }
791
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", children: formatMessage(
792
+ {
793
+ id: getTranslation("Settings.list.actions.deleteAdditionalInfos"),
794
+ defaultMessage: "This will delete the active locale versions <em>(from Internationalization)</em>"
795
+ },
796
+ {
797
+ em: Emphasis
798
+ }
799
+ ) });
800
+ };
801
+ const PublishModalAdditionalInfo = () => {
802
+ const { hasI18n } = useI18n();
803
+ const { formatMessage } = reactIntl.useIntl();
804
+ if (!hasI18n) {
805
+ return null;
806
+ }
807
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", children: formatMessage(
808
+ {
809
+ id: getTranslation("Settings.list.actions.publishAdditionalInfos"),
810
+ defaultMessage: "This will publish the active locale versions <em>(from Internationalization)</em>"
811
+ },
812
+ {
813
+ em: Emphasis
814
+ }
815
+ ) });
816
+ };
817
+ const UnpublishModalAdditionalInfo = () => {
818
+ const { hasI18n } = useI18n();
819
+ const { formatMessage } = reactIntl.useIntl();
820
+ if (!hasI18n) {
821
+ return null;
822
+ }
823
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", children: formatMessage(
824
+ {
825
+ id: getTranslation("Settings.list.actions.unpublishAdditionalInfos"),
826
+ defaultMessage: "This will unpublish the active locale versions <em>(from Internationalization)</em>"
827
+ },
828
+ {
829
+ em: Emphasis
830
+ }
831
+ ) });
832
+ };
833
+ const Initializer = ({ setPlugin }) => {
834
+ const setPluginRef = React__namespace.useRef(setPlugin);
835
+ React__namespace.useEffect(() => {
836
+ setPluginRef.current(pluginId);
837
+ }, []);
838
+ return null;
839
+ };
840
+ const LocalePicker = () => {
841
+ const { formatMessage } = reactIntl.useIntl();
842
+ const [{ query }, setQuery] = strapiAdmin.useQueryParams();
843
+ const { hasI18n, canRead, canCreate } = useI18n();
844
+ const { data: locales = [] } = useGetLocalesQuery(void 0, {
845
+ skip: !hasI18n
846
+ });
847
+ const handleChange = React__namespace.useCallback(
848
+ (code, replace = false) => {
849
+ setQuery(
850
+ {
851
+ page: 1,
852
+ plugins: { ...query.plugins, i18n: { locale: code } }
853
+ },
854
+ "push",
855
+ replace
856
+ );
857
+ },
858
+ [query.plugins, setQuery]
859
+ );
860
+ React__namespace.useEffect(() => {
861
+ if (!Array.isArray(locales) || !hasI18n) {
862
+ return;
863
+ }
864
+ const currentDesiredLocale = query.plugins?.i18n?.locale;
865
+ const doesLocaleExist = locales.find((loc) => loc.code === currentDesiredLocale);
866
+ const defaultLocale = locales.find((locale) => locale.isDefault);
867
+ if (!doesLocaleExist && defaultLocale?.code) {
868
+ handleChange(defaultLocale.code, true);
869
+ }
870
+ }, [hasI18n, handleChange, locales, query.plugins?.i18n?.locale]);
871
+ if (!hasI18n || !Array.isArray(locales) || locales.length === 0) {
872
+ return null;
873
+ }
874
+ const displayedLocales = locales.filter((locale) => {
875
+ return canCreate.includes(locale.code) || canRead.includes(locale.code);
876
+ });
877
+ return /* @__PURE__ */ jsxRuntime.jsx(
878
+ designSystem.SingleSelect,
879
+ {
880
+ size: "S",
881
+ "aria-label": formatMessage({
882
+ id: getTranslation("actions.select-locale"),
883
+ defaultMessage: "Select locale"
884
+ }),
885
+ value: query.plugins?.i18n?.locale || locales.find((locale) => locale.isDefault)?.code,
886
+ onChange: handleChange,
887
+ children: displayedLocales.map((locale) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: locale.code, children: locale.name }, locale.id))
888
+ }
889
+ );
890
+ };
891
+ const PERMISSIONS = {
892
+ accessMain: [{ action: "plugin::i18n.locale.read", subject: null }],
893
+ create: [{ action: "plugin::i18n.locale.create", subject: null }],
894
+ delete: [{ action: "plugin::i18n.locale.delete", subject: null }],
895
+ update: [{ action: "plugin::i18n.locale.update", subject: null }],
896
+ read: [{ action: "plugin::i18n.locale.read", subject: null }]
897
+ };
898
+ const mutateEditViewHook = ({ layout }) => {
899
+ if (!("i18n" in layout.options) || typeof layout.options.i18n === "object" && layout.options.i18n !== null && "localized" in layout.options.i18n && !layout.options.i18n.localized) {
900
+ return { layout };
901
+ }
902
+ const components = Object.entries(layout.components).reduce(
903
+ (acc, [key, componentLayout]) => {
904
+ return {
905
+ ...acc,
906
+ [key]: {
907
+ ...componentLayout,
908
+ layout: componentLayout.layout.map((row) => row.map(addLabelActionToField))
909
+ }
910
+ };
911
+ },
912
+ {}
913
+ );
914
+ return {
915
+ layout: {
916
+ ...layout,
917
+ components,
918
+ layout: layout.layout.map((panel) => panel.map((row) => row.map(addLabelActionToField)))
919
+ }
920
+ };
921
+ };
922
+ const addLabelActionToField = (field) => {
923
+ const isFieldLocalized = doesFieldHaveI18nPluginOpt(field.attribute.pluginOptions) ? field.attribute.pluginOptions.i18n.localized : true;
924
+ const labelActionProps = {
925
+ title: {
926
+ id: isFieldLocalized ? getTranslation("Field.localized") : getTranslation("Field.not-localized"),
927
+ defaultMessage: isFieldLocalized ? "This value is unique for the selected locale" : "This value is the same across all locales"
928
+ },
929
+ icon: isFieldLocalized ? /* @__PURE__ */ jsxRuntime.jsx(icons.Earth, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.EarthStriked, {})
930
+ };
931
+ return {
932
+ ...field,
933
+ labelAction: /* @__PURE__ */ jsxRuntime.jsx(LabelAction, { ...labelActionProps })
934
+ };
935
+ };
936
+ const doesFieldHaveI18nPluginOpt = (pluginOpts) => {
937
+ if (!pluginOpts) {
938
+ return false;
939
+ }
940
+ return "i18n" in pluginOpts && typeof pluginOpts.i18n === "object" && pluginOpts.i18n !== null && "localized" in pluginOpts.i18n;
941
+ };
942
+ const LabelAction = ({ title, icon }) => {
943
+ const { formatMessage } = reactIntl.useIntl();
944
+ return /* @__PURE__ */ jsxRuntime.jsxs(Span, { tag: "span", children: [
945
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { tag: "span", children: formatMessage(title) }),
946
+ React__namespace.cloneElement(icon, {
947
+ "aria-hidden": true,
948
+ focusable: false
949
+ // See: https://allyjs.io/tutorials/focusing-in-svg.html#making-svg-elements-focusable
950
+ })
951
+ ] });
952
+ };
953
+ const Span = styledComponents.styled(designSystem.Flex)`
954
+ svg {
955
+ width: 12px;
956
+ height: 12px;
957
+
958
+ fill: ${({ theme }) => theme.colors.neutral500};
959
+
960
+ path {
961
+ fill: ${({ theme }) => theme.colors.neutral500};
962
+ }
963
+ }
964
+ `;
965
+ const LocaleListCell = ({
966
+ documentId,
967
+ locale: currentLocale,
968
+ collectionType,
969
+ model
970
+ }) => {
971
+ const { meta, isLoading } = strapiAdmin$1.unstable_useDocument({
972
+ documentId,
973
+ collectionType,
974
+ model,
975
+ params: {
976
+ locale: currentLocale
977
+ }
978
+ });
979
+ const { locale: language } = reactIntl.useIntl();
980
+ const { data: locales = [] } = useGetLocalesQuery();
981
+ const formatter = designSystem.useCollator(language, {
982
+ sensitivity: "base"
983
+ });
984
+ if (!Array.isArray(locales) || isLoading) {
985
+ return null;
986
+ }
987
+ const availableLocales = meta?.availableLocales.map((doc) => doc.locale) ?? [];
988
+ const localesForDocument = locales.reduce((acc, locale) => {
989
+ const createdLocale = [currentLocale, ...availableLocales].find((loc) => {
990
+ return loc === locale.code;
991
+ });
992
+ if (createdLocale) {
993
+ acc.push(locale);
994
+ }
995
+ return acc;
996
+ }, []).map((locale) => {
997
+ if (locale.isDefault) {
998
+ return `${locale.name} (default)`;
999
+ }
1000
+ return locale.name;
1001
+ }).toSorted((a, b) => formatter.compare(a, b));
1002
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Popover.Root, { children: [
1003
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxRuntime.jsxs(
1004
+ ActionWrapper,
1005
+ {
1006
+ minWidth: "100%",
1007
+ alignItems: "center",
1008
+ justifyContent: "center",
1009
+ height: "3.2rem",
1010
+ width: "3.2rem",
1011
+ children: [
1012
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", ellipsis: true, children: localesForDocument.join(", ") }),
1013
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(icons.CaretDown, {}) })
1014
+ ]
1015
+ }
1016
+ ) }) }),
1017
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Content, { sideOffset: 16, children: /* @__PURE__ */ jsxRuntime.jsx("ul", { children: localesForDocument.map((name) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 3, tag: "li", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: name }) }, name)) }) })
1018
+ ] });
1019
+ };
1020
+ const Button = styledComponents.styled.button`
1021
+ width: 100%;
1022
+
1023
+ svg {
1024
+ > g,
1025
+ path {
1026
+ fill: ${({ theme }) => theme.colors.neutral500};
1027
+ }
1028
+ }
1029
+ &:hover {
1030
+ svg {
1031
+ > g,
1032
+ path {
1033
+ fill: ${({ theme }) => theme.colors.neutral600};
1034
+ }
1035
+ }
1036
+ }
1037
+ &:active {
1038
+ svg {
1039
+ > g,
1040
+ path {
1041
+ fill: ${({ theme }) => theme.colors.neutral400};
1042
+ }
1043
+ }
1044
+ }
1045
+ `;
1046
+ const ActionWrapper = styledComponents.styled(designSystem.Flex)`
1047
+ svg {
1048
+ height: 0.4rem;
1049
+ }
1050
+ `;
1051
+ const addColumnToTableHook = ({ displayedHeaders, layout }) => {
1052
+ const { options } = layout;
1053
+ const isFieldLocalized = doesPluginOptionsHaveI18nLocalized(options) ? options.i18n.localized : false;
1054
+ if (!isFieldLocalized) {
1055
+ return { displayedHeaders, layout };
1056
+ }
1057
+ return {
1058
+ displayedHeaders: [
1059
+ ...displayedHeaders,
1060
+ {
1061
+ attribute: { type: "string" },
1062
+ label: {
1063
+ id: getTranslation("list-view.table.header.label"),
1064
+ defaultMessage: "Available in"
1065
+ },
1066
+ searchable: false,
1067
+ sortable: false,
1068
+ name: "locales",
1069
+ // @ts-expect-error – ID is seen as number | string; this will change when we move the type over.
1070
+ cellFormatter: (props, _header, meta) => /* @__PURE__ */ jsxRuntime.jsx(LocaleListCell, { ...props, ...meta })
1071
+ }
1072
+ ],
1073
+ layout
1074
+ };
1075
+ };
1076
+ const addLocaleToReleasesHook = ({ displayedHeaders = [] }) => {
1077
+ return {
1078
+ displayedHeaders: [
1079
+ ...displayedHeaders,
1080
+ {
1081
+ label: {
1082
+ id: "content-releases.page.ReleaseDetails.table.header.label.locale",
1083
+ defaultMessage: "locale"
1084
+ },
1085
+ name: "locale"
1086
+ }
1087
+ ],
1088
+ hasI18nEnabled: true
1089
+ };
1090
+ };
1091
+ const extendCTBAttributeInitialDataMiddleware = () => {
1092
+ return ({ getState }) => (next) => (action) => {
1093
+ const enhanceAction = () => {
1094
+ try {
1095
+ const store = getState();
1096
+ const hasi18nEnabled = get__default.default(
1097
+ store,
1098
+ [
1099
+ "content-type-builder_dataManagerProvider",
1100
+ "modifiedData",
1101
+ "contentType",
1102
+ "schema",
1103
+ "pluginOptions",
1104
+ "i18n",
1105
+ "localized"
1106
+ ],
1107
+ false
1108
+ );
1109
+ if (hasi18nEnabled) {
1110
+ const pluginOptions = action.options ? { ...action.options.pluginOptions, i18n: { localized: true } } : { i18n: { localized: true } };
1111
+ return next({
1112
+ ...action,
1113
+ options: {
1114
+ pluginOptions
1115
+ }
1116
+ });
1117
+ }
1118
+ return next(action);
1119
+ } catch (err) {
1120
+ return next(action);
1121
+ }
1122
+ };
1123
+ if (action.type === "ContentTypeBuilder/FormModal/SET_ATTRIBUTE_DATA_SCHEMA" && action.forTarget === "contentType" && !["relation", "component"].includes(action.attributeType) && !action.isEditing) {
1124
+ return enhanceAction();
1125
+ }
1126
+ if (action.type === "ContentTypeBuilder/FormModal/SET_CUSTOM_FIELD_DATA_SCHEMA" && action.forTarget === "contentType" && !action.isEditing) {
1127
+ return enhanceAction();
1128
+ }
1129
+ if ((action.type === "ContentTypeBuilder/FormModal/RESET_PROPS_AND_SET_FORM_FOR_ADDING_AN_EXISTING_COMPO" || action.type === "ContentTypeBuilder/FormModal/RESET_PROPS_AND_SAVE_CURRENT_DATA") && action.forTarget === "contentType") {
1130
+ return enhanceAction();
1131
+ }
1132
+ return next(action);
1133
+ };
1134
+ };
1135
+ const extendCTBInitialDataMiddleware = () => {
1136
+ return () => (next) => (action) => {
1137
+ if (action.type === "ContentTypeBuilder/FormModal/SET_DATA_TO_EDIT" && action.modalType === "contentType") {
1138
+ const i18n = { localized: false };
1139
+ const pluginOptions = action.data.pluginOptions ? { ...action.data.pluginOptions, i18n } : { i18n };
1140
+ const data = { ...action.data, pluginOptions };
1141
+ if (action.actionType === "create") {
1142
+ return next({ ...action, data });
1143
+ }
1144
+ if (!action.data.pluginOptions?.i18n?.localized) {
1145
+ return next({ ...action, data });
1146
+ }
1147
+ }
1148
+ return next(action);
1149
+ };
1150
+ };
1151
+ const localeMiddleware = (ctx) => (next) => (permissions) => {
1152
+ const match = reactRouterDom.matchPath("/content-manager/:collectionType/:model?/:id", ctx.pathname);
1153
+ if (!match) {
1154
+ return next(permissions);
1155
+ }
1156
+ const search = qs__namespace.parse(ctx.search);
1157
+ if (typeof search !== "object") {
1158
+ return next(permissions);
1159
+ }
1160
+ if (!("plugins" in search && typeof search.plugins === "object")) {
1161
+ return next(permissions);
1162
+ }
1163
+ if (!("i18n" in search.plugins && typeof search.plugins.i18n === "object" && !Array.isArray(search.plugins.i18n))) {
1164
+ return next(permissions);
1165
+ }
1166
+ const { locale } = search.plugins.i18n;
1167
+ if (typeof locale !== "string") {
1168
+ return next(permissions);
1169
+ }
1170
+ const revisedPermissions = permissions.filter(
1171
+ (permission) => !permission.properties?.locales || permission.properties.locales.includes(locale)
1172
+ );
1173
+ return next(revisedPermissions);
1174
+ };
1175
+ const prefixPluginTranslations = (trad, pluginId2) => {
1176
+ if (!pluginId2) {
1177
+ throw new TypeError("pluginId can't be empty");
1178
+ }
1179
+ return Object.keys(trad).reduce((acc, current) => {
1180
+ acc[`${pluginId2}.${current}`] = trad[current];
1181
+ return acc;
1182
+ }, {});
1183
+ };
1184
+ const mutateCTBContentTypeSchema = (nextSchema, prevSchema) => {
1185
+ if (!doesPluginOptionsHaveI18nLocalized(nextSchema.pluginOptions)) {
1186
+ return nextSchema;
1187
+ }
1188
+ const isNextSchemaLocalized = nextSchema.pluginOptions.i18n.localized;
1189
+ const isPrevSchemaLocalized = doesPluginOptionsHaveI18nLocalized(
1190
+ prevSchema?.schema?.pluginOptions
1191
+ ) ? prevSchema?.schema?.pluginOptions.i18n.localized : false;
1192
+ if (isNextSchemaLocalized && isPrevSchemaLocalized) {
1193
+ return nextSchema;
1194
+ }
1195
+ if (isNextSchemaLocalized) {
1196
+ const attributes = addLocalisationToFields(nextSchema.attributes);
1197
+ return { ...nextSchema, attributes };
1198
+ }
1199
+ if (!isNextSchemaLocalized) {
1200
+ const pluginOptions = omit__default.default(nextSchema.pluginOptions, "i18n");
1201
+ const attributes = disableAttributesLocalisation(nextSchema.attributes);
1202
+ return { ...nextSchema, pluginOptions, attributes };
1203
+ }
1204
+ return nextSchema;
1205
+ };
1206
+ const addLocalisationToFields = (attributes) => Object.keys(attributes).reduce((acc, current) => {
1207
+ const currentAttribute = attributes[current];
1208
+ if (LOCALIZED_FIELDS.includes(currentAttribute.type)) {
1209
+ const i18n = { localized: true };
1210
+ const pluginOptions = currentAttribute.pluginOptions ? { ...currentAttribute.pluginOptions, i18n } : { i18n };
1211
+ acc[current] = { ...currentAttribute, pluginOptions };
1212
+ return acc;
1213
+ }
1214
+ acc[current] = currentAttribute;
1215
+ return acc;
1216
+ }, {});
1217
+ const disableAttributesLocalisation = (attributes) => Object.keys(attributes).reduce((acc, current) => {
1218
+ acc[current] = omit__default.default(attributes[current], "pluginOptions.i18n");
1219
+ return acc;
1220
+ }, {});
1221
+ const index = {
1222
+ register(app) {
1223
+ app.addMiddlewares([extendCTBAttributeInitialDataMiddleware, extendCTBInitialDataMiddleware]);
1224
+ app.addMiddlewares([() => i18nApi.middleware]);
1225
+ app.addReducers({
1226
+ [i18nApi.reducerPath]: i18nApi.reducer
1227
+ });
1228
+ app.addRBACMiddleware([localeMiddleware]);
1229
+ app.registerPlugin({
1230
+ id: pluginId,
1231
+ initializer: Initializer,
1232
+ isReady: false,
1233
+ name: pluginId
1234
+ });
1235
+ },
1236
+ bootstrap(app) {
1237
+ app.registerHook("Admin/CM/pages/ListView/inject-column-in-table", addColumnToTableHook);
1238
+ app.registerHook("Admin/CM/pages/EditView/mutate-edit-view-layout", mutateEditViewHook);
1239
+ app.registerHook(
1240
+ "ContentReleases/pages/ReleaseDetails/add-locale-in-releases",
1241
+ addLocaleToReleasesHook
1242
+ );
1243
+ app.addSettingsLink("global", {
1244
+ intlLabel: {
1245
+ id: getTranslation("plugin.name"),
1246
+ defaultMessage: "Internationalization"
1247
+ },
1248
+ id: "internationalization",
1249
+ to: "internationalization",
1250
+ Component: () => Promise.resolve().then(() => require("./SettingsPage-DT1sxWa2.js")).then((mod) => ({ default: mod.ProtectedSettingsPage })),
1251
+ permissions: PERMISSIONS.accessMain
1252
+ });
1253
+ const contentManager = app.getPlugin("content-manager");
1254
+ contentManager.apis.addDocumentHeaderAction([LocalePickerAction]);
1255
+ contentManager.apis.addDocumentAction((actions) => {
1256
+ const indexOfDeleteAction = actions.findIndex((action) => action.type === "delete");
1257
+ actions.splice(indexOfDeleteAction, 0, DeleteLocaleAction);
1258
+ return actions;
1259
+ });
1260
+ contentManager.apis.addDocumentAction((actions) => {
1261
+ actions.splice(2, 0, BulkLocalePublishAction);
1262
+ return actions;
1263
+ });
1264
+ contentManager.injectComponent("listView", "actions", {
1265
+ name: "i18n-locale-filter",
1266
+ Component: LocalePicker
1267
+ });
1268
+ contentManager.injectComponent("listView", "publishModalAdditionalInfos", {
1269
+ name: "i18n-publish-bullets-in-modal",
1270
+ Component: PublishModalAdditionalInfo
1271
+ });
1272
+ contentManager.injectComponent("listView", "unpublishModalAdditionalInfos", {
1273
+ name: "i18n-unpublish-bullets-in-modal",
1274
+ Component: UnpublishModalAdditionalInfo
1275
+ });
1276
+ contentManager.injectComponent("listView", "deleteModalAdditionalInfos", {
1277
+ name: "i18n-delete-bullets-in-modal",
1278
+ Component: DeleteModalAdditionalInfo
1279
+ });
1280
+ const ctbPlugin = app.getPlugin("content-type-builder");
1281
+ if (ctbPlugin) {
1282
+ const ctbFormsAPI = ctbPlugin.apis.forms;
1283
+ ctbFormsAPI.addContentTypeSchemaMutation(mutateCTBContentTypeSchema);
1284
+ ctbFormsAPI.components.add({ id: "checkboxConfirmation", component: CheckboxConfirmation });
1285
+ ctbFormsAPI.extendContentType({
1286
+ validator: () => ({
1287
+ i18n: yup__namespace.object().shape({
1288
+ localized: yup__namespace.bool()
1289
+ })
1290
+ }),
1291
+ form: {
1292
+ advanced() {
1293
+ return [
1294
+ {
1295
+ name: "pluginOptions.i18n.localized",
1296
+ description: {
1297
+ id: getTranslation("plugin.schema.i18n.localized.description-content-type"),
1298
+ defaultMessage: "Allows translating an entry into different languages"
1299
+ },
1300
+ type: "checkboxConfirmation",
1301
+ intlLabel: {
1302
+ id: getTranslation("plugin.schema.i18n.localized.label-content-type"),
1303
+ defaultMessage: "Localization"
1304
+ }
1305
+ }
1306
+ ];
1307
+ }
1308
+ }
1309
+ });
1310
+ ctbFormsAPI.extendFields(LOCALIZED_FIELDS, {
1311
+ validator: (args) => ({
1312
+ i18n: yup__namespace.object().shape({
1313
+ localized: yup__namespace.bool().test({
1314
+ name: "ensure-unique-localization",
1315
+ message: getTranslation("plugin.schema.i18n.ensure-unique-localization"),
1316
+ test(value) {
1317
+ if (value === void 0 || value) {
1318
+ return true;
1319
+ }
1320
+ const unique = get__default.default(args, ["3", "modifiedData", "unique"], null);
1321
+ if (unique && !value) {
1322
+ return false;
1323
+ }
1324
+ return true;
1325
+ }
1326
+ })
1327
+ })
1328
+ }),
1329
+ form: {
1330
+ advanced({ contentTypeSchema, forTarget, type, step }) {
1331
+ if (forTarget !== "contentType") {
1332
+ return [];
1333
+ }
1334
+ const hasI18nEnabled = get__default.default(
1335
+ contentTypeSchema,
1336
+ ["schema", "pluginOptions", "i18n", "localized"],
1337
+ false
1338
+ );
1339
+ if (!hasI18nEnabled) {
1340
+ return [];
1341
+ }
1342
+ if (type === "component" && step === "1") {
1343
+ return [];
1344
+ }
1345
+ return [
1346
+ {
1347
+ name: "pluginOptions.i18n.localized",
1348
+ description: {
1349
+ id: getTranslation("plugin.schema.i18n.localized.description-field"),
1350
+ defaultMessage: "The field can have different values in each locale"
1351
+ },
1352
+ type: "checkbox",
1353
+ intlLabel: {
1354
+ id: getTranslation("plugin.schema.i18n.localized.label-field"),
1355
+ defaultMessage: "Enable localization for this field"
1356
+ }
1357
+ }
1358
+ ];
1359
+ }
1360
+ }
1361
+ });
1362
+ }
1363
+ },
1364
+ async registerTrads({ locales }) {
1365
+ const importedTrads = await Promise.all(
1366
+ locales.map((locale) => {
1367
+ return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("./de-DtWiGdHl.js")), "./translations/dk.json": () => Promise.resolve().then(() => require("./dk-D8C-casx.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-BsOU9o5z.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-DS-XFGSw.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-BTjekDpq.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-DmcGUBQ3.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-Cn5RYonZ.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BMBgVL3s.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-CarUU76c.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-DSHIXAa3.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CukOviB0.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
1368
+ return {
1369
+ data: prefixPluginTranslations(data, pluginId),
1370
+ locale
1371
+ };
1372
+ }).catch(() => {
1373
+ return {
1374
+ data: {},
1375
+ locale
1376
+ };
1377
+ });
1378
+ })
1379
+ );
1380
+ return Promise.resolve(importedTrads);
1381
+ }
1382
+ };
1383
+ exports.PERMISSIONS = PERMISSIONS;
1384
+ exports.getTranslation = getTranslation;
1385
+ exports.index = index;
1386
+ exports.useCreateLocaleMutation = useCreateLocaleMutation;
1387
+ exports.useDeleteLocaleMutation = useDeleteLocaleMutation;
1388
+ exports.useGetDefaultLocalesQuery = useGetDefaultLocalesQuery;
1389
+ exports.useGetLocalesQuery = useGetLocalesQuery;
1390
+ exports.useUpdateLocaleMutation = useUpdateLocaleMutation;
1391
+ //# sourceMappingURL=index-jMrzaEb9.js.map