Back to index

plone3  3.1.7
Classes | Functions
CMFDefault.formlib.form Namespace Reference

Classes

class  EditFormBase
class  ContentEditFormBase
class  DisplayFormBase

Functions

def getLocale

Function Documentation

Definition at line 37 of file form.py.

00037 
00038 def getLocale(request):
00039     envadapter = IUserPreferredLanguages(request, None)
00040     if envadapter is None:
00041         return None
00042 
00043     langs = envadapter.getPreferredLanguages()
00044     for httplang in langs:
00045         parts = (httplang.split('-') + [None, None])[:3]
00046         try:
00047             return locales.getLocale(*parts)
00048         except LoadLocaleError:
00049             # Just try the next combination
00050             pass
00051     else:
00052         # No combination gave us an existing locale, so use the default,
00053         # which is guaranteed to exist
00054         return locales.getLocale(None, None, None)
00055