getFirstSupportedLang(langs)[source]¶Return the first language in langs that we support.
| Parameters: | langs (list) – All requested languages | 
|---|---|
| Return type: | str | 
| Returns: | A country code for the client’s preferred language. | 
getLocaleFromHTTPRequest(request)[source]¶Retrieve the languages from an HTTP Accept-Language: header.
Parse the languages from the header, use them to install a
gettext.translation chain via installTranslations(), and lastly
return the requested languages.
| Parameters: | request (twisted.web.server.Request) – An incoming request from a client. | 
|---|---|
| Return type: | list | 
| Returns: | All requested languages. | 
getLocaleFromPlusAddr(address)[source]¶See whether the user sent his email to a ‘plus’ address, for instance to bridges+fa@bridges.torproject.org. Plus addresses are the current mechanism to set the reply language.
installTranslations(langs)[source]¶Create a gettext.translation chain for all langs.
Attempt to install the first language in the langs list. If that
fails, we receive a gettext.NullTranslation object, and if it worked
then we have a gettext.GNUTranslation object. Whichever one we end up
with, get the other languages and add them as fallbacks to the
first. Lastly, install this chain of translations.
| Parameters: | langs (list) – A list of language codes. | 
|---|---|
| Returns: | A gettext.NullTranslation or gettext.GNUTranslation with
fallback languages set. | 
usingRTLLang(langs)[source]¶Check if we should translate the text into a RTL language.
Choose the first language from the langs list that we support and return True if it is a RTL language, else return False.
| Parameters: | langs (list) – An incoming request. | 
|---|---|
| Return type: | bool | 
| Returns: | True if the preferred language is right-to-left; False
otherwise. |