Changeset 7206
- Timestamp:
- 03/07/08 21:55:47 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/utils/translation/trans_real.py
r7185 r7206 1 " Translation helper functions"1 """Translation helper functions.""" 2 2 3 3 import locale … … 8 8 from cStringIO import StringIO 9 9 10 from django.utils.encoding import force_unicode11 10 from django.utils.safestring import mark_safe, SafeData 12 11 … … 31 30 _default = None 32 31 33 # This is a cache for normali sed accept-header languages to prevent multiple32 # This is a cache for normalized accept-header languages to prevent multiple 34 33 # file lookups when checking the same locale on repeated requests. 35 34 _accepted = {} … … 57 56 58 57 def to_language(locale): 59 " Turns a locale name (en_US) into a language name (en-us)."58 """Turns a locale name (en_US) into a language name (en-us).""" 60 59 p = locale.find('_') 61 60 if p >= 0: … … 230 229 231 230 def get_language(): 232 " Returns the currently selected language."231 """Returns the currently selected language.""" 233 232 t = _active.get(currentThread(), None) 234 233 if t is not None: … … 252 251 def catalog(): 253 252 """ 254 This function returns the current active catalog for further processing.253 Returns the current active catalog for further processing. 255 254 This can be used if you need to modify the catalog or want to access the 256 255 whole message catalog instead of just translating one string. … … 375 374 if not normalized: 376 375 continue 377 # Remove the default encoding from locale_alias 376 # Remove the default encoding from locale_alias. 378 377 normalized = normalized.split('.')[0] 379 378 … … 397 396 def get_date_formats(): 398 397 """ 399 This function checks whether translation files provide a translation for some400 technical message ID to store date and time formats. If it doesn't contain401 one, theformats provided in the settings will be used.398 Checks whether translation files provide a translation for some technical 399 message ID to store date and time formats. If it doesn't contain one, the 400 formats provided in the settings will be used. 402 401 """ 403 402 from django.conf import settings … … 415 414 def get_partial_date_formats(): 416 415 """ 417 This function checks whether translation files provide a translation for some418 technical message ID to store partial date formats. If it doesn't contain419 one, theformats provided in the settings will be used.416 Checks whether translation files provide a translation for some technical 417 message ID to store partial date formats. If it doesn't contain one, the 418 formats provided in the settings will be used. 420 419 """ 421 420 from django.conf import settings … … 441 440 plural_re = re.compile(r"""^\s*plural$""") 442 441 constant_re = re.compile(r"""_\(((?:".*?")|(?:'.*?'))\)""") 442 443 443 def templatize(src): 444 444 """ … … 476 476 inplural = True 477 477 else: 478 raise SyntaxError , "Translation blocks must not include other block tags: %s" % t.contents478 raise SyntaxError("Translation blocks must not include other block tags: %s" % t.contents) 479 479 elif t.token_type == TOKEN_VAR: 480 480 if inplural: … … 542 542 result.sort(lambda x, y: -cmp(x[1], y[1])) 543 543 return result 544
