root / env / lib / python2.7 / site-packages / django / utils / translation / trans_null.py @ 1a305335
History | View | Annotate | Download (1.94 KB)
1 | 1a305335 | officers | # These are versions of the functions in django.utils.translation.trans_real
|
---|---|---|---|
2 | # that don't actually do anything. This is purely for performance, so that
|
||
3 | # settings.USE_I18N = False can use this module rather than trans_real.py.
|
||
4 | |||
5 | from django.conf import settings |
||
6 | from django.utils.encoding import force_unicode |
||
7 | from django.utils.safestring import mark_safe, SafeData |
||
8 | |||
9 | def ngettext(singular, plural, number): |
||
10 | if number == 1: return singular |
||
11 | return plural
|
||
12 | ngettext_lazy = ngettext |
||
13 | |||
14 | def ungettext(singular, plural, number): |
||
15 | return force_unicode(ngettext(singular, plural, number))
|
||
16 | |||
17 | def pgettext(context, message): |
||
18 | return ugettext(message)
|
||
19 | |||
20 | def npgettext(context, singular, plural, number): |
||
21 | return ungettext(singular, plural, number)
|
||
22 | |||
23 | activate = lambda x: None |
||
24 | deactivate = deactivate_all = lambda: None |
||
25 | get_language = lambda: settings.LANGUAGE_CODE
|
||
26 | get_language_bidi = lambda: settings.LANGUAGE_CODE in settings.LANGUAGES_BIDI |
||
27 | check_for_language = lambda x: True |
||
28 | |||
29 | # date formats shouldn't be used using gettext anymore. This
|
||
30 | # is kept for backward compatibility
|
||
31 | TECHNICAL_ID_MAP = { |
||
32 | "DATE_WITH_TIME_FULL": settings.DATETIME_FORMAT,
|
||
33 | "DATE_FORMAT": settings.DATE_FORMAT,
|
||
34 | "DATETIME_FORMAT": settings.DATETIME_FORMAT,
|
||
35 | "TIME_FORMAT": settings.TIME_FORMAT,
|
||
36 | "YEAR_MONTH_FORMAT": settings.YEAR_MONTH_FORMAT,
|
||
37 | "MONTH_DAY_FORMAT": settings.MONTH_DAY_FORMAT,
|
||
38 | } |
||
39 | |||
40 | def gettext(message): |
||
41 | result = TECHNICAL_ID_MAP.get(message, message) |
||
42 | if isinstance(message, SafeData): |
||
43 | return mark_safe(result)
|
||
44 | return result
|
||
45 | |||
46 | def ugettext(message): |
||
47 | return force_unicode(gettext(message))
|
||
48 | |||
49 | gettext_noop = gettext_lazy = _ = gettext |
||
50 | |||
51 | def to_locale(language): |
||
52 | p = language.find('-')
|
||
53 | if p >= 0: |
||
54 | return language[:p].lower()+'_'+language[p+1:].upper() |
||
55 | else:
|
||
56 | return language.lower()
|
||
57 | |||
58 | def get_language_from_request(request, check_path=False): |
||
59 | return settings.LANGUAGE_CODE
|
||
60 | |||
61 | def get_language_from_path(request): |
||
62 | return None |