Skip to content

Commit

Permalink
fix(build): escape quotes in translation texts (#1511)
Browse files Browse the repository at this point in the history
**Background**
The Translation Delivery pull request fails and I found out that one of the new texts in messagebundle_en.properties has has quoted word  `Drop files to upload them or use the "Upload" button `.

**Issue:**
Later when building the i18n-defaults.js, the following fails:

```js
// effectiveValue  has double quotes itself and a word inside with double quotes in addition
return `const ${key} = {key: "${key}", defaultText: "${effectiveValue}"};`;
```

**Solution**: escaping those quotes.
  • Loading branch information
ilhan007 committed Apr 22, 2020
1 parent 727819d commit ee7f300
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/tools/lib/i18n/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ catch (e) {}
* };
*/
const getTextInfo = (key, value, defaultLanguageValue) => {
const effectiveValue = defaultLanguageValue || value;
let effectiveValue = defaultLanguageValue || value;
effectiveValue.replace(/"/g, "\\\""); // escape double quotes in translations

return `const ${key} = {key: "${key}", defaultText: "${effectiveValue}"};`;
};

Expand Down

0 comments on commit ee7f300

Please sign in to comment.