Commit deb2c700 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[validation api] properly use yams 0.36 validation error api and update...

[validation api] properly use yams 0.36 validation error api and update message catalog. Follows bbe0d6985e59

the creation of the `translate` method in the 23a10f049447 yams commit.
parent 41259e1f9d48
......@@ -215,7 +215,7 @@ def validation_error(entity, errors, substitutions=None, i18nvalues=None):
"""
if substitutions is None:
# set empty dict else translation won't be done for backward
# compatibility reason (see ValidationError.tr method)
# compatibility reason (see ValidationError.translate method)
substitutions = {}
for key in errors.keys():
if isinstance(key, tuple):
......
......@@ -165,14 +165,12 @@ class SchemaHooksTC(CubicWebTC):
self.execute, 'INSERT CWRType X: X name "in_group"')
def test_validation_unique_constraint(self):
self.assertRaises(ValidationError,
self.execute, 'INSERT CWUser X: X login "admin"')
try:
with self.assertRaises(ValidationError) as cm:
self.execute('INSERT CWUser X: X login "admin"')
except ValidationError, ex:
ex.tr(unicode)
self.assertIsInstance(ex.entity, int)
self.assertEqual(ex.errors, {'login-subject': 'the value "admin" is already used, use another one'})
ex = cm.exception
ex.translate(unicode)
self.assertIsInstance(ex.entity, int)
self.assertEqual(ex.errors, {'login-subject': 'the value "admin" is already used, use another one'})
if __name__ == '__main__':
......
# -*- coding: utf-8 -*-
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
......@@ -31,11 +31,11 @@ class CWPropertyHooksTC(CubicWebTC):
def test_unexistant_cwproperty(self):
with self.assertRaises(ValidationError) as cm:
self.execute('INSERT CWProperty X: X pkey "bla.bla", X value "hop", X for_user U')
cm.exception.tr(unicode)
cm.exception.translate(unicode)
self.assertEqual(cm.exception.errors, {'pkey-subject': 'unknown property key bla.bla'})
with self.assertRaises(ValidationError) as cm:
self.execute('INSERT CWProperty X: X pkey "bla.bla", X value "hop"')
cm.exception.tr(unicode)
cm.exception.translate(unicode)
self.assertEqual(cm.exception.errors, {'pkey-subject': 'unknown property key bla.bla'})
def test_site_wide_cwproperty(self):
......
......@@ -49,6 +49,14 @@ msgstr ""
msgid "\"role=subject\" or \"role=object\" must be specified in options"
msgstr ""
#, python-format
msgid "%(KEY-cstr)s constraint failed for value %(KEY-value)r"
msgstr ""
#, python-format
msgid "%(KEY-value)r doesn't match the %(KEY-regexp)r regular expression"
msgstr ""
#, python-format
msgid "%(attr)s set to %(newvalue)s"
msgstr "%(attr)s geändert in %(newvalue)s"
......@@ -57,10 +65,6 @@ msgstr "%(attr)s geändert in %(newvalue)s"
msgid "%(attr)s updated from %(oldvalue)s to %(newvalue)s"
msgstr "%(attr)s geändert von %(oldvalue)s in %(newvalue)s"
#, python-format
msgid "%(cstr)s constraint failed for value %(value)r"
msgstr "%(cstr)s Einschränkung verletzt für Wert %(value)r"
#, python-format
msgid "%(etype)s by %(author)s"
msgstr ""
......@@ -73,10 +77,6 @@ msgstr "%(firstname)s %(surname)s"
msgid "%(subject)s %(etype)s #%(eid)s (%(login)s)"
msgstr "%(subject)s %(etype)s #%(eid)s (%(login)s)"
#, python-format
msgid "%(value)r doesn't match the %(regexp)r regular expression"
msgstr "%(value)r entspricht nicht dem regulären Ausdruck %(regexp)r"
#, python-format
msgid "%d days"
msgstr "%d Tage"
......@@ -427,6 +427,11 @@ msgstr ""
msgid "Click to sort on this column"
msgstr ""
msgid ""
"Configuration of the system source goes to the 'sources' file, not in the "
"database"
msgstr ""
#, python-format
msgid "Created %(etype)s : %(entity)s"
msgstr ""
......@@ -897,6 +902,9 @@ msgstr ""
msgid "UniqueConstraint"
msgstr "eindeutige Einschränkung"
msgid "Unknown source type"
msgstr ""
msgid "Unreachable objects"
msgstr "unzugängliche Objekte"
......@@ -955,6 +963,15 @@ msgstr ""
msgid "You can use any of the following substitutions in your text"
msgstr "Sie können die folgenden Ersetzungen in Ihrem Text verwenden:"
msgid "You can't change this relation"
msgstr ""
msgid "You cannot remove the system source"
msgstr ""
msgid "You cannot rename the system source"
msgstr ""
msgid ""
"You have no access to this view or it can not be used to display the current "
"data."
......@@ -1384,11 +1401,7 @@ msgstr "kann nicht geändert werden"
msgid "can't be deleted"
msgstr "kann nicht entfernt werden"
#, python-format
msgid "can't change the %s attribute"
msgstr "Kann das Attribut %s nicht ändern."
msgid "can't change this relation"
msgid "can't change this attribute"
msgstr ""
#, python-format
......@@ -2854,8 +2867,8 @@ msgid "incorrect captcha value"
msgstr "Unzulässiger Wert für Überschrift"
#, python-format
msgid "incorrect value (%(value)s) for type \"%(type)s\""
msgstr "Wert %(value)s ungültig für den Typ \"%(type)s\""
msgid "incorrect value (%(KEY-value)r) for type \"%(KEY-type)s\""
msgstr ""
msgid "index this attribute's value in the plain text index"
msgstr "indizieren des Wertes dieses Attributs im Volltext-Index"
......@@ -2933,8 +2946,8 @@ msgid "invalid action %r"
msgstr "Ungültige Aktion %r"
#, python-format
msgid "invalid value %(value)s, it must be one of %(choices)s"
msgstr "Wert %(value)s ungültig, er muss zwischen %(choices)s"
msgid "invalid value %(KEY-value)s, it must be one of %(KEY-choices)s"
msgstr ""
msgid "is"
msgstr "vom Typ"
......@@ -4314,9 +4327,6 @@ msgstr ""
msgid "unknown property key %s"
msgstr "Unbekannter Eigentumsschlüssel %s"
msgid "unknown source type"
msgstr ""
msgid "unknown vocabulary:"
msgstr "Unbekanntes Wörterbuch : "
......@@ -4462,15 +4472,7 @@ msgid "value"
msgstr "Wert"
#, python-format
msgid "value %(value)s must be %(op)s %(boundary)s"
msgstr ""
#, python-format
msgid "value %(value)s must be <= %(boundary)s"
msgstr ""
#, python-format
msgid "value %(value)s must be >= %(boundary)s"
msgid "value %(KEY-value)s must be %(KEY-op)s %(KEY-boundary)s"
msgstr ""
msgid "value associated to this key is not editable manually"
......@@ -4479,11 +4481,11 @@ msgstr ""
"werden."
#, python-format
msgid "value should have maximum size of %s but found %s"
msgid "value should have maximum size of %(KEY-max)s but found %(KEY-size)s"
msgstr ""
#, python-format
msgid "value should have minimum size of %s but found %s"
msgid "value should have minimum size of %(KEY-min)s but found %(KEY-size)s"
msgstr ""
msgid "vcard"
......@@ -4628,9 +4630,24 @@ msgstr "Sie sollten diese Eigenschaft wahrscheinlich löschen."
msgid "you should un-inline relation %s which is supported and may be crossed "
msgstr ""
#~ msgid "%(cstr)s constraint failed for value %(value)r"
#~ msgstr "%(cstr)s Einschränkung verletzt für Wert %(value)r"
#~ msgid "%(value)r doesn't match the %(regexp)r regular expression"
#~ msgstr "%(value)r entspricht nicht dem regulären Ausdruck %(regexp)r"
#~ msgid ""
#~ "Can't restore relation %(rtype)s of entity %(eid)s, this relation does "
#~ "not exists anymore in the schema."
#~ msgstr ""
#~ "Kann die Relation %(rtype)s der Entität %(eid)s nicht wieder herstellen, "
#~ "diese Relation existiert nicht mehr in dem Schema."
#~ msgid "can't change the %s attribute"
#~ msgstr "Kann das Attribut %s nicht ändern."
#~ msgid "incorrect value (%(value)s) for type \"%(type)s\""
#~ msgstr "Wert %(value)s ungültig für den Typ \"%(type)s\""
#~ msgid "invalid value %(value)s, it must be one of %(choices)s"
#~ msgstr "Wert %(value)s ungültig, er muss zwischen %(choices)s"
......@@ -42,31 +42,31 @@ msgid "\"role=subject\" or \"role=object\" must be specified in options"
msgstr ""
#, python-format
msgid "%(attr)s set to %(newvalue)s"
msgid "%(KEY-cstr)s constraint failed for value %(KEY-value)r"
msgstr ""
#, python-format
msgid "%(attr)s updated from %(oldvalue)s to %(newvalue)s"
msgid "%(KEY-value)r doesn't match the %(KEY-regexp)r regular expression"
msgstr ""
#, python-format
msgid "%(cstr)s constraint failed for value %(value)r"
msgid "%(attr)s set to %(newvalue)s"
msgstr ""
#, python-format
msgid "%(etype)s by %(author)s"
msgid "%(attr)s updated from %(oldvalue)s to %(newvalue)s"
msgstr ""
#, python-format
msgid "%(firstname)s %(surname)s"
msgid "%(etype)s by %(author)s"
msgstr ""
#, python-format
msgid "%(subject)s %(etype)s #%(eid)s (%(login)s)"
msgid "%(firstname)s %(surname)s"
msgstr ""
#, python-format
msgid "%(value)r doesn't match the %(regexp)r regular expression"
msgid "%(subject)s %(etype)s #%(eid)s (%(login)s)"
msgstr ""
#, python-format
......@@ -405,6 +405,11 @@ msgstr ""
msgid "Click to sort on this column"
msgstr ""
msgid ""
"Configuration of the system source goes to the 'sources' file, not in the "
"database"
msgstr ""
#, python-format
msgid "Created %(etype)s : %(entity)s"
msgstr ""
......@@ -873,6 +878,9 @@ msgstr ""
msgid "UniqueConstraint"
msgstr "unique constraint"
msgid "Unknown source type"
msgstr ""
msgid "Unreachable objects"
msgstr ""
......@@ -924,6 +932,15 @@ msgstr ""
msgid "You can use any of the following substitutions in your text"
msgstr ""
msgid "You can't change this relation"
msgstr ""
msgid "You cannot remove the system source"
msgstr ""
msgid "You cannot rename the system source"
msgstr ""
msgid ""
"You have no access to this view or it can not be used to display the current "
"data."
......@@ -1341,11 +1358,7 @@ msgstr ""
msgid "can't be deleted"
msgstr ""
#, python-format
msgid "can't change the %s attribute"
msgstr ""
msgid "can't change this relation"
msgid "can't change this attribute"
msgstr ""
#, python-format
......@@ -2783,7 +2796,7 @@ msgid "incorrect captcha value"
msgstr ""
#, python-format
msgid "incorrect value (%(value)s) for type \"%(type)s\""
msgid "incorrect value (%(KEY-value)r) for type \"%(KEY-type)s\""
msgstr ""
msgid "index this attribute's value in the plain text index"
......@@ -2860,7 +2873,7 @@ msgid "invalid action %r"
msgstr ""
#, python-format
msgid "invalid value %(value)s, it must be one of %(choices)s"
msgid "invalid value %(KEY-value)s, it must be one of %(KEY-choices)s"
msgstr ""
msgid "is"
......@@ -4214,9 +4227,6 @@ msgstr ""
msgid "unknown property key %s"
msgstr ""
msgid "unknown source type"
msgstr ""
msgid "unknown vocabulary:"
msgstr ""
......@@ -4353,26 +4363,18 @@ msgid "value"
msgstr ""
#, python-format
msgid "value %(value)s must be %(op)s %(boundary)s"
msgstr ""
#, python-format
msgid "value %(value)s must be <= %(boundary)s"
msgstr ""
#, python-format
msgid "value %(value)s must be >= %(boundary)s"
msgid "value %(KEY-value)s must be %(KEY-op)s %(KEY-boundary)s"
msgstr ""
msgid "value associated to this key is not editable manually"
msgstr ""
#, python-format
msgid "value should have maximum size of %s but found %s"
msgid "value should have maximum size of %(KEY-max)s but found %(KEY-size)s"
msgstr ""
#, python-format
msgid "value should have minimum size of %s but found %s"
msgid "value should have minimum size of %(KEY-min)s but found %(KEY-size)s"
msgstr ""
msgid "vcard"
......
......@@ -50,6 +50,14 @@ msgid "\"role=subject\" or \"role=object\" must be specified in options"
msgstr ""
"\"role=subject\" o \"role=object\" debe ser especificado en las opciones"
#, python-format
msgid "%(KEY-cstr)s constraint failed for value %(KEY-value)r"
msgstr ""
#, python-format
msgid "%(KEY-value)r doesn't match the %(KEY-regexp)r regular expression"
msgstr ""
#, python-format
msgid "%(attr)s set to %(newvalue)s"
msgstr "%(attr)s modificado a %(newvalue)s"
......@@ -58,10 +66,6 @@ msgstr "%(attr)s modificado a %(newvalue)s"
msgid "%(attr)s updated from %(oldvalue)s to %(newvalue)s"
msgstr "%(attr)s modificado de %(oldvalue)s a %(newvalue)s"
#, python-format
msgid "%(cstr)s constraint failed for value %(value)r"
msgstr "el valor %(value)r no satisface la condición %(cstr)s"
#, python-format
msgid "%(etype)s by %(author)s"
msgstr "%(etype)s por %(author)s"
......@@ -74,10 +78,6 @@ msgstr "%(firstname)s %(surname)s"
msgid "%(subject)s %(etype)s #%(eid)s (%(login)s)"
msgstr "%(subject)s %(etype)s #%(eid)s (%(login)s)"
#, python-format
msgid "%(value)r doesn't match the %(regexp)r regular expression"
msgstr "%(value)r no corresponde a la expresión regular %(regexp)r"
#, python-format
msgid "%d days"
msgstr "%d días"
......@@ -427,6 +427,11 @@ msgstr ""
msgid "Click to sort on this column"
msgstr ""
msgid ""
"Configuration of the system source goes to the 'sources' file, not in the "
"database"
msgstr ""
#, python-format
msgid "Created %(etype)s : %(entity)s"
msgstr ""
......@@ -900,6 +905,9 @@ msgstr ""
msgid "UniqueConstraint"
msgstr "Restricción de Unicidad"
msgid "Unknown source type"
msgstr ""
msgid "Unreachable objects"
msgstr "Objetos inaccesibles"
......@@ -960,6 +968,15 @@ msgstr ""
"Puede realizar cualquiera de las siguientes sustituciones en el contenido de "
"su email."
msgid "You can't change this relation"
msgstr ""
msgid "You cannot remove the system source"
msgstr ""
msgid "You cannot rename the system source"
msgstr ""
msgid ""
"You have no access to this view or it can not be used to display the current "
"data."
......@@ -1395,12 +1412,8 @@ msgstr "No puede ser modificado"
msgid "can't be deleted"
msgstr "No puede ser eliminado"
#, python-format
msgid "can't change the %s attribute"
msgstr "no puede modificar el atributo %s"
msgid "can't change this relation"
msgstr "no puede modificar esta relación"
msgid "can't change this attribute"
msgstr ""
#, python-format
msgid "can't connect to source %s, some data may be missing"
......@@ -2896,8 +2909,8 @@ msgid "incorrect captcha value"
msgstr "Valor del Captcha incorrecto"
#, python-format
msgid "incorrect value (%(value)s) for type \"%(type)s\""
msgstr "valor %(value)s incorrecto para el tipo \"%(type)s\""
msgid "incorrect value (%(KEY-value)r) for type \"%(KEY-type)s\""
msgstr ""
msgid "index this attribute's value in the plain text index"
msgstr "Indexar el valor de este atributo en el índice de texto simple"
......@@ -2976,8 +2989,8 @@ msgid "invalid action %r"
msgstr "Acción %r invalida"
#, python-format
msgid "invalid value %(value)s, it must be one of %(choices)s"
msgstr "Valor %(value)s incorrecto, debe estar entre %(choices)s"
msgid "invalid value %(KEY-value)s, it must be one of %(KEY-choices)s"
msgstr ""
msgid "is"
msgstr "es"
......@@ -4364,9 +4377,6 @@ msgstr "opciones desconocidas: %s"
msgid "unknown property key %s"
msgstr "Clave de Propiedad desconocida: %s"
msgid "unknown source type"
msgstr "tipo de fuente desconocida"
msgid "unknown vocabulary:"
msgstr "Vocabulario desconocido: "
......@@ -4512,26 +4522,18 @@ msgid "value"
msgstr "Vampr"
#, python-format
msgid "value %(value)s must be %(op)s %(boundary)s"
msgstr ""
#, python-format
msgid "value %(value)s must be <= %(boundary)s"
msgstr ""
#, python-format
msgid "value %(value)s must be >= %(boundary)s"
msgid "value %(KEY-value)s must be %(KEY-op)s %(KEY-boundary)s"
msgstr ""
msgid "value associated to this key is not editable manually"
msgstr "El valor asociado a este elemento no es editable manualmente"
#, python-format
msgid "value should have maximum size of %s but found %s"
msgid "value should have maximum size of %(KEY-max)s but found %(KEY-size)s"
msgstr ""
#, python-format
msgid "value should have minimum size of %s but found %s"
msgid "value should have minimum size of %(KEY-min)s but found %(KEY-size)s"
msgstr ""
msgid "vcard"
......@@ -4679,9 +4681,30 @@ msgstr ""
"usted debe quitar la puesta en línea de la relación %s que es aceptada y "
"puede ser cruzada"
#~ msgid "%(cstr)s constraint failed for value %(value)r"
#~ msgstr "el valor %(value)r no satisface la condición %(cstr)s"
#~ msgid "%(value)r doesn't match the %(regexp)r regular expression"
#~ msgstr "%(value)r no corresponde a la expresión regular %(regexp)r"
#~ msgid ""
#~ "Can't restore relation %(rtype)s of entity %(eid)s, this relation does "
#~ "not exists anymore in the schema."
#~ msgstr ""
#~ "No puede restaurar la relación %(rtype)s de la entidad %(eid)s, esta "
#~ "relación ya no existe en el esquema."
#~ msgid "can't change the %s attribute"
#~ msgstr "no puede modificar el atributo %s"
#~ msgid "can't change this relation"
#~ msgstr "no puede modificar esta relación"
#~ msgid "incorrect value (%(value)s) for type \"%(type)s\""
#~ msgstr "valor %(value)s incorrecto para el tipo \"%(type)s\""
#~ msgid "invalid value %(value)s, it must be one of %(choices)s"
#~ msgstr "Valor %(value)s incorrecto, debe estar entre %(choices)s"
#~ msgid "unknown source type"
#~ msgstr "tipo de fuente desconocida"
......@@ -49,6 +49,15 @@ msgid "\"role=subject\" or \"role=object\" must be specified in options"
msgstr ""
"\"role=subject\" ou \"role=object\" doit être specifié dans les options"
#, python-format
msgid "%(KEY-cstr)s constraint failed for value %(KEY-value)r"
msgstr "la valeur %(KEY-value)r ne satisfait pas la contrainte %(KEY-cstr)s"
#, python-format
msgid "%(KEY-value)r doesn't match the %(KEY-regexp)r regular expression"
msgstr ""
"%(KEY-value)r ne correspond pas à l'expression régulière %(KEY-regexp)r"
#, python-format
msgid "%(attr)s set to %(newvalue)s"
msgstr "%(attr)s modifié à %(newvalue)s"
......@@ -57,10 +66,6 @@ msgstr "%(attr)s modifié à %(newvalue)s"
msgid "%(attr)s updated from %(oldvalue)s to %(newvalue)s"
msgstr "%(attr)s modifié de %(oldvalue)s à %(newvalue)s"
#, python-format
msgid "%(cstr)s constraint failed for value %(value)r"
msgstr "la valeur %(value)r ne satisfait pas la contrainte %(cstr)s"
#, python-format
msgid "%(etype)s by %(author)s"
msgstr "%(etype)s par %(author)s"
......@@ -73,10 +78,6 @@ msgstr "%(firstname)s %(surname)s"
msgid "%(subject)s %(etype)s #%(eid)s (%(login)s)"
msgstr "%(subject)s %(etype)s #%(eid)s (%(login)s)"
#, python-format
msgid "%(value)r doesn't match the %(regexp)r regular expression"
msgstr "%(value)r ne correspond pas à l'expression régulière %(regexp)r"
#, python-format
msgid "%d days"
msgstr "%d jours"
......@@ -427,6 +428,11 @@ msgstr ""
msgid "Click to sort on this column"
msgstr "Cliquer pour trier sur cette colonne"
msgid ""
"Configuration of the system source goes to the 'sources' file, not in the "
"database"
msgstr ""
#, python-format
msgid "Created %(etype)s : %(entity)s"
msgstr "Entité %(etype)s crée : %(entity)s"
......@@ -900,6 +906,9 @@ msgstr "Annuler"
msgid "UniqueConstraint"
msgstr "contrainte d'unicité"
msgid "Unknown source type"
msgstr "Type de source inconnue"
msgid "Unreachable objects"
msgstr "Objets inaccessibles"
......@@ -960,6 +969,15 @@ msgstr ""
"Vous pouvez utiliser n'importe quelle substitution parmi la liste suivante "
"dans le contenu de votre courriel."
msgid "You can't change this relation"
msgstr "Vous ne pouvez pas modifier cette relation"
msgid "You cannot remove the system source"
msgstr "Vous ne pouvez pas supprimer la source système"
msgid "You cannot rename the system source"
msgstr "Vous ne pouvez pas renommer la source système"
msgid ""
"You have no access to this view or it can not be used to display the current "
"data."
......@@ -1301,7 +1319,7 @@ msgid "bad value"
msgstr "mauvaise valeur"
msgid "badly formatted url"
msgstr ""
msgstr "URL mal formattée"
msgid "base url"
msgstr "url de base"
......@@ -1389,7 +1407,7 @@ msgid "can not resolve entity types:"
msgstr "impossible d'interpréter les types d'entités :"
msgid "can only have one url"
msgstr ""
msgstr "ne supporte qu'une seule URL"
msgid "can't be changed"
msgstr "ne peut-être modifié"
......@@ -1397,12 +1415,8 @@ msgstr "ne peut-être modifié"
msgid "can't be deleted"
msgstr "ne peut-être supprimé"
#, python-format
msgid "can't change the %s attribute"
msgstr "ne peut changer l'attribut %s"
msgid "can't change this relation"
msgstr "ne peut modifier cette relation"
msgid "can't change this attribute"
msgstr "cet attribut ne peut pas être modifié"
#, python-format
msgid "can't connect to source %s, some data may be missing"
......@@ -2902,8 +2916,8 @@ msgid "incorrect captcha value"
msgstr "valeur de captcha incorrecte"
#, python-format
msgid "incorrect value (%(value)s) for type \"%(type)s\""
msgstr "valeur %(value)s incorrecte pour le type \"%(type)s\""
msgid "incorrect value (%(KEY-value)r) for type \"%(KEY-type)s\""
msgstr "la valeur %(KEY-value)s est incorrecte pour le type \"%(KEY-type)s\""
msgid "index this attribute's value in the plain text index"
msgstr "indexer la valeur de cet attribut dans l'index plein texte"
......@@ -2982,8 +2996,9 @@ msgid "invalid action %r"
msgstr "action %r invalide"
#, python-format
msgid "invalid value %(value)s, it must be one of %(choices)s"
msgstr "valeur %(value)s incorrect, doit être parmi %(choices)s"
msgid "invalid value %(KEY-value)s, it must be one of %(KEY-choices)s"
msgstr ""
"la valeur %(KEY-value)s est incorrecte, elle doit être parmi %(KEY-choices)s"
msgid "is"
msgstr "de type"
......@@ -4375,14 +4390,11 @@ msgstr "options inconnues : %s"