public
Description: An addition to django that allows better presentation of date strings in a local way.
Homepage: http://code.google.com/p/django-localdates/
Clone URL: git://github.com/orestis/django-localdates.git
Click here to lend your support to: django-localdates and make a donation at www.pledgie.com !
added support for translatable strings

git-svn-id: https://django-localdates.googlecode.com/svn/trunk@9 
2d4215e5-4f35-0410-b94f-7947a7918f2f
orestis (author)
Tue Jul 17 12:23:27 -0700 2007
commit  b850ade3f34be412c658e7b466901176958d16cd
tree    02a5d4c4fa159d9c3d42c6d11a548eef89792a70
parent  3ce5ff131b63c0e02098fdb68535a6e38ab85256
...
9
10
11
12
 
 
13
14
15
16
 
17
18
19
...
30
31
32
33
 
 
34
35
36
37
 
 
38
39
40
...
70
71
72
 
 
73
74
 
 
 
 
 
 
75
76
77
...
88
89
90
 
 
91
92
93
...
9
10
11
 
12
13
14
15
16
17
18
19
20
21
...
32
33
34
 
35
36
37
38
39
 
40
41
42
43
44
...
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
...
100
101
102
103
104
105
106
107
0
@@ -9,11 +9,13 @@ local_re = re.compile(r'(\{\w{2}\})')
0
 #to trigger translation
0
 dummy_formats = (
0
     _('FULL_DATE'),
0
- _('ABBR_DATE'),
0
+ _('ABBR_DATE'),
0
+ _('ABBR2_DATE'),
0
     _('NUM_DATE'),
0
    
0
     _('FULL_DATETIME'),
0
     _('ABBR_DATETIME'),
0
+ _('ABBR2_DATETIME'),
0
     _('NUM_DATETIME'),
0
     
0
     _('FULL_TIME'),
0
@@ -30,11 +32,13 @@ dummy_formats = (
0
 # default to english
0
 default_format_strings = {
0
     'FULL_DATE':'l, N j, Y',
0
- 'ABBR_DATE':'N j, Y',
0
+ 'ABBR_DATE':'F j, Y',
0
+ 'ABBR2_DATE':'M j, Y',
0
     'NUM_DATE':'n/j/Y',
0
 
0
     'FULL_DATETIME':'l, N j, Y, P',
0
- 'ABBR_DATETIME':'N j, Y, P',
0
+ 'ABBR_DATETIME':'F j, Y, P',
0
+ 'ABBR2_DATETIME':'M j, Y, P',
0
     'NUM_DATETIME':'n/j/Y, P',
0
     
0
     'FULL_TIME':'P',
0
@@ -70,8 +74,16 @@ local_standard_string = r'('+(r'|'.join([r'\{%s\}'%key for key in get_local_form
0
 
0
 local_standard_re = re.compile(local_standard_string)
0
 
0
+local_trans_re = re.compile(r'(\{_\(.+?\)\})')
0
+
0
 class LocalFormatter(object):
0
     def format(self, formatstr):
0
+ # replace the translated strings
0
+ trans_pieces = local_trans_re.findall(formatstr)
0
+ for piece in trans_pieces:
0
+ result = _(piece[3:-2])
0
+ formatstr = formatstr.replace(piece, result)
0
+
0
         # replace the standard strings with their expanded versions
0
         standard_pieces = local_standard_re.findall(formatstr)
0
         for piece in standard_pieces:
0
@@ -88,6 +100,8 @@ class LocalFormatter(object):
0
                 # we don't do anything
0
                 pass
0
         
0
+
0
+
0
         # use the standard behavior for the rest
0
         return self._format(self, formatstr)
0
 
...
8
9
10
11
 
12
13
14
...
16
17
18
19
 
20
21
22
23
 
24
 
 
 
 
25
26
27
 
28
29
30
31
 
32
33
34
35
 
36
 
 
 
 
37
38
39
 
40
41
42
43
 
44
45
46
47
 
48
49
50
51
 
52
53
54
55
 
56
57
58
59
 
60
61
62
63
 
64
65
66
67
 
68
69
...
8
9
10
 
11
12
13
14
...
16
17
18
 
19
20
21
22
 
23
24
25
26
27
28
29
30
 
31
32
33
34
 
35
36
37
38
 
39
40
41
42
43
44
45
46
 
47
48
49
50
 
51
52
53
54
 
55
56
57
58
 
59
60
61
62
 
63
64
65
66
 
67
68
69
70
 
71
72
73
74
 
75
76
77
0
@@ -8,7 +8,7 @@ msgid ""
0
 msgstr ""
0
 "Project-Id-Version: PACKAGE VERSION\n"
0
 "Report-Msgid-Bugs-To: \n"
0
-"POT-Creation-Date: 2007-07-17 13:14+0300\n"
0
+"POT-Creation-Date: 2007-07-17 22:11+0300\n"
0
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
0
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
0
 "Language-Team: LANGUAGE <LL@li.org>\n"
0
@@ -16,54 +16,62 @@ msgstr ""
0
 "Content-Type: text/plain; charset=UTF-8\n"
0
 "Content-Transfer-Encoding: 8bit\n"
0
 
0
-#: .\local_dateformat.py:34
0
+#: .\local_dateformat.py:11
0
 msgid "FULL_DATE"
0
 msgstr "l, j {Fp}, Y"
0
 
0
-#: .\local_dateformat.py:35
0
+#: .\local_dateformat.py:12
0
 msgid "ABBR_DATE"
0
+msgstr "j {Fp}, Y"
0
+
0
+#: .\local_dateformat.py:13
0
+msgid "ABBR2_DATE"
0
 msgstr "j M, Y"
0
 
0
-#: .\local_dateformat.py:36
0
+#: .\local_dateformat.py:14
0
 msgid "NUM_DATE"
0
 msgstr "j/n/Y"
0
 
0
-#: .\local_dateformat.py:38
0
+#: .\local_dateformat.py:16
0
 msgid "FULL_DATETIME"
0
 msgstr "l, j {Fp}, Y, P"
0
 
0
-#: .\local_dateformat.py:39
0
+#: .\local_dateformat.py:17
0
 msgid "ABBR_DATETIME"
0
+msgstr "j {Fp}, Y, P"
0
+
0
+#: .\local_dateformat.py:18
0
+msgid "ABBR2_DATETIME"
0
 msgstr "j M, Y, P"
0
 
0
-#: .\local_dateformat.py:40
0
+#: .\local_dateformat.py:19
0
 msgid "NUM_DATETIME"
0
 msgstr "j/n/Y, P"
0
 
0
-#: .\local_dateformat.py:42
0
+#: .\local_dateformat.py:21
0
 msgid "FULL_TIME"
0
 msgstr "P"
0
 
0
-#: .\local_dateformat.py:44
0
+#: .\local_dateformat.py:23
0
 msgid "FULL_YEARMONTH"
0
 msgstr "F Y"
0
 
0
-#: .\local_dateformat.py:45
0
+#: .\local_dateformat.py:24
0
 msgid "ABBR_YEARMONTH"
0
 msgstr "M Y"
0
 
0
-#: .\local_dateformat.py:46
0
+#: .\local_dateformat.py:25
0
 msgid "NUM_YEARMONTH"
0
 msgstr "n/Y"
0
 
0
-#: .\local_dateformat.py:48
0
+#: .\local_dateformat.py:27
0
 msgid "FULL_MONTHDAY"
0
 msgstr "j {Fp}"
0
 
0
-#: .\local_dateformat.py:49
0
+#: .\local_dateformat.py:28
0
 msgid "ABBR_MONTHDAY"
0
 msgstr "j M"
0
 
0
-#: .\local_dateformat.py:50
0
+#: .\local_dateformat.py:29
0
 msgid "NUM_MONTHDAY"
0
 msgstr "j/n"
...
26
27
28
 
29
 
30
31
 
32
33
34
...
26
27
28
29
30
31
32
 
33
34
35
36
0
@@ -26,8 +26,10 @@ d {Fp} Y:
0
 ltime:"{FULL_TIME}"
0
 {{datenow|ltime:"{FULL_TIME}"}}
0
 <hr>
0
+Translations: <br>
0
 
0
+{{datenow|ldate:"\T\h\i\s \i\s: {_(MY_DATE)} - {FULL_DATE}"}}
0
 
0
-
0
+<hr>
0
 
0
 {% now "d F Y" %}
0
\ No newline at end of file

Comments

    No one has commented yet.