Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/scripts/i18n.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ const chalk = require('chalk');
/**
* Replace appearances of " to convert to \"
* to keep gettext compatibility in PO files
* Avoid double escaping
* @function escapeDoubleQuotes
* @return {string}
*/
function escapeDoubleQuotes(value) {
return value.replaceAll('"', '\\"');
return value.replace(/\\"/g, '"').replace(/"/g, '\\"');
}

/**
Expand Down Expand Up @@ -257,7 +258,9 @@ ${map(pot.items, (item) => {
`#. ${item.extractedComments[0]}`,
`${map(item.references, (ref) => `#: ${ref}`).join('\n')}`,
`msgid "${escapeDoubleQuotes(item.msgid)}"`,
`msgstr "${poItem ? poItem.msgstr : ''}"`,
`msgstr "${
poItem && poItem.msgstr[0] ? escapeDoubleQuotes(poItem.msgstr[0]) : ''
}"`,
].join('\n');
}).join('\n\n')}\n`,
);
Expand Down Expand Up @@ -367,4 +370,4 @@ if (require.main === module) {
main({ addonMode: options.addon });
}

module.exports = { poToJson };
module.exports = { poToJson, escapeDoubleQuotes };
43 changes: 43 additions & 0 deletions packages/scripts/i18n.test.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const { escapeDoubleQuotes } = require("./i18n.cjs");

/**
* Simple test runner for i18n script functions
*/
function runTests() {
const testCases = [
{ name: "No quotes", input: "simple text", expected: "simple text" },
{ name: "Single quotes (ignored)", input: "it's a test", expected: "it's a test" },
{ name: "Unescaped double quotes", input: 'with "quote"', expected: 'with \\"quote\\"' },
{ name: "Already escaped double quotes", input: 'with \\"escaped quote\\"', expected: 'with \\"escaped quote\\"' },
{ name: "Mixed quotes", input: 'mixed "un-escaped" and \\"escaped\\"', expected: 'mixed \\"un-escaped\\" and \\"escaped\\"' },
{ name: "Empty string", input: "", expected: "" },
{ name: "Literal backslash before quote", input: 'back\\\\\\"quote', expected: 'back\\\\\\"quote' },
];

let failures = 0;

console.log("Running i18n script tests...");

testCases.forEach((tc) => {
const result = escapeDoubleQuotes(tc.input);
if (result === tc.expected) {
console.log(`✅ PASSED: ${tc.name}`);
} else {
failures++;
console.error(`❌ FAILED: ${tc.name}`);
console.error(` Input: ${JSON.stringify(tc.input)}`);
console.error(` Expected: ${JSON.stringify(tc.expected)}`);
console.error(` Result: ${JSON.stringify(result)}`);
}
});

if (failures === 0) {
console.log("\nAll tests passed successfully!");
process.exit(0);
} else {
console.error(`\n${failures} test(s) failed.`);
process.exit(1);
}
}

runTests();
1 change: 1 addition & 0 deletions packages/scripts/news/8203.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enhance i18n escaping function to avoid double-escaping and use it for msgstrs @erral
4 changes: 2 additions & 2 deletions packages/volto/locales/ca/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ msgstr "Descarrega el fitxer"
#. Default: "Drag and drop files from your computer onto this area or click the “Browse” button."
#: components/manage/Contents/ContentsUploadModal
msgid "Drag and drop files from your computer onto this area or click the “Browse” button."
msgstr "Arrossegueu fitxers des del vostre ordinador a aquesta àrea o feu clic al botó "Navega"."
msgstr "Arrossegueu fitxers des del vostre ordinador a aquesta àrea o feu clic al botó \"Navega\"."

#. Default: "Drop file here to replace the existing file"
#: components/manage/Widgets/FileWidget
Expand Down Expand Up @@ -2637,7 +2637,7 @@ msgstr "D'acord"
#. Default: "Only 7-bit bytes characters are allowed. Cannot contain uppercase letters, special characters: <, >, &, #, /, ?, or others that are illegal in URLs. Cannot start with: _, aq_, @@, ++. Cannot end with __. Cannot be: request,contributors, ., .., \"\". Cannot contain new lines."
#: components/manage/Widgets/IdWidget
msgid "Only 7-bit bytes characters are allowed. Cannot contain uppercase letters, special characters: <, >, &, #, /, ?, or others that are illegal in URLs. Cannot start with: _, aq_, @@, ++. Cannot end with __. Cannot be: request,contributors, ., .., \"\". Cannot contain new lines."
msgstr "Només es permeten caràcters de 7 bits. No pot contenir majúscules, caràcters especials: <, >, &, #, /, ?, o altres que són il·legals en URLs. No pot començar amb: _, aq_, @@, ++. No pot acabar amb __. No pot ser: request,contributors, ., .., "". No pot contenir salts de línia."
msgstr "Només es permeten caràcters de 7 bits. No pot contenir majúscules, caràcters especials: <, >, &, #, /, ?, o altres que són il·legals en URLs. No pot començar amb: _, aq_, @@, ++. No pot acabar amb __. No pot ser: request,contributors, ., .., \"\". No pot contenir salts de línia."

#. Default: "Open URL browser"
#: components/manage/Widgets/UrlWidget
Expand Down
6 changes: 3 additions & 3 deletions packages/volto/locales/de/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -2637,7 +2637,7 @@ msgstr "OK"
#. Default: "Only 7-bit bytes characters are allowed. Cannot contain uppercase letters, special characters: <, >, &, #, /, ?, or others that are illegal in URLs. Cannot start with: _, aq_, @@, ++. Cannot end with __. Cannot be: request,contributors, ., .., \"\". Cannot contain new lines."
#: components/manage/Widgets/IdWidget
msgid "Only 7-bit bytes characters are allowed. Cannot contain uppercase letters, special characters: <, >, &, #, /, ?, or others that are illegal in URLs. Cannot start with: _, aq_, @@, ++. Cannot end with __. Cannot be: request,contributors, ., .., \"\". Cannot contain new lines."
msgstr "Nur 7-Bit Zeichen sind erlaubt. Darf keine Großbuchstaben und Sonderzeichen enthalten: <, >, &, #, /, ? oder andere, die in URLs nicht zulässig sind. Darf nicht beginnen mit: _, aq_, @@, ++. Darf nicht mit __ enden. Kann nicht sein: request,contributors, ., .., "". Darf keine neuen Zeilen enthalten."
msgstr "Nur 7-Bit Zeichen sind erlaubt. Darf keine Großbuchstaben und Sonderzeichen enthalten: <, >, &, #, /, ? oder andere, die in URLs nicht zulässig sind. Darf nicht beginnen mit: _, aq_, @@, ++. Darf nicht mit __ enden. Kann nicht sein: request,contributors, ., .., \"\". Darf keine neuen Zeilen enthalten."

#. Default: "Open URL browser"
#: components/manage/Widgets/UrlWidget
Expand Down Expand Up @@ -4292,7 +4292,7 @@ msgstr "Nutzen Sie das folgende Formular zum Definieren neuer Inhaltsregeln"
#. Default: "Use the form below to define, change or remove content rules. Rules will automatically perform actions on content when certain triggers take place. After defining rules, you may want to go to a folder to assign them, using the 'rules' item in the actions menu."
#: components/manage/Controlpanels/Rules/Rules
msgid "Use the form below to define, change or remove content rules. Rules will automatically perform actions on content when certain triggers take place. After defining rules, you may want to go to a folder to assign them, using the 'rules' item in the actions menu."
msgstr "Nutzen Sie das folgende Formular zum Definieren, Ändern oder Entfernen von Inhaltsregeln. Inhaltsregeln führen automatische Aktionen auf Inhalten aus, wenn bestimmte Auslöser vorhanden sind. Nach dem Definieren von Regeln können Sie diese einer Seite oder einem beliebigen Inhaltselement zuweisen, indem Sie das "Inhaltsregeln" Bedienelement im Aktionsmenü nutzen."
msgstr "Nutzen Sie das folgende Formular zum Definieren, Ändern oder Entfernen von Inhaltsregeln. Inhaltsregeln führen automatische Aktionen auf Inhalten aus, wenn bestimmte Auslöser vorhanden sind. Nach dem Definieren von Regeln können Sie diese einer Seite oder einem beliebigen Inhaltselement zuweisen, indem Sie das \"Inhaltsregeln\" Bedienelement im Aktionsmenü nutzen."

#. Default: "Used for programmatic access to the fieldset."
#: components/manage/Widgets/SchemaWidget
Expand Down Expand Up @@ -4651,7 +4651,7 @@ msgstr "Geben Sie Ihr neues Passwort ein. Das Passwort muss aus mindestens 8 Zei
#. Default: "Enter a user name, usually something like \"jsmith\". No spaces or special characters. Usernames and passwords are case sensitive, make sure the caps lock key is not enabled. This is the name used to log in."
#: helpers/MessageLabels/MessageLabels
msgid "addUserFormUsernameDescription"
msgstr "Geben Sie einen Nutzernamen ein, beispielsweise etwas wie "m.muster". Benutzen Sie keine Leer- oder Sonderzeichen. Bitte beachten Sie Groß- und Kleinschreibung und stellen Sie sicher, dass die Feststelltaste nicht aktiviert ist. Dieser Name wird zum Anmelden genutzt."
msgstr "Geben Sie einen Nutzernamen ein, beispielsweise etwas wie \"m.muster\". Benutzen Sie keine Leer- oder Sonderzeichen. Bitte beachten Sie Groß- und Kleinschreibung und stellen Sie sicher, dass die Feststelltaste nicht aktiviert ist. Dieser Name wird zum Anmelden genutzt."

#. Default: "Available views"
#: components/manage/Blocks/Search/schema
Expand Down
2 changes: 1 addition & 1 deletion packages/volto/locales/es/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -2632,7 +2632,7 @@ msgstr "Ok"
#. Default: "Only 7-bit bytes characters are allowed. Cannot contain uppercase letters, special characters: <, >, &, #, /, ?, or others that are illegal in URLs. Cannot start with: _, aq_, @@, ++. Cannot end with __. Cannot be: request,contributors, ., .., \"\". Cannot contain new lines."
#: components/manage/Widgets/IdWidget
msgid "Only 7-bit bytes characters are allowed. Cannot contain uppercase letters, special characters: <, >, &, #, /, ?, or others that are illegal in URLs. Cannot start with: _, aq_, @@, ++. Cannot end with __. Cannot be: request,contributors, ., .., \"\". Cannot contain new lines."
msgstr "Sólo se permiten caracteres en bytes de 7 bits. No puede contener letras mayúsculas, caracteres especiales: <, >, &, #, /, ?, u otros que sean ilegales en las URL. No puede empezar por: _, aq_, @@, ++. No puede terminar con __. No puede ser: request,contributors, ., .., "". No puede contener líneas nuevas."
msgstr "Sólo se permiten caracteres en bytes de 7 bits. No puede contener letras mayúsculas, caracteres especiales: <, >, &, #, /, ?, u otros que sean ilegales en las URL. No puede empezar por: _, aq_, @@, ++. No puede terminar con __. No puede ser: request,contributors, ., .., \"\". No puede contener líneas nuevas."

#. Default: "Open URL browser"
#: components/manage/Widgets/UrlWidget
Expand Down
6 changes: 3 additions & 3 deletions packages/volto/locales/eu/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -2632,7 +2632,7 @@ msgstr "Ados"
#. Default: "Only 7-bit bytes characters are allowed. Cannot contain uppercase letters, special characters: <, >, &, #, /, ?, or others that are illegal in URLs. Cannot start with: _, aq_, @@, ++. Cannot end with __. Cannot be: request,contributors, ., .., \"\". Cannot contain new lines."
#: components/manage/Widgets/IdWidget
msgid "Only 7-bit bytes characters are allowed. Cannot contain uppercase letters, special characters: <, >, &, #, /, ?, or others that are illegal in URLs. Cannot start with: _, aq_, @@, ++. Cannot end with __. Cannot be: request,contributors, ., .., \"\". Cannot contain new lines."
msgstr "7 biteko byte karaktereak bakarrik onartzen dira. Ezin dira hizki larriak edo karaktere bereziak erabili: <, >, &, #, /, ?, edo URLtan onartzen ez direnak. Ezin da karaktere hauekin hasi: _, aq_, @@, ++. Ezin da __-rekin amaitu. Ezin da request, contributors, ., ... edo "" izan. Ezin ditu lerro berriak izan."
msgstr "7 biteko byte karaktereak bakarrik onartzen dira. Ezin dira hizki larriak edo karaktere bereziak erabili: <, >, &, #, /, ?, edo URLtan onartzen ez direnak. Ezin da karaktere hauekin hasi: _, aq_, @@, ++. Ezin da __-rekin amaitu. Ezin da request, contributors, ., ... edo \"\" izan. Ezin ditu lerro berriak izan."

#. Default: "Open URL browser"
#: components/manage/Widgets/UrlWidget
Expand Down Expand Up @@ -4287,7 +4287,7 @@ msgstr "Erabili formulario hau erregela berria definitzeko"
#. Default: "Use the form below to define, change or remove content rules. Rules will automatically perform actions on content when certain triggers take place. After defining rules, you may want to go to a folder to assign them, using the 'rules' item in the actions menu."
#: components/manage/Controlpanels/Rules/Rules
msgid "Use the form below to define, change or remove content rules. Rules will automatically perform actions on content when certain triggers take place. After defining rules, you may want to go to a folder to assign them, using the 'rules' item in the actions menu."
msgstr "Erabili formulario hau erregela berriak sortu, aldatu edo ezabatzeko. Erregelek ekintza jakin batzuk gertatzean akzio jakin batzuk exekutatuko dituzte. Erregelak definitu ostean, erregelak zein tokitan esleitu aukeratu beharko duzu akzioen menuko "erregelak" erabiliz."
msgstr "Erabili formulario hau erregela berriak sortu, aldatu edo ezabatzeko. Erregelek ekintza jakin batzuk gertatzean akzio jakin batzuk exekutatuko dituzte. Erregelak definitu ostean, erregelak zein tokitan esleitu aukeratu beharko duzu akzioen menuko \"erregelak\" erabiliz."

#. Default: "Used for programmatic access to the fieldset."
#: components/manage/Widgets/SchemaWidget
Expand Down Expand Up @@ -4646,7 +4646,7 @@ msgstr "Idatzi zure pasahitz berria. Gutxienez 8 karaktere."
#. Default: "Enter a user name, usually something like \"jsmith\". No spaces or special characters. Usernames and passwords are case sensitive, make sure the caps lock key is not enabled. This is the name used to log in."
#: helpers/MessageLabels/MessageLabels
msgid "addUserFormUsernameDescription"
msgstr "Idatzi zure erabiltzaile izena, "jgarmendia" moduko zerbait. Ez da onartzen espaziorik edo karaktere berezirik. Erabiltzaile izenak eta pasahitzak letra larri eta xeheak bereizten dituzte. Hau da webgunera sartzeko erabiliko den izena."
msgstr "Idatzi zure erabiltzaile izena, \"jgarmendia\" moduko zerbait. Ez da onartzen espaziorik edo karaktere berezirik. Erabiltzaile izenak eta pasahitzak letra larri eta xeheak bereizten dituzte. Hau da webgunera sartzeko erabiliko den izena."

#. Default: "Available views"
#: components/manage/Blocks/Search/schema
Expand Down
2 changes: 1 addition & 1 deletion packages/volto/locales/fr/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -4652,7 +4652,7 @@ msgstr "Saisissez votre nouveau mot de passe, minimum 8 caractères."
#. Default: "Enter a user name, usually something like \"jsmith\". No spaces or special characters. Usernames and passwords are case sensitive, make sure the caps lock key is not enabled. This is the name used to log in."
#: helpers/MessageLabels/MessageLabels
msgid "addUserFormUsernameDescription"
msgstr "Saisissez un nom d'utilisateur, haituellement quelque chose comme "jdupont". Pas d'espace ou de caractères spéciaux. Les noms d'utilisateurs et mots de passes sont sensible à la casse, vérifiez que la touche verrouillage majuscule n'est pas activée. C'est le nom utilisé pour se connecté."
msgstr "Saisissez un nom d'utilisateur, haituellement quelque chose comme \"jdupont\". Pas d'espace ou de caractères spéciaux. Les noms d'utilisateurs et mots de passes sont sensible à la casse, vérifiez que la touche verrouillage majuscule n'est pas activée. C'est le nom utilisé pour se connecté."

#. Default: "Available views"
#: components/manage/Blocks/Search/schema
Expand Down
6 changes: 3 additions & 3 deletions packages/volto/locales/hi/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,7 @@ msgstr "फ़ाइल का नाम"
#: components/manage/Contents/ContentsUploadModal
#: components/manage/Contents/DropZoneContent
msgid "Files uploaded: {uploadedFiles}"
msgstr ""फ़ाइलें अपलोड की गईं: {uploadedFiles}"
msgstr "\"फ़ाइलें अपलोड की गईं: {uploadedFiles}"

#. Default: "Fills the value of the form field with the value supplied by a query parameter inside the URL with the given name."
#: components/manage/Widgets/SchemaWidget
Expand Down Expand Up @@ -2631,7 +2631,7 @@ msgstr "ठीक है"
#. Default: "Only 7-bit bytes characters are allowed. Cannot contain uppercase letters, special characters: <, >, &, #, /, ?, or others that are illegal in URLs. Cannot start with: _, aq_, @@, ++. Cannot end with __. Cannot be: request,contributors, ., .., \"\". Cannot contain new lines."
#: components/manage/Widgets/IdWidget
msgid "Only 7-bit bytes characters are allowed. Cannot contain uppercase letters, special characters: <, >, &, #, /, ?, or others that are illegal in URLs. Cannot start with: _, aq_, @@, ++. Cannot end with __. Cannot be: request,contributors, ., .., \"\". Cannot contain new lines."
msgstr "केवल 7-बिट बाइट वाले वर्ण प्रयोग किए जा सकते हैं। अपरकेस अक्षर, विशेष वर्ण: <, >, &, #, /, ?, या अन्य जो यूआरएल में अवैध हैं, का प्रयोग नहीं किया जा सकता। नहीं शुरू हो सकता: _, aq_, @@, ++। __ के साथ समाप्त नहीं हो सकता। नहीं हो सकता: request,contributors, ., .., ""। नई पंक्तियों को नहीं शामिल किया जा सकता।"
msgstr "केवल 7-बिट बाइट वाले वर्ण प्रयोग किए जा सकते हैं। अपरकेस अक्षर, विशेष वर्ण: <, >, &, #, /, ?, या अन्य जो यूआरएल में अवैध हैं, का प्रयोग नहीं किया जा सकता। नहीं शुरू हो सकता: _, aq_, @@, ++। __ के साथ समाप्त नहीं हो सकता। नहीं हो सकता: request,contributors, ., .., \"\"। नई पंक्तियों को नहीं शामिल किया जा सकता।"

#. Default: "Open URL browser"
#: components/manage/Widgets/UrlWidget
Expand Down Expand Up @@ -4645,7 +4645,7 @@ msgstr "अपना नया पासवर्ड दर्ज करें
#. Default: "Enter a user name, usually something like \"jsmith\". No spaces or special characters. Usernames and passwords are case sensitive, make sure the caps lock key is not enabled. This is the name used to log in."
#: helpers/MessageLabels/MessageLabels
msgid "addUserFormUsernameDescription"
msgstr "एक उपयोगकर्ता नाम दर्ज करें, सामान्यत: "jsmith" कुछ ऐसा। कोई रिक्त स्थान या विशेष वर्ण नहीं। उपयोगकर्ता नाम और पासवर्ड मामूली हैं, सुनिश्चित करें कि कैप्स लॉक कुंजी सक्षम नहीं है। यह लॉगिन के लिए उपयोग किया जाने वाला नाम है।"
msgstr "एक उपयोगकर्ता नाम दर्ज करें, सामान्यत: \"jsmith\" कुछ ऐसा। कोई रिक्त स्थान या विशेष वर्ण नहीं। उपयोगकर्ता नाम और पासवर्ड मामूली हैं, सुनिश्चित करें कि कैप्स लॉक कुंजी सक्षम नहीं है। यह लॉगिन के लिए उपयोग किया जाने वाला नाम है।"

#. Default: "Available views"
#: components/manage/Blocks/Search/schema
Expand Down
2 changes: 1 addition & 1 deletion packages/volto/locales/it/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -2632,7 +2632,7 @@ msgstr "Ok"
#. Default: "Only 7-bit bytes characters are allowed. Cannot contain uppercase letters, special characters: <, >, &, #, /, ?, or others that are illegal in URLs. Cannot start with: _, aq_, @@, ++. Cannot end with __. Cannot be: request,contributors, ., .., \"\". Cannot contain new lines."
#: components/manage/Widgets/IdWidget
msgid "Only 7-bit bytes characters are allowed. Cannot contain uppercase letters, special characters: <, >, &, #, /, ?, or others that are illegal in URLs. Cannot start with: _, aq_, @@, ++. Cannot end with __. Cannot be: request,contributors, ., .., \"\". Cannot contain new lines."
msgstr "Sono ammessi solo 7-bit bytes di caratteri. Non può contenere lettere maiuscole, caratteris speciali come: <, >, &, #, /, ?, o altri che non sono ammessi negli URLs. Non può iniziare con: _, aq_, @@, ++. Non può finire con: __. Non può essere: request,contributors, ., .., "" Non può contenere nuove righe."
msgstr "Sono ammessi solo 7-bit bytes di caratteri. Non può contenere lettere maiuscole, caratteris speciali come: <, >, &, #, /, ?, o altri che non sono ammessi negli URLs. Non può iniziare con: _, aq_, @@, ++. Non può finire con: __. Non può essere: request,contributors, ., .., \"\" Non può contenere nuove righe."

#. Default: "Open URL browser"
#: components/manage/Widgets/UrlWidget
Expand Down
Loading
Loading