Package turbogears :: Package i18n :: Module utils

Module utils

source code

General i18n utility functions.

Classes
  TGURLopener
Functions
 
google_translate(from_lang, to_lang, text)
Translate text via the translate.google.com service.
source code
 
lang_in_gettext_format(lang) source code
 
get_accept_languages(accept)
Get the list of accepted languages, by order of preference.
source code
 
get_locale(locale=None)
Get the user locale.
source code
 
set_session_locale(locale)
Set the i18n session locale.
source code
Variables
  __package__ = 'turbogears.i18n'
Function Details

google_translate(from_lang, to_lang, text)

source code 

Translate text via the translate.google.com service.

The source language is given by 'from_lang' and the target language as 'to_lang'. 'text' must be a unicode or UTF-8 encoded string.

get_accept_languages(accept)

source code 

Get the list of accepted languages, by order of preference.

THis is based on the HTTP Accept-Language string. See W3C RFC 2616 (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) for specification.

get_locale(locale=None)

source code 

Get the user locale.

This is done using _get_locale or an app-specific locale lookup function.

set_session_locale(locale)

source code 

Set the i18n session locale.

Raises an error if session support is not enabled.