Skip to content

Commit 22d71c6

Browse files
Ensure messages not duplicated + fix newline (#2044)
1 parent a6a37f8 commit 22d71c6

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

extensions/reviewed/TweenIntoView.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMy4wLjMsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iSWNvbnMiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgMzIgMzIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDMyIDMyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8Zz4NCgk8cGF0aCBkPSJNMjUsMTZjLTAuMywwLTAuNS0wLjEtMC43LTAuM2MtMC40LTAuNC0wLjQtMSwwLTEuNGwzLjMtMy4zbC0zLjMtMy4zYy0wLjQtMC40LTAuNC0xLDAtMS40czEtMC40LDEuNCwwbDQsNA0KCQljMC40LDAuNCwwLjQsMSwwLDEuNGwtNCw0QzI1LjUsMTUuOSwyNS4zLDE2LDI1LDE2eiIvPg0KPC9nPg0KPGc+DQoJPHBhdGggZD0iTTI5LDEySDdjLTAuNiwwLTEtMC40LTEtMXMwLjQtMSwxLTFoMjJjMC42LDAsMSwwLjQsMSwxUzI5LjYsMTIsMjksMTJ6Ii8+DQo8L2c+DQo8Zz4NCgk8cGF0aCBkPSJNNywyNmMtMC4zLDAtMC41LTAuMS0wLjctMC4zbC00LTRjLTAuNC0wLjQtMC40LTEsMC0xLjRsNC00YzAuNC0wLjQsMS0wLjQsMS40LDBzMC40LDEsMCwxLjRMNC40LDIxbDMuMywzLjMNCgkJYzAuNCwwLjQsMC40LDEsMCwxLjRDNy41LDI1LjksNy4zLDI2LDcsMjZ6Ii8+DQo8L2c+DQo8Zz4NCgk8cGF0aCBkPSJNMjUsMjJIM2MtMC42LDAtMS0wLjQtMS0xczAuNC0xLDEtMWgyMmMwLjYsMCwxLDAuNCwxLDFTMjUuNiwyMiwyNSwyMnoiLz4NCjwvZz4NCjwvc3ZnPg0K",
99
"name": "TweenIntoView",
1010
"previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/Glyphster Pack/Master/SVG/Arrows/557b3471ae92fa5c744b9bf14b8803a0c7745c224ed9cfe80037a8ac7295d99e_Arrows_thin_arrow_left_right_directions.svg",
11-
"shortDescription": "Tween objects into position from off screen.\n",
11+
"shortDescription": "Tween objects into position from off screen.",
1212
"version": "1.0.0",
1313
"description": [
1414
"Tween objects into position from off screen, or from a set distance, to create a polished visual effect.",

scripts/extract-all-translations.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ try {
5454
if (data[key]) {
5555
/** @type {string[]} */
5656
const values = Array.isArray(data[key]) ? data[key] : [data[key]];
57-
values.forEach((value) => {
58-
if (value.trim()) {
57+
values.forEach((rawValue) => {
58+
const value = rawValue.trim();
59+
if (value) {
5960
if (!translationsMap.has(value)) {
6061
translationsMap.set(value, []);
6162
}
@@ -201,9 +202,9 @@ try {
201202

202203
console.log('ℹ️ Creating .POT content...');
203204
// Step 3: Build POT content
205+
const generatedMsgids = new Set();
204206
translationsMap.forEach((files, value) => {
205207
const uniqueFiles = [...new Set(files)];
206-
potContent += uniqueFiles.map((file) => `#: ${file}`).join('\n') + '\n';
207208

208209
// Handle multi-line strings
209210
const escapedValue = value
@@ -213,14 +214,27 @@ try {
213214
/** @type {string[]} */
214215
let lines = escapedValue.split('\n');
215216
lines = lines.filter((line) => line.trim());
216-
potContent +=
217-
'msgid ' +
218-
lines
219-
.map((line, index) =>
220-
index === lines.length - 1 ? `"${line}"` : `"${line}\\n"`
221-
)
222-
.join('\n') +
223-
'\n';
217+
const msgidContent = lines
218+
.map((line, index) =>
219+
index === lines.length - 1 ? `"${line}"` : `"${line}\\n"`
220+
)
221+
.join('\n');
222+
223+
// Skip if this msgid was already generated (safety net for edge cases
224+
// where two different source strings produce the same msgid after escaping).
225+
if (generatedMsgids.has(msgidContent)) {
226+
console.warn(
227+
`⚠️ Skipping duplicate msgid ${msgidContent.slice(
228+
0,
229+
60
230+
)} (from: ${uniqueFiles.join(', ')})`
231+
);
232+
return;
233+
}
234+
generatedMsgids.add(msgidContent);
235+
236+
potContent += uniqueFiles.map((file) => `#: ${file}`).join('\n') + '\n';
237+
potContent += 'msgid ' + msgidContent + '\n';
224238
potContent += 'msgstr ""\n\n';
225239
});
226240

0 commit comments

Comments
 (0)