Exemple #1
0
 def gettext_translate(string):
     """ Translate untranslated strings with FormEncode."""
     # Try default translation first
     translation = localizer.old_translate(i18n.TranslationString(string))
     if translation == string:
         # translation failed then use FormEncode
         translation = formencode_api._stdtrans(string)
     return translation
Exemple #2
0
 def gettext_translate(string):
     """ Translate untranslated strings with FormEncode."""
     # Try default translation first
     translation = localizer.old_translate(i18n.TranslationString(string))
     if translation == string:
         # translation failed then use FormEncode
         translation = formencode_api._stdtrans(string)
     return translation
def pylons_formencode_gettext(value):
    """Translates a string ``value`` using pylons gettext first and if
    that fails, formencode gettext.

    This allows to "merge" localized error messages from built-in
    FormEncode's validators with application-specific validators.

    """
    trans = pylons_gettext(value)
    if trans == value:
        # translation failed, try formencode
        trans = api._stdtrans(value)
    return trans
Exemple #4
0
def pylons_formencode_gettext(value):
    """Translates a string ``value`` using pylons gettext first and if
    that fails, formencode gettext.

    This allows to "merge" localized error messages from built-in
    FormEncode's validators with application-specific validators.

    """
    trans = pylons_gettext(value)
    if trans == value:
        # translation failed, try formencode
        trans = api._stdtrans(value)
    return trans