invenio-app-rdm 13.0.0rc2__py2.py3-none-any.whl → 13.0.0rc4__py2.py3-none-any.whl

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 (156) hide show
  1. invenio_app_rdm/__init__.py +1 -1
  2. invenio_app_rdm/config.py +14 -1
  3. invenio_app_rdm/ext.py +2 -2
  4. invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/deposit.html +5 -0
  5. invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/detail.html +1 -1
  6. invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/detail.html +1 -1
  7. invenio_app_rdm/records_ui/templates/semantic-ui/invenio_app_rdm/records/macros/files.html +20 -3
  8. invenio_app_rdm/records_ui/views/deposits.py +11 -5
  9. invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/administration/components/ImpersonateUserForm.js +12 -17
  10. invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/administration/components/SetQuotaAction.js +1 -1
  11. invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/communityRecordsSearch/CommunityRecordsSearchAppLayout.js +3 -4
  12. invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/deposit/RDMDepositForm.js +6 -1
  13. invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/deposit/index.js +1 -0
  14. invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/RecordVersionsList.js +16 -17
  15. invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/landing_page/RemoveFromCommunity/RemoveFromCommunityAction.js +5 -5
  16. invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/search/components.js +13 -18
  17. invenio_app_rdm/theme/assets/semantic-ui/less/invenio_app_rdm/file_uploader/uppy.less +37 -0
  18. invenio_app_rdm/theme/assets/semantic-ui/less/invenio_app_rdm/theme/modules/accordion.overrides +9 -0
  19. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/i18next-scanner.config.js +1 -1
  20. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/i18next.js +1 -1
  21. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/_generatedTranslations.js +66 -0
  22. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/ar/messages.po +804 -137
  23. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/ar/translations.json +277 -249
  24. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/bg/messages.po +689 -70
  25. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/bg/translations.json +102 -82
  26. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/ca/messages.po +699 -80
  27. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/ca/translations.json +112 -92
  28. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/cs/messages.po +821 -138
  29. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/cs/translations.json +290 -262
  30. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/da/messages.po +691 -66
  31. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/da/translations.json +91 -71
  32. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/de/messages.po +818 -138
  33. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/de/translations.json +260 -240
  34. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/el/messages.po +698 -78
  35. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/el/translations.json +108 -88
  36. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/en/messages.po +1000 -5
  37. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/en/translations.json +81 -28
  38. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/es/messages.po +810 -137
  39. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/es/translations.json +253 -233
  40. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/et/messages.po +746 -133
  41. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/et/translations.json +130 -110
  42. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/fa/messages.po +688 -69
  43. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/fa/translations.json +103 -79
  44. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/fr/messages.po +809 -126
  45. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/fr/translations.json +277 -257
  46. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/hr/messages.po +695 -70
  47. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/hr/translations.json +101 -79
  48. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/hu/messages.po +801 -135
  49. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/hu/translations.json +254 -234
  50. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/index.js +16 -65
  51. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/it/messages.po +712 -86
  52. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/it/translations.json +116 -96
  53. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/ja/messages.po +683 -70
  54. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/ja/translations.json +96 -78
  55. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/ka/messages.po +689 -70
  56. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/ka/translations.json +109 -85
  57. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/ko/messages.po +889 -0
  58. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/ko/translations.json +277 -0
  59. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/lt/messages.po +702 -71
  60. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/lt/translations.json +113 -85
  61. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/no/messages.po +689 -70
  62. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/no/translations.json +102 -82
  63. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/pl/messages.po +704 -70
  64. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/pl/translations.json +119 -91
  65. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/pt/messages.po +694 -69
  66. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/pt/translations.json +93 -73
  67. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/ro/messages.po +717 -85
  68. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/ro/translations.json +155 -133
  69. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/ru/messages.po +806 -124
  70. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/ru/translations.json +288 -260
  71. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/sk/messages.po +713 -82
  72. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/sk/translations.json +119 -91
  73. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/sv/messages.po +807 -141
  74. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/sv/translations.json +260 -240
  75. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/tr/messages.po +799 -128
  76. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/tr/translations.json +259 -239
  77. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/uk/messages.po +756 -131
  78. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/uk/translations.json +124 -96
  79. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/zh_CN/messages.po +736 -123
  80. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/zh_CN/translations.json +130 -108
  81. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/zh_TW/messages.po +683 -70
  82. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/messages/zh_TW/translations.json +100 -78
  83. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/package-lock.json +1295 -678
  84. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/package.json +3 -37
  85. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/scripts/compileCatalog.js +102 -24
  86. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/scripts/fixTrailingNewlines.js +23 -0
  87. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/scripts/initCatalog.js +1 -1
  88. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/scripts/postExtractMessages.js +36 -0
  89. invenio_app_rdm/theme/assets/semantic-ui/translations/invenio_app_rdm/translations.pot +243 -94
  90. invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/intro_section.html +7 -6
  91. invenio_app_rdm/theme/webpack.py +1 -0
  92. invenio_app_rdm/translations/ar/LC_MESSAGES/messages.mo +0 -0
  93. invenio_app_rdm/translations/ar/LC_MESSAGES/messages.po +972 -376
  94. invenio_app_rdm/translations/bg/LC_MESSAGES/messages.mo +0 -0
  95. invenio_app_rdm/translations/bg/LC_MESSAGES/messages.po +907 -278
  96. invenio_app_rdm/translations/ca/LC_MESSAGES/messages.mo +0 -0
  97. invenio_app_rdm/translations/ca/LC_MESSAGES/messages.po +912 -283
  98. invenio_app_rdm/translations/cs/LC_MESSAGES/messages.mo +0 -0
  99. invenio_app_rdm/translations/cs/LC_MESSAGES/messages.po +1069 -405
  100. invenio_app_rdm/translations/da/LC_MESSAGES/messages.mo +0 -0
  101. invenio_app_rdm/translations/da/LC_MESSAGES/messages.po +908 -273
  102. invenio_app_rdm/translations/de/LC_MESSAGES/messages.mo +0 -0
  103. invenio_app_rdm/translations/de/LC_MESSAGES/messages.po +1017 -406
  104. invenio_app_rdm/translations/el/LC_MESSAGES/messages.mo +0 -0
  105. invenio_app_rdm/translations/el/LC_MESSAGES/messages.po +915 -286
  106. invenio_app_rdm/translations/es/LC_MESSAGES/messages.mo +0 -0
  107. invenio_app_rdm/translations/es/LC_MESSAGES/messages.po +963 -371
  108. invenio_app_rdm/translations/et/LC_MESSAGES/messages.mo +0 -0
  109. invenio_app_rdm/translations/et/LC_MESSAGES/messages.po +938 -362
  110. invenio_app_rdm/translations/fa/LC_MESSAGES/messages.mo +0 -0
  111. invenio_app_rdm/translations/fa/LC_MESSAGES/messages.po +906 -277
  112. invenio_app_rdm/translations/fr/LC_MESSAGES/messages.mo +0 -0
  113. invenio_app_rdm/translations/fr/LC_MESSAGES/messages.po +1032 -375
  114. invenio_app_rdm/translations/hr/LC_MESSAGES/messages.mo +0 -0
  115. invenio_app_rdm/translations/hr/LC_MESSAGES/messages.po +907 -278
  116. invenio_app_rdm/translations/hu/LC_MESSAGES/messages.mo +0 -0
  117. invenio_app_rdm/translations/hu/LC_MESSAGES/messages.po +985 -369
  118. invenio_app_rdm/translations/it/LC_MESSAGES/messages.mo +0 -0
  119. invenio_app_rdm/translations/it/LC_MESSAGES/messages.po +928 -298
  120. invenio_app_rdm/translations/ja/LC_MESSAGES/messages.mo +0 -0
  121. invenio_app_rdm/translations/ja/LC_MESSAGES/messages.po +907 -278
  122. invenio_app_rdm/translations/ka/LC_MESSAGES/messages.mo +0 -0
  123. invenio_app_rdm/translations/ka/LC_MESSAGES/messages.po +909 -280
  124. invenio_app_rdm/translations/ko/LC_MESSAGES/messages.mo +0 -0
  125. invenio_app_rdm/translations/ko/LC_MESSAGES/messages.po +1361 -0
  126. invenio_app_rdm/translations/lt/LC_MESSAGES/messages.mo +0 -0
  127. invenio_app_rdm/translations/lt/LC_MESSAGES/messages.po +910 -281
  128. invenio_app_rdm/translations/messages.pot +486 -303
  129. invenio_app_rdm/translations/no/LC_MESSAGES/messages.mo +0 -0
  130. invenio_app_rdm/translations/no/LC_MESSAGES/messages.po +907 -278
  131. invenio_app_rdm/translations/pl/LC_MESSAGES/messages.mo +0 -0
  132. invenio_app_rdm/translations/pl/LC_MESSAGES/messages.po +907 -278
  133. invenio_app_rdm/translations/pt/LC_MESSAGES/messages.mo +0 -0
  134. invenio_app_rdm/translations/pt/LC_MESSAGES/messages.po +906 -277
  135. invenio_app_rdm/translations/ro/LC_MESSAGES/messages.mo +0 -0
  136. invenio_app_rdm/translations/ro/LC_MESSAGES/messages.po +1042 -384
  137. invenio_app_rdm/translations/ru/LC_MESSAGES/messages.mo +0 -0
  138. invenio_app_rdm/translations/ru/LC_MESSAGES/messages.po +1022 -370
  139. invenio_app_rdm/translations/sk/LC_MESSAGES/messages.mo +0 -0
  140. invenio_app_rdm/translations/sk/LC_MESSAGES/messages.po +916 -287
  141. invenio_app_rdm/translations/sv/LC_MESSAGES/messages.mo +0 -0
  142. invenio_app_rdm/translations/sv/LC_MESSAGES/messages.po +989 -380
  143. invenio_app_rdm/translations/tr/LC_MESSAGES/messages.mo +0 -0
  144. invenio_app_rdm/translations/tr/LC_MESSAGES/messages.po +992 -341
  145. invenio_app_rdm/translations/uk/LC_MESSAGES/messages.mo +0 -0
  146. invenio_app_rdm/translations/uk/LC_MESSAGES/messages.po +935 -356
  147. invenio_app_rdm/translations/zh_CN/LC_MESSAGES/messages.mo +0 -0
  148. invenio_app_rdm/translations/zh_CN/LC_MESSAGES/messages.po +939 -347
  149. invenio_app_rdm/translations/zh_TW/LC_MESSAGES/messages.mo +0 -0
  150. invenio_app_rdm/translations/zh_TW/LC_MESSAGES/messages.po +907 -278
  151. {invenio_app_rdm-13.0.0rc2.dist-info → invenio_app_rdm-13.0.0rc4.dist-info}/METADATA +27 -1
  152. {invenio_app_rdm-13.0.0rc2.dist-info → invenio_app_rdm-13.0.0rc4.dist-info}/RECORD +156 -148
  153. {invenio_app_rdm-13.0.0rc2.dist-info → invenio_app_rdm-13.0.0rc4.dist-info}/WHEEL +0 -0
  154. {invenio_app_rdm-13.0.0rc2.dist-info → invenio_app_rdm-13.0.0rc4.dist-info}/entry_points.txt +0 -0
  155. {invenio_app_rdm-13.0.0rc2.dist-info → invenio_app_rdm-13.0.0rc4.dist-info}/licenses/LICENSE +0 -0
  156. {invenio_app_rdm-13.0.0rc2.dist-info → invenio_app_rdm-13.0.0rc4.dist-info}/top_level.txt +0 -0
@@ -1,41 +1,7 @@
1
1
  {
2
2
  "name": "invenio-app-rdm-ui",
3
3
  "config": {
4
- "languages": [
5
- "af",
6
- "ar",
7
- "bg",
8
- "ca",
9
- "cs",
10
- "da",
11
- "de",
12
- "el",
13
- "en",
14
- "es",
15
- "et",
16
- "et_EE",
17
- "fa",
18
- "fr",
19
- "gl",
20
- "hr",
21
- "hu",
22
- "it",
23
- "ja",
24
- "ka",
25
- "lt",
26
- "no",
27
- "pl",
28
- "pt",
29
- "ro",
30
- "ru",
31
- "rw",
32
- "sk",
33
- "sv",
34
- "tr",
35
- "uk",
36
- "zh_CN",
37
- "zh_TW"
38
- ]
4
+ "languages": ["en"]
39
5
  },
40
6
  "devDependencies": {
41
7
  "i18next-conv": "^10.2.0",
@@ -44,8 +10,8 @@
44
10
  "react-json-view": "^1.21.3"
45
11
  },
46
12
  "scripts": {
47
- "extract_messages": "i18next-scanner --config i18next-scanner.config.js '../../js/**/*.{js,jsx}'",
48
- "postextract_messages": "i18next-conv -l en -s ./messages/en/translations.json -t ./translations.pot",
13
+ "extract_messages": "i18next-scanner --config i18next-scanner.config.js '../../js/**/*.{js,jsx}' '!../../js/**/node_modules/**'",
14
+ "postextract_messages": "node ./scripts/postExtractMessages.js",
49
15
  "compile_catalog": "node ./scripts/compileCatalog.js",
50
16
  "init_catalog": "node ./scripts/initCatalog"
51
17
  }
@@ -1,40 +1,118 @@
1
- // This file is part of React-Invenio-Deposit
2
- // Copyright (C) 2021 Graz University of Technology.
1
+ // This file is part of invenio-app-rdm.
2
+ // Copyright (C) 2021-2024 Graz University of Technology.
3
+ // Copyright (C) 2025 KTH Royal Institute of Technology.
3
4
  //
4
5
  // Invenio-app-rdm is free software; you can redistribute it and/or modify it
5
6
  // under the terms of the MIT License; see LICENSE file for more details.
6
7
 
7
- const { readFileSync, writeFileSync } = require("fs");
8
+ const { readdirSync, readFileSync, writeFileSync, existsSync } = require("fs");
8
9
  const { gettextToI18next } = require("i18next-conv");
10
+ const path = require("path");
9
11
 
10
- const PACKAGE_JSON_BASE_PATH = "./";
11
- const { languages } = require(`../package`).config;
12
+ const PACKAGE_MESSAGES_PATH = "./messages";
13
+ const PO_FILENAME = "messages.po";
14
+ const JSON_FILENAME = "translations.json";
15
+ const GENERATED_FILE = "_generatedTranslations.js";
12
16
 
13
17
  // it accepts the same options as the cli.
14
18
  // https://github.com/i18next/i18next-gettext-converter#options
15
19
  const options = {
16
- /* you options here */
20
+ /* your options here */
17
21
  };
18
22
 
19
- function save(target) {
20
- return (result) => {
21
- writeFileSync(target, result);
22
- };
23
+ async function compileAndCreateFileForLanguage(parentPath, lang) {
24
+ const poFilePath = path.join(parentPath, lang, PO_FILENAME);
25
+ const jsonFilePath = path.join(parentPath, lang, JSON_FILENAME);
26
+
27
+ if (!existsSync(poFilePath)) {
28
+ console.warn(`❌ Skipping ${lang}: ${PO_FILENAME} not found.`);
29
+ return false;
30
+ }
31
+
32
+ try {
33
+ const poContent = readFileSync(poFilePath);
34
+ const result = await gettextToI18next(lang, poContent, options);
35
+ const parsed = JSON.parse(result);
36
+ const prettyJSON = JSON.stringify(parsed, null, 2) + "\n";
37
+ writeFileSync(jsonFilePath, prettyJSON);
38
+ console.log(`✅ Successfully converted ${lang}/${PO_FILENAME} to ${JSON_FILENAME}`);
39
+ return true;
40
+ } catch (error) {
41
+ console.error(`❌ Error processing ${lang}:`, error.message);
42
+ return false;
43
+ }
44
+ }
45
+
46
+ function writeGeneratedTranslationsFile(languages) {
47
+ const generatedPath = path.join(PACKAGE_MESSAGES_PATH, GENERATED_FILE);
48
+ let content = "// AUTO-GENERATED FILE - DO NOT EDIT MANUALLY\n";
49
+ content += "// This file exports all available translations for i18next\n\n";
50
+
51
+ // Generate imports
52
+ languages.forEach((lang) => {
53
+ const varName = lang.toUpperCase().replace(/-/g, "_");
54
+ content += `import TRANSLATE_${varName} from "./${lang}/${JSON_FILENAME}";\n`;
55
+ });
56
+
57
+ // Generate exports
58
+ content += "\nexport const translations = {\n";
59
+ languages.forEach((lang) => {
60
+ const varName = lang.toUpperCase().replace(/-/g, "_");
61
+ content += ` ${lang}: { translation: TRANSLATE_${varName} },\n`;
62
+ });
63
+ content += "};\n";
64
+
65
+ writeFileSync(generatedPath, content);
66
+ console.log(`📁 Generated translation index at ${GENERATED_FILE}`);
23
67
  }
24
68
 
25
- if ("lang" === process.argv[2]) {
26
- const lang = process.argv[3];
27
- gettextToI18next(
28
- lang,
29
- readFileSync(`${PACKAGE_JSON_BASE_PATH}messages/${lang}/messages.po`),
30
- options
31
- ).then(save(`${PACKAGE_JSON_BASE_PATH}messages/${lang}/translations.json`));
32
- } else {
33
- for (const lang of languages) {
34
- gettextToI18next(
35
- lang,
36
- readFileSync(`${PACKAGE_JSON_BASE_PATH}messages/${lang}/messages.po`),
37
- options
38
- ).then(save(`${PACKAGE_JSON_BASE_PATH}messages/${lang}/translations.json`));
69
+ async function processAllLanguages() {
70
+ const directories = readdirSync(PACKAGE_MESSAGES_PATH, {
71
+ withFileTypes: true,
72
+ })
73
+ .filter((dir) => dir.isDirectory())
74
+ .map((dir) => dir.name);
75
+
76
+ const processedLangs = [];
77
+ for (const lang of directories) {
78
+ const success = await compileAndCreateFileForLanguage(PACKAGE_MESSAGES_PATH, lang);
79
+ if (success) processedLangs.push(lang);
39
80
  }
81
+ return processedLangs;
82
+ }
83
+
84
+ async function handleLanguageCommand(lang) {
85
+ const success = await compileAndCreateFileForLanguage(PACKAGE_MESSAGES_PATH, lang);
86
+ if (!success) process.exit(1);
87
+
88
+ const directories = readdirSync(PACKAGE_MESSAGES_PATH, {
89
+ withFileTypes: true,
90
+ })
91
+ .filter((dir) => dir.isDirectory())
92
+ .map((dir) => dir.name);
93
+
94
+ const validLangs = directories.filter((l) =>
95
+ existsSync(path.join(PACKAGE_MESSAGES_PATH, l, JSON_FILENAME))
96
+ );
97
+ writeGeneratedTranslationsFile(validLangs);
40
98
  }
99
+
100
+ // Main execution flow
101
+ // self-executing function for coordinating async on the top level
102
+ // and to avoid using .then() and .catch().
103
+ // operations with centralized error handling.
104
+ (async () => {
105
+ try {
106
+ if (process.argv[2] === "lang") {
107
+ const lang = process.argv[3];
108
+ if (!lang) throw new Error("Missing language code e.g. 'sv', 'ar', etc.");
109
+ await handleLanguageCommand(lang);
110
+ } else {
111
+ const processedLangs = await processAllLanguages();
112
+ writeGeneratedTranslationsFile(processedLangs);
113
+ }
114
+ } catch (error) {
115
+ console.error("❌ Script failed:", error.message);
116
+ process.exit(1);
117
+ }
118
+ })();
@@ -0,0 +1,23 @@
1
+ // This file is part of invenio-app-rdm.
2
+ // Copyright (C) 2025 CERN.
3
+ // Copyright (C) 2025 KTH Royal Institute of Technology.
4
+ //
5
+ // Invenio-app-rdm is free software; you can redistribute it and/or modify it
6
+ // under the terms of the MIT License; see LICENSE file for more details.
7
+
8
+ const fs = require("fs");
9
+
10
+ const files = ["./translations.pot", "./messages/en/messages.po"];
11
+
12
+ for (const file of files) {
13
+ if (!fs.existsSync(file)) {
14
+ console.warn(`⚠️ File not found: ${file}`);
15
+ continue;
16
+ }
17
+
18
+ const content = fs.readFileSync(file, "utf8");
19
+ if (!content.endsWith("\n")) {
20
+ fs.appendFileSync(file, "\n");
21
+ console.log(`🔧 Appended trailing newline to: ${file}`);
22
+ }
23
+ }
@@ -1,4 +1,4 @@
1
- // This file is part of React-Invenio-Deposit
1
+ // This file is part of invenio-app-rdm.
2
2
  // Copyright (C) 2021 Graz University of Technology.
3
3
  //
4
4
  // Invenio-app-rdm is free software; you can redistribute it and/or modify it
@@ -0,0 +1,36 @@
1
+ // This file is part of invenio-app-rdm.
2
+ // Copyright (C) 2025 KTH Royal Institute of Technology.
3
+ //
4
+ // invenio-app-rdm is free software; you can redistribute it and/or modify it
5
+ // under the terms of the MIT License; see LICENSE file for more details.
6
+
7
+ const { execSync } = require("child_process");
8
+
9
+ /**
10
+ * Post-processing script for extracted messages
11
+ * Converts translations.json to .pot and .po formats and fixes trailing newlines
12
+ */
13
+
14
+ const commands = [
15
+ // Convert to .pot format
16
+ "i18next-conv -l en -s ./messages/en/translations.json -t ./translations.pot",
17
+ // Convert to .po format
18
+ "i18next-conv -l en -s ./messages/en/translations.json -t ./messages/en/messages.po",
19
+ // Fix trailing newlines
20
+ "node scripts/fixTrailingNewlines.js",
21
+ ];
22
+
23
+ console.log("📝 Post-processing extracted messages...");
24
+
25
+ commands.forEach((command, index) => {
26
+ try {
27
+ console.log(`⚙️ Step ${index + 1}/${commands.length}: ${command}`);
28
+ execSync(command, { stdio: "inherit", cwd: process.cwd() });
29
+ } catch (error) {
30
+ console.error(`❌ Failed to execute: ${command}`);
31
+ console.error(error.message);
32
+ process.exit(1);
33
+ }
34
+ });
35
+
36
+ console.log("✅ Post-processing completed successfully!");