def ugettext(message, context=None): """Always return a stripped string, localized if possible""" stripped = strip_whitespace(message) message = add_context(context, stripped) if context else stripped ret = django_ugettext(message) # If the context isn't found, we need to return the string without it return stripped if ret == message else ret
def ugettext(text): """Translate a string, and escape it as plain text. Use like this in Mako:: <% from util.markup import ugettext as _ %> <p>${_("Hello, world!")}</p> Or with formatting:: <% from util.markup import HTML, ugettext as _ %> ${_("Write & send {start}email{end}").format( start=HTML("<a href='mailto:[email protected]'>"), end=HTML("</a>"), )} """ return markupsafe.escape(django_ugettext(text))
def ugettext(message): return smart_unicode(django_ugettext(message))