summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-06-02 04:20:32 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-06-02 04:20:32 +0000
commitab2fb1634f22d655ca38bd9ae7db9de3d1a629a3 (patch)
tree1df7954186b12119a2dcf0332f4c1d76d2caccfd /django
parent1717b94fc85430a1b0b8626d9b932fda58563e50 (diff)
Fixed #2062 -- Added YEAR_MONTH_FORMAT and MONTH_DAY_FORMAT settings, and added technical message IDs of the same names. Thanks, ramiro
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3055 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/conf/global_settings.py10
-rw-r--r--django/utils/translation.py21
2 files changed, 28 insertions, 3 deletions
diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
index e110a50884..640b290a6f 100644
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -203,6 +203,16 @@ DATETIME_FORMAT = 'N j, Y, P'
# http://www.djangoproject.com/documentation/templates/#now
TIME_FORMAT = 'P'
+# Default formatting for date objects when only the year and month are relevant.
+# See all available format strings here:
+# http://www.djangoproject.com/documentation/templates/#now
+YEAR_MONTH_FORMAT = 'F Y'
+
+# Default formatting for date objects when only the month and day are relevant.
+# See all available format strings here:
+# http://www.djangoproject.com/documentation/templates/#now
+MONTH_DAY_FORMAT = 'F j'
+
# Whether to enable Psyco, which optimizes Python code. Requires Psyco.
# http://psyco.sourceforge.net/
ENABLE_PSYCO = False
diff --git a/django/utils/translation.py b/django/utils/translation.py
index 81cd8e2992..a73c43c257 100644
--- a/django/utils/translation.py
+++ b/django/utils/translation.py
@@ -221,10 +221,10 @@ def get_language_bidi():
False = left-to-right layout
True = right-to-left layout
"""
-
+
from django.conf import settings
return get_language() in settings.LANGUAGES_BIDI
-
+
def catalog():
"""
This function returns the current active catalog for further processing.
@@ -369,7 +369,22 @@ def get_date_formats():
datetime_format = settings.DATETIME_FORMAT
if time_format == 'TIME_FORMAT':
time_format = settings.TIME_FORMAT
- return (date_format, datetime_format, time_format)
+ return date_format, datetime_format, time_format
+
+def get_partial_date_formats():
+ """
+ This function checks whether translation files provide a translation for some
+ technical message ID to store partial date formats. If it doesn't contain
+ one, the formats provided in the settings will be used.
+ """
+ from django.conf import settings
+ year_month_format = _('YEAR_MONTH_FORMAT')
+ month_day_format = _('MONTH_DAY_FORMAT')
+ if year_month_format == 'YEAR_MONTH_FORMAT':
+ year_month_format = settings.YEAR_MONTH_FORMAT
+ if month_day_format == 'MONTH_DAY_FORMAT':
+ month_day_format = settings.MONTH_DAY_FORMAT
+ return year_month_format, month_day_format
def install():
"""