[FIX] transifex: correctly escape links

This commit corrects two issues:
- new lines characters are ignored by transifex when searching (searching on
'\n' finds no match)
- quotes are ignored by transifex (it used to be escaped with \\)
- the text:'...' does not need to be escaped, it is the searched string that
must be escaped.

For instance, searching on "\n\nThis addon is already installed"
used to give:
https://www.transifex.com/odoo/odoo-12/translate/#fr/base/42?q=text%3A%27%0A%0AThis+addon+is+already+installed+on+your+system%27

and it now returns:
https://www.transifex.com/odoo/odoo-12/translate/#fr/base/42?q=text:'This+addon+is+already+installed+on+your+system'

Searching on
'%s' does not seem to be a number
used to give:
https://www.transifex.com/odoo/odoo-12/translate/#fr/base/42?q=text:'%5C%27%25s%5C%27+does+not+seem+to+be+a+number+for+field+%5C%27%25%25%28fi'

and it now returns:
https://www.transifex.com/odoo/odoo-12/translate/#fr/base/42?q=text:'%25s+does+not+seem+to+be+a+number+for+field+%25%25%28fi'

closes odoo/odoo#33279

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
This commit is contained in:
Martin Trigaux
2019-05-09 12:55:04 +00:00
parent a515ee6064
commit de3a4c2947
+3 -4
View File
@@ -84,8 +84,7 @@ class IrTranslation(models.Model):
'project': project,
'lang': lang_code,
'module': translation.module,
'src': werkzeug.url_quote_plus(
"text:'" +
translation.source[:50].replace("'", "\\'") +
"'"),
'src': "text:'" + werkzeug.url_quote_plus(
translation.source[:50].replace("\n", "").replace("'", "")
) + "'",
}