diff --git a/udata/translations/fr/LC_MESSAGES/udata.po b/udata/translations/fr/LC_MESSAGES/udata.po index 7903ff662d..80bac44b1e 100644 --- a/udata/translations/fr/LC_MESSAGES/udata.po +++ b/udata/translations/fr/LC_MESSAGES/udata.po @@ -1555,3 +1555,34 @@ msgstr "Assez réutilisé" msgid "Heavily reused" msgstr "Souvent réutilisé" +#: udata/uris.py:53 +msgid "URL invalide : %(reason)s" +msgstr "" + +#: udata/uris.py:103 +msgid "Schéma invalide {0}, schémas autorisés : {1}" +msgstr "" + +#: udata/uris.py:106 +msgid "Les informations d'identification dans l'URL ne sont pas autorisées" +msgstr "" + +#: udata/uris.py:110 +msgid "TLD invalide {0}" +msgstr "" + +#: udata/uris.py:119 +msgid "{0} est une IP multicast" +msgstr "" + +#: udata/uris.py:121 +msgid "{0} est un masque IP" +msgstr "" + +#: udata/uris.py:125 +msgid "est une URL locale" +msgstr "" + +#: udata/uris.py:128 +msgid "est une URL privée" +msgstr "" \ No newline at end of file diff --git a/udata/translations/udata.pot b/udata/translations/udata.pot index a4a6937a37..4ac875bdfa 100644 --- a/udata/translations/udata.pot +++ b/udata/translations/udata.pot @@ -1575,3 +1575,34 @@ msgstr "" msgid "Heavily reused" msgstr "" +#: udata/uris.py:53 +msgid "Invalid URL: %(reason)s" +msgstr "" + +#: udata/uris.py:103 +msgid "Invalid scheme {0}, allowed schemes: {1}" +msgstr "" + +#: udata/uris.py:106 +msgid "Credentials in URL are not allowed" +msgstr "" + +#: udata/uris.py:110 +msgid "Invalid TLD {0}" +msgstr "" + +#: udata/uris.py:119 +msgid "{0} is a multicast IP" +msgstr "" + +#: udata/uris.py:121 +msgid "{0} is a mask IP" +msgstr "" + +#: udata/uris.py:125 +msgid "is a local URL" +msgstr "" + +#: udata/uris.py:128 +msgid "is a private URL" +msgstr "" \ No newline at end of file diff --git a/udata/uris.py b/udata/uris.py index 1204edba1e..8ebe474252 100644 --- a/udata/uris.py +++ b/udata/uris.py @@ -3,6 +3,7 @@ from werkzeug.routing import BuildError from flask import current_app, url_for from netaddr import IPAddress, AddrFormatError +from udata.i18n import _ from udata.settings import Defaults @@ -49,9 +50,7 @@ def error(url, reason=None): __tracebackhide__ = True if not isinstance(url, str): url = url.decode('utf8') - msg = 'Invalid URL "{0}"'.format(url) - if reason: - msg = ': '.join((msg, reason)) + msg = _('Invalid URL: %(reason)s', reason = reason) raise ValidationError(msg.encode('utf8')) @@ -101,14 +100,14 @@ def validate(url, schemes=None, tlds=None, private=None, local=None, scheme = (match.group('scheme') or '').lower() if scheme and scheme not in schemes: - error(url, 'Invalid scheme {0}'.format(scheme)) + error(url, _('Invalid scheme {0}, allowed schemes: {1}').format(scheme, ", ".join(schemes))) if not credentials and match.group('credentials'): - error(url, 'Credentials in URL are not allowed') + error(url, _('Credentials in URL are not allowed')) tld = match.group('tld') if tld and tld not in tlds and idna(tld) not in tlds: - error(url, 'Invalid TLD {0}'.format(tld)) + error(url, _('Invalid TLD {0}').format(tld)) ip = match.group('ipv6') or match.group('ipv4') if ip: @@ -117,15 +116,15 @@ def validate(url, schemes=None, tlds=None, private=None, local=None, except AddrFormatError: error(url) if ip.is_multicast(): - error(url, '{0} is a multicast IP'.format(ip)) + error(url, _('{0} is a multicast IP').format(ip)) elif not ip.is_loopback() and ip.is_hostmask() or ip.is_netmask(): - error(url, '{0} is a mask IP'.format(ip)) + error(url, _('{0} is a mask IP').format(ip)) if not local: if ip and ip.is_loopback() or match.group('localhost'): - error(url, 'is a local URL') + error(url, _('is a local URL')) if not private and ip and ip.is_private(): - error(url, 'is a private URL') + error(url, _('is a private URL')) return url