Package turbogears :: Package i18n :: Module utils
[hide private]

Module utils

source code

General i18n utility functions.

Functions [hide private]
 
google_translate(from_lang, to_lang, text) source code
 
lang_in_gettext_format(lang) source code
 
get_accept_languages(accept)
Returns a list of languages, by order of preference, based on an HTTP Accept-Language string.See W3C RFC 2616 (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) for specification.
source code
 
get_locale(locale=None)
Returns user locale, using _get_locale or app-specific locale lookup function.
source code
 
_get_locale()
Default function for returning locale.
source code
 
_get_locale_from_accept_header()
Checks HTTP Accept-Language header to find preferred language if any.
source code
 
set_session_locale(locale)
Sets the i18n session locale.
source code
Function Details [hide private]

_get_locale()

source code 

Default function for returning locale. First looks in session for locale key, then checks the HTTP Accept-Language header, and finally checks the config default locale setting. This can be replaced by your own function by setting cherrypy config setting i18n.get_locale to your function name.

set_session_locale(locale)

source code 

Sets the i18n session locale.

Raises an error if session support is not enabled.