App Engine Python SDK  v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
Classes | Functions | Variables
google.appengine._internal.django.utils.translation.trans_real Namespace Reference

Classes

class  DjangoTranslation
 

Functions

def to_locale
 
def to_language
 
def translation
 
def activate
 
def deactivate
 
def deactivate_all
 
def get_language
 
def get_language_bidi
 
def catalog
 
def do_translate
 
def gettext
 
def ugettext
 
def gettext_noop
 
def do_ntranslate
 
def ngettext
 
def ungettext
 
def check_for_language
 
def get_language_from_request
 
def blankout
 
def templatize
 
def parse_accept_lang_header
 
def get_date_formats
 
def get_partial_date_formats
 

Variables

dictionary _translations = {}
 
dictionary _active = {}
 
 _default = None
 
dictionary _accepted = {}
 
tuple accept_language_re
 
tuple dot_re = re.compile(r'\S')
 
tuple inline_re = re.compile(r"""^\s*trans\s+((?:".*?")|(?:'.*?'))\s*""")
 
tuple block_re = re.compile(r"""^\s*blocktrans(?:\s+|$)""")
 
tuple endblock_re = re.compile(r"""^\s*endblocktrans$""")
 
tuple plural_re = re.compile(r"""^\s*plural$""")
 
tuple constant_re = re.compile(r"""_\(((?:".*?")|(?:'.*?'))\)""")
 

Detailed Description

Translation helper functions.

Function Documentation

def google.appengine._internal.django.utils.translation.trans_real.activate (   language)
Fetches the translation object for a given tuple of application name and
language and installs it as the current translation object for the current
thread.
def google.appengine._internal.django.utils.translation.trans_real.blankout (   src,
  char 
)
Changes every non-whitespace character to the given char.
Used in the templatize function.
def google.appengine._internal.django.utils.translation.trans_real.catalog ( )
Returns the current active catalog for further processing.
This can be used if you need to modify the catalog or want to access the
whole message catalog instead of just translating one string.
def google.appengine._internal.django.utils.translation.trans_real.check_for_language (   lang_code)
Checks whether there is a global language file for the given language
code. This is used to decide whether a user-provided language is
available. This is only used for language codes from either the cookies or
session.
def google.appengine._internal.django.utils.translation.trans_real.deactivate ( )
Deinstalls the currently active translation object so that further _ calls
will resolve against the default translation object, again.
def google.appengine._internal.django.utils.translation.trans_real.deactivate_all ( )
Makes the active translation object a NullTranslations() instance. This is
useful when we want delayed translations to appear as the original string
for some reason.
def google.appengine._internal.django.utils.translation.trans_real.do_translate (   message,
  translation_function 
)
Translates 'message' using the given 'translation_function' name -- which
will be either gettext or ugettext. It uses the current thread to find the
translation object to use. If no current translation is activated, the
message will be run through the default translation object.
def google.appengine._internal.django.utils.translation.trans_real.get_date_formats ( )
Checks whether translation files provide a translation for some technical
message ID to store date and time formats. If it doesn't contain one, the
formats provided in the settings will be used.
def google.appengine._internal.django.utils.translation.trans_real.get_language ( )
Returns the currently selected language.
def google.appengine._internal.django.utils.translation.trans_real.get_language_bidi ( )
Returns selected language's BiDi layout.

* False = left-to-right layout
* True = right-to-left layout
def google.appengine._internal.django.utils.translation.trans_real.get_language_from_request (   request)
Analyzes the request to find what language the user wants the system to
show. Only languages listed in settings.LANGUAGES are taken into account.
If the user requests a sublanguage where we have a main language, we send
out the main language.
def google.appengine._internal.django.utils.translation.trans_real.get_partial_date_formats ( )
Checks whether translation files provide a translation for some technical
message ID to store partial date formats. If it doesn't contain one, the
formats provided in the settings will be used.
def google.appengine._internal.django.utils.translation.trans_real.gettext_noop (   message)
Marks strings for translation but doesn't translate them now. This can be
used to store strings in global variables that should stay in the base
language (because they might be used externally) and will be translated
later.
def google.appengine._internal.django.utils.translation.trans_real.ngettext (   singular,
  plural,
  number 
)
Returns a UTF-8 bytestring of the translation of either the singular or
plural, based on the number.
def google.appengine._internal.django.utils.translation.trans_real.parse_accept_lang_header (   lang_string)
Parses the lang_string, which is the body of an HTTP Accept-Language
header, and returns a list of (lang, q-value), ordered by 'q' values.

Any format errors in lang_string results in an empty list being returned.
def google.appengine._internal.django.utils.translation.trans_real.templatize (   src)
Turns a Django template into something that is understood by xgettext. It
does so by translating the Django translation tags into standard gettext
function invocations.
def google.appengine._internal.django.utils.translation.trans_real.to_language (   locale)
Turns a locale name (en_US) into a language name (en-us).
def google.appengine._internal.django.utils.translation.trans_real.to_locale (   language,
  to_lower = False 
)
Turns a language name (en-us) into a locale name (en_US). If 'to_lower' is
True, the last component is lower-cased (en_us).
def google.appengine._internal.django.utils.translation.trans_real.translation (   language)
Returns a translation object.

This translation object will be constructed out of multiple GNUTranslations
objects by merging their catalogs. It will construct a object for the
requested language and add a fallback to the default language, if it's
different from the requested language.
def google.appengine._internal.django.utils.translation.trans_real.ungettext (   singular,
  plural,
  number 
)
Returns a unicode strings of the translation of either the singular or
plural, based on the number.

Variable Documentation

tuple google.appengine._internal.django.utils.translation.trans_real.accept_language_re
Initial value:
1 = re.compile(r'''
2  ([A-Za-z]{1,8}(?:-[A-Za-z]{1,8})*|\*) # "en", "en-au", "x-y-z", "*"
3  (?:;q=(0(?:\.\d{,3})?|1(?:.0{,3})?))? # Optional "q=1.00", "q=0.8"
4  (?:\s*,\s*|$) # Multiple accepts per header.
5  ''', re.VERBOSE)