@akemona-org/strapi-plugin-i18n 3.7.0

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 (147) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +19 -0
  3. package/admin/src/assets/images/logo.svg +1 -0
  4. package/admin/src/components/CMEditViewCopyLocale/index.js +183 -0
  5. package/admin/src/components/CMEditViewCopyLocale/utils/cleanData.js +36 -0
  6. package/admin/src/components/CMEditViewCopyLocale/utils/generateOptions.js +22 -0
  7. package/admin/src/components/CMEditViewCopyLocale/utils/index.js +2 -0
  8. package/admin/src/components/CMEditViewCopyLocale/utils/removePasswordAndRelationsFieldFromData.js +54 -0
  9. package/admin/src/components/CMEditViewCopyLocale/utils/tests/cleanData.test.js +83 -0
  10. package/admin/src/components/CMEditViewCopyLocale/utils/tests/data.js +219 -0
  11. package/admin/src/components/CMEditViewCopyLocale/utils/tests/generateOptions.test.js +79 -0
  12. package/admin/src/components/CMEditViewCopyLocale/utils/tests/removePasswordAndRelationsFieldFromData.test.js +40 -0
  13. package/admin/src/components/CMEditViewInjectedComponents/index.js +58 -0
  14. package/admin/src/components/CMEditViewLocalePicker/Option.js +66 -0
  15. package/admin/src/components/CMEditViewLocalePicker/Wrapper.js +8 -0
  16. package/admin/src/components/CMEditViewLocalePicker/index.js +160 -0
  17. package/admin/src/components/CMEditViewLocalePicker/utils/addStatusColorToLocale.js +24 -0
  18. package/admin/src/components/CMEditViewLocalePicker/utils/createLocalesOption.js +20 -0
  19. package/admin/src/components/CMEditViewLocalePicker/utils/index.js +2 -0
  20. package/admin/src/components/CheckboxConfirmation/Wrapper.js +12 -0
  21. package/admin/src/components/CheckboxConfirmation/index.js +70 -0
  22. package/admin/src/components/DeleteModalAdditionalInfos/index.js +25 -0
  23. package/admin/src/components/LocaleList/index.js +101 -0
  24. package/admin/src/components/LocaleListCell/LocaleListCell.js +90 -0
  25. package/admin/src/components/LocaleListCell/tests/LocaleListCell.test.js +128 -0
  26. package/admin/src/components/LocalePicker/index.js +126 -0
  27. package/admin/src/components/LocaleRow/index.js +77 -0
  28. package/admin/src/components/ModalCreate/AdvancedForm.js +45 -0
  29. package/admin/src/components/ModalCreate/BaseForm.js +103 -0
  30. package/admin/src/components/ModalCreate/index.js +136 -0
  31. package/admin/src/components/ModalDelete/index.js +49 -0
  32. package/admin/src/components/ModalEdit/AdvancedForm.js +51 -0
  33. package/admin/src/components/ModalEdit/BaseForm.js +91 -0
  34. package/admin/src/components/ModalEdit/index.js +122 -0
  35. package/admin/src/components/SettingsModal.js +66 -0
  36. package/admin/src/components/index.js +2 -0
  37. package/admin/src/containers/Initializer.js +31 -0
  38. package/admin/src/containers/SettingsPage/LocaleSettingsPage.js +69 -0
  39. package/admin/src/containers/SettingsPage/index.js +33 -0
  40. package/admin/src/containers/SettingsPage/tests/SettingsPage.test.js +744 -0
  41. package/admin/src/containers/SettingsPage/tests/__snapshots__/SettingsPage.test.js.snap +241 -0
  42. package/admin/src/hooks/constants.js +6 -0
  43. package/admin/src/hooks/reducers.js +63 -0
  44. package/admin/src/hooks/tests/reducers.test.js +203 -0
  45. package/admin/src/hooks/useAddLocale/index.js +60 -0
  46. package/admin/src/hooks/useContentTypePermissions/index.js +16 -0
  47. package/admin/src/hooks/useDefaultLocales/index.js +27 -0
  48. package/admin/src/hooks/useDeleteLocale/index.js +45 -0
  49. package/admin/src/hooks/useEditLocale/index.js +46 -0
  50. package/admin/src/hooks/useHasI18n/index.js +13 -0
  51. package/admin/src/hooks/useLocales/index.js +35 -0
  52. package/admin/src/index.js +169 -0
  53. package/admin/src/middlewares/addCommonFieldsToInitialDataMiddleware.js +83 -0
  54. package/admin/src/middlewares/addLocaleColumnToListViewMiddleware.js +32 -0
  55. package/admin/src/middlewares/addLocaleToCollectionTypesMiddleware.js +25 -0
  56. package/admin/src/middlewares/addLocaleToSingleTypesMiddleware.js +25 -0
  57. package/admin/src/middlewares/extendCMEditViewLayoutMiddleware.js +159 -0
  58. package/admin/src/middlewares/extendCTBAttributeInitialDataMiddleware.js +58 -0
  59. package/admin/src/middlewares/extendCTBInitialDataMiddleware.js +33 -0
  60. package/admin/src/middlewares/index.js +21 -0
  61. package/admin/src/middlewares/localePermissionMiddleware.js +39 -0
  62. package/admin/src/middlewares/tests/addCommonFieldsToInitialDataMiddleware.test.js +97 -0
  63. package/admin/src/middlewares/tests/addLocaleColumnToListViewMiddleware.test.js +68 -0
  64. package/admin/src/middlewares/tests/addLocaleToCollectionTypesMiddleware.test.js +200 -0
  65. package/admin/src/middlewares/tests/addLocaleToSingleTypesMiddleware.test.js +193 -0
  66. package/admin/src/middlewares/tests/extendCMEditViewLayoutMiddleware.test.js +556 -0
  67. package/admin/src/middlewares/tests/extendCTBAttrributeInitialDataMiddleware.test.js +124 -0
  68. package/admin/src/middlewares/tests/extendCTBInitialDataMiddleware.test.js +92 -0
  69. package/admin/src/middlewares/tests/localePermissionMiddleware.test.js +150 -0
  70. package/admin/src/middlewares/utils/addLocaleToLinksSearch.js +56 -0
  71. package/admin/src/middlewares/utils/tests/addLocaleToLinksSearch.test.js +137 -0
  72. package/admin/src/permissions.js +9 -0
  73. package/admin/src/pluginId.js +5 -0
  74. package/admin/src/schemas.js +7 -0
  75. package/admin/src/selectors/selectCollectionTypesRelatedPermissions.js +4 -0
  76. package/admin/src/selectors/selectI18nLocales.js +3 -0
  77. package/admin/src/translations/en.json +60 -0
  78. package/admin/src/translations/fr.json +9 -0
  79. package/admin/src/translations/index.js +11 -0
  80. package/admin/src/translations/zh-Hans.json +60 -0
  81. package/admin/src/utils/getDefaultLocale.js +60 -0
  82. package/admin/src/utils/getInitialLocale.js +14 -0
  83. package/admin/src/utils/getLocaleFromQuery.js +7 -0
  84. package/admin/src/utils/getTrad.js +5 -0
  85. package/admin/src/utils/index.js +2 -0
  86. package/admin/src/utils/localizedFields.js +23 -0
  87. package/admin/src/utils/mutateCTBContentTypeSchema.js +66 -0
  88. package/admin/src/utils/tests/getDefaultLocale.test.js +337 -0
  89. package/admin/src/utils/tests/getInitialLocale.test.js +106 -0
  90. package/admin/src/utils/tests/mutateCTBContentTypeSchema.test.js +205 -0
  91. package/config/functions/bootstrap.js +57 -0
  92. package/config/functions/migrations/__tests__/content-type.test.js +255 -0
  93. package/config/functions/migrations/__tests__/field.test.js +150 -0
  94. package/config/functions/migrations/content-type/disable/index.js +34 -0
  95. package/config/functions/migrations/content-type/disable/migrate-for-bookshelf.js +58 -0
  96. package/config/functions/migrations/content-type/disable/migrate-for-mongoose.js +39 -0
  97. package/config/functions/migrations/content-type/enable/index.js +40 -0
  98. package/config/functions/migrations/content-type/utils/index.js +27 -0
  99. package/config/functions/migrations/field/__tests__/utils.test.js +53 -0
  100. package/config/functions/migrations/field/index.js +37 -0
  101. package/config/functions/migrations/field/migrate-for-bookshelf.js +72 -0
  102. package/config/functions/migrations/field/migrate-for-mongoose.js +24 -0
  103. package/config/functions/migrations/field/migrate.js +55 -0
  104. package/config/functions/migrations/field/utils.js +58 -0
  105. package/config/functions/register.js +46 -0
  106. package/config/policies/validateLocaleCreation.js +68 -0
  107. package/config/routes.json +64 -0
  108. package/constants/__tests__/index.test.js +27 -0
  109. package/constants/index.js +36 -0
  110. package/constants/iso-locales.json +2002 -0
  111. package/controllers/__tests__/content-types.test.js +113 -0
  112. package/controllers/__tests__/iso-locales.test.js +26 -0
  113. package/controllers/__tests__/locales.test.js +308 -0
  114. package/controllers/content-types.js +64 -0
  115. package/controllers/iso-locales.js +11 -0
  116. package/controllers/locales.js +104 -0
  117. package/domain/locale.js +10 -0
  118. package/middlewares/i18n/defaults.json +5 -0
  119. package/middlewares/i18n/index.js +28 -0
  120. package/models/Locale.settings.json +31 -0
  121. package/oas.yml +195 -0
  122. package/package.json +31 -0
  123. package/services/__tests__/__snapshots__/iso-locales.test.js.snap +2006 -0
  124. package/services/__tests__/content-types.test.js +545 -0
  125. package/services/__tests__/core-api.test.js +106 -0
  126. package/services/__tests__/entity-service-decorator.test.js +280 -0
  127. package/services/__tests__/iso-locales.test.js +11 -0
  128. package/services/__tests__/locales.test.js +237 -0
  129. package/services/__tests__/localizations.test.js +187 -0
  130. package/services/__tests__/metrics.test.js +90 -0
  131. package/services/content-types.js +200 -0
  132. package/services/core-api.js +296 -0
  133. package/services/entity-service-decorator.js +155 -0
  134. package/services/iso-locales.js +9 -0
  135. package/services/locales.js +97 -0
  136. package/services/localizations.js +65 -0
  137. package/services/metrics.js +24 -0
  138. package/services/permissions/actions.js +124 -0
  139. package/services/permissions/engine.js +63 -0
  140. package/services/permissions/sections-builder.js +48 -0
  141. package/services/permissions.js +11 -0
  142. package/tests/content-manager/list-relation.test.e2e.js +122 -0
  143. package/tests/graphql.test.e2e.js +120 -0
  144. package/tests/locales.test.e2e.js +414 -0
  145. package/utils/index.js +20 -0
  146. package/validation/content-types.js +30 -0
  147. package/validation/locales.js +39 -0
@@ -0,0 +1,31 @@
1
+ {
2
+ "collectionName": "i18n_locales",
3
+ "info": {
4
+ "name": "locale",
5
+ "description": ""
6
+ },
7
+ "options": {
8
+ "timestamps": true
9
+ },
10
+ "pluginOptions": {
11
+ "content-manager": {
12
+ "visible": false
13
+ },
14
+ "content-type-builder": {
15
+ "visible": false
16
+ }
17
+ },
18
+ "attributes": {
19
+ "name": {
20
+ "type": "string",
21
+ "min": 1,
22
+ "max": 50,
23
+ "configurable": false
24
+ },
25
+ "code": {
26
+ "type": "string",
27
+ "unique": true,
28
+ "configurable": false
29
+ }
30
+ }
31
+ }
package/oas.yml ADDED
@@ -0,0 +1,195 @@
1
+ openapi: 3.0.2
2
+ info:
3
+ title: Strapi i18n Plugin
4
+ version: 1.0.0
5
+ servers:
6
+ - url: http://localhost:1337
7
+ description: Local server
8
+ externalDocs:
9
+ url: https://strapi.akemona.com/documentation
10
+ description: Strapi documentation
11
+ paths:
12
+ /i18n/iso-locales:
13
+ get:
14
+ tags:
15
+ - ISO-locales
16
+ description: List iso-locales that the app can use
17
+ responses:
18
+ 200:
19
+ description: The list of the locales the app can use
20
+ content:
21
+ application/json:
22
+ schema:
23
+ type: array
24
+ items:
25
+ $ref: '#/components/schemas/iso-locale'
26
+ /i18n/locales:
27
+ get:
28
+ tags:
29
+ - Locales
30
+ description: List locales used by the app
31
+ responses:
32
+ 200:
33
+ description: A list of locales
34
+ content:
35
+ application/json:
36
+ schema:
37
+ type: array
38
+ items:
39
+ $ref: '#/components/schemas/locale'
40
+ post:
41
+ tags:
42
+ - Locales
43
+ description: Create a locale
44
+ requestBody:
45
+ content:
46
+ application/json:
47
+ schema:
48
+ $ref: '#/components/schemas/localeInputCreate'
49
+ responses:
50
+ 200:
51
+ content:
52
+ application/json:
53
+ schema:
54
+ $ref: '#/components/schemas/locale'
55
+ /i18n/locales/{id}:
56
+ put:
57
+ tags:
58
+ - Locales
59
+ description: Update the name of a locale
60
+ parameters:
61
+ - $ref: '#/components/parameters/locale-id'
62
+ requestBody:
63
+ content:
64
+ application/json:
65
+ schema:
66
+ $ref: '#/components/schemas/localeInputUpdate'
67
+ responses:
68
+ 200:
69
+ content:
70
+ application/json:
71
+ schema:
72
+ $ref: '#/components/schemas/locale'
73
+ /i18n/content-manager/actions/get-non-localized-fields:
74
+ post:
75
+ tags:
76
+ - Content-Manager
77
+ description: Return the non localized fields of a related entity in order to pre-fill the creation form of a related entity.
78
+ requestBody:
79
+ content:
80
+ application/json:
81
+ schema:
82
+ $ref: '#/components/schemas/getNonLocalizedFieldsInput'
83
+ responses:
84
+ 200:
85
+ content:
86
+ application/json:
87
+ schema:
88
+ type: object
89
+ properties:
90
+ nonLocalizedFields:
91
+ type: object
92
+ localizations:
93
+ description: All related entities id and locale
94
+ type: array
95
+ items:
96
+ type: object
97
+ properties:
98
+ id:
99
+ $ref: '#/components/schemas/id'
100
+ description: Id of this related entity
101
+ locale:
102
+ type: string
103
+ description: Code of the locale of this related entity
104
+
105
+ components:
106
+ schemas:
107
+ id:
108
+ oneOf:
109
+ - type: string
110
+ - type: integer
111
+
112
+ localeInputCreate:
113
+ type: object
114
+ required:
115
+ - code
116
+ - isDefault
117
+ properties:
118
+ name:
119
+ type: string
120
+ description: Name of the locale
121
+ code:
122
+ type: string
123
+ description: ISO code of the locale
124
+ isDefault:
125
+ type: boolean
126
+ description: Set default locale (ignored if set to false)
127
+
128
+ localeInputUpdate:
129
+ type: object
130
+ properties:
131
+ name:
132
+ type: string
133
+ description: Name of the locale
134
+ isDefault:
135
+ type: boolean
136
+ description: Set default locale (ignored if set to false)
137
+
138
+ getNonLocalizedFieldsInput:
139
+ type: object
140
+ required:
141
+ - model
142
+ - id
143
+ - locale
144
+ properties:
145
+ model:
146
+ type: string
147
+ description: Model of the entity
148
+ id:
149
+ $ref: '#/components/schemas/id'
150
+ description: Id of an entity related to the one that will be created
151
+ locale:
152
+ type: string
153
+ description: The locale of the entity that will be pre-filled with the non localized fields this route returns
154
+
155
+ locale:
156
+ type: object
157
+ properties:
158
+ id:
159
+ $ref: '#/components/schemas/id'
160
+ name:
161
+ type: string
162
+ description: Name of the locale
163
+ code:
164
+ type: string
165
+ description: ISO code of the locale
166
+ isDefault:
167
+ type: boolean
168
+ description: Is the default locale
169
+
170
+ iso-locale:
171
+ type: object
172
+ properties:
173
+ name:
174
+ type: string
175
+ description: Name of the locale
176
+ code:
177
+ type: string
178
+ description: ISO code of the locale
179
+
180
+ parameters:
181
+ locale-id:
182
+ in: path
183
+ name: id
184
+ schema:
185
+ type: string
186
+ required: true
187
+ description: Locale id
188
+
189
+ securitySchemes:
190
+ bearerAuth:
191
+ type: http
192
+ scheme: bearer
193
+
194
+ security:
195
+ - bearerAuth: []
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@akemona-org/strapi-plugin-i18n",
3
+ "publishConfig": {
4
+ "access": "public"
5
+ },
6
+ "version": "3.7.0",
7
+ "description": "This plugin enables to create, to read and to update content in different languages, both from the Admin Panel and from the API",
8
+ "strapi": {
9
+ "name": "Internationalization",
10
+ "icon": "round-language",
11
+ "description": "i18n.plugin.description",
12
+ "required": false
13
+ },
14
+ "dependencies": {
15
+ "@akemona-org/strapi-utils": "3.7.0",
16
+ "lodash": "4.17.21",
17
+ "p-map": "4.0.0",
18
+ "pluralize": "8.0.0"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/akemona/strapi.git",
23
+ "directory": "packages/strapi-plugin-i18n"
24
+ },
25
+ "engines": {
26
+ "node": ">=10.16.0 <=14.x.x",
27
+ "npm": ">=6.0.0"
28
+ },
29
+ "license": "SEE LICENSE IN LICENSE",
30
+ "gitHead": "129a8d6191b55810fd66448dcc47fee829df986c"
31
+ }