Quellcode durchsuchen

Translate models

Camille Masset vor 9 Jahren
Ursprung
Commit
cbf36e6252
3 geänderte Dateien mit 266 neuen und 60 gelöschten Zeilen
  1. 44 50
      counter/models.py
  2. 109 5
      locale/en/LC_MESSAGES/django.po
  3. 113 5
      locale/fr/LC_MESSAGES/django.po

+ 44 - 50
counter/models.py

@@ -1,92 +1,86 @@
1
-from django.db import models
2 1
 from datetime import datetime
3
-from babel.dates import format_timedelta
2
+
4 3
 from django.contrib.auth.models import User
4
+from django.db import models
5
+from django.utils.translation import ugettext_lazy as _, get_language
5 6
 
6
-# Create your models here.
7
+import arrow
8
+from babel.dates import format_timedelta
7 9
 
8 10
 
9 11
 class Counter(models.Model):
10
-    name = models.CharField('nom', max_length=60)
11
-    email = models.EmailField('email', max_length=264,
12
-                              default='null@localhost')
13
-    trigramme = models.CharField('trigramme', max_length=3)
14
-    user = models.ForeignKey(User, blank=True, null=True,
15
-                             verbose_name='utilisateur associé')
16
-    email_notifications = models.BooleanField(
17
-        'notifications par email', default=False)
18
-    sort_by_score = models.BooleanField(
19
-        'trier par SeumScore™', default=True)
12
+    name = models.CharField(_('name'), max_length=60)
13
+    email = models.EmailField(_('email'), max_length=264, default='null@localhost')
14
+    trigramme = models.CharField(_('trigram'), max_length=3)
15
+    user = models.ForeignKey(User, blank=True, null=True, verbose_name=_('associated user'))
16
+    email_notifications = models.BooleanField(_('email notifications'), default=False)
17
+    sort_by_score = models.BooleanField(_('sort by SeumScore'), default=True)
20 18
 
21 19
     def __str__(self):
22
-        return '%s (%s)' % (self.trigramme, self.name)
20
+        return _('%(trigram)s (%(name)s)') % {'trigram': self.trigramme, 'name': self.name}
23 21
 
24 22
     class Meta:
25
-        verbose_name = 'compteur'
23
+        verbose_name = _('counter')
26 24
 
27 25
 
28 26
 class Reset(models.Model):
29
-    timestamp = models.DateTimeField('date et heure', auto_now_add=True)
30
-    reason = models.TextField('raison')
31
-    counter = models.ForeignKey('Counter', related_name='counter',
32
-                                verbose_name='victime')
33
-    who = models.ForeignKey('Counter', related_name='who',
34
-                            verbose_name='fouteur de seum',
35
-                            blank=True, null=True, default=None)
27
+    timestamp = models.DateTimeField(_('datetime'), auto_now_add=True)
28
+    reason = models.TextField(_('reason'))
29
+    counter = models.ForeignKey('Counter', related_name='counter', verbose_name=_('victim'))
30
+    who = models.ForeignKey('Counter', related_name='who', verbose_name=_('seum giver'), blank=True, null=True, default=None)
36 31
 
37 32
     def __str__(self):
38
-        if (self.who is None or
39
-                self.who.id == self.counter.id):
40
-            return '%s : %s (%s)' % (self.counter,
41
-                                     format_timedelta(
42
-                                         datetime.now() -
43
-                                         self.timestamp.replace(tzinfo=None),
44
-                                         locale='fr'), self.reason)
33
+        if self.who is None or self.who == self.counter:
34
+            return _('%(counter)s : %(datetime)s (%(reason)s)') % {
35
+                'counter': self.counter,
36
+                'datetime': arrow.Arrow.fromdatetime(self.timestamp).humanize(locale=(get_language() or 'en')), # dirty hack...
37
+                'reason': self.reason
38
+            }
45 39
         else:
46
-            return '%s à %s : %s (%s)' % (self.who, self.counter,
47
-                                          format_timedelta(
48
-                                              datetime.now() -
49
-                                              self.timestamp.replace(
50
-                                                  tzinfo=None),
51
-                                              locale='fr'), self.reason)
40
+            return '%(who)s to %(counter)s : %(datetime)s (%(reason)s)' % {
41
+                'who': self.who,
42
+                'counter': self.counter,
43
+                'datetime': arrow.Arrow.fromdatetime(self.timestamp).humanize(locale=(get_language() or 'en')),
44
+                'reason': self.reason
45
+            }
52 46
 
53 47
     class Meta:
54
-        verbose_name = 'remise à zéro'
55
-        verbose_name_plural = 'remises à zéro'
48
+        verbose_name = _('reset')
49
+        verbose_name_plural = _('resets')
56 50
 
57 51
 
58 52
 class Like(models.Model):
59
-    liker = models.ForeignKey('Counter', verbose_name='likeur', related_name='likes')
60
-    reset = models.ForeignKey('Reset', verbose_name='seum', related_name='likes')
61
-    timestamp = models.DateTimeField('date et heure', auto_now_add=True)
53
+    liker = models.ForeignKey('Counter', verbose_name=_('liker'), related_name='likes')
54
+    reset = models.ForeignKey('Reset', verbose_name=_('seum'), related_name='likes')
55
+    timestamp = models.DateTimeField(_('datetime'), auto_now_add=True)
62 56
 
63 57
     class Meta:
64
-        verbose_name = 'like'
65
-        verbose_name_plural = 'likes'
58
+        verbose_name = _('like')
59
+        verbose_name_plural = _('likes')
66 60
         unique_together = ('liker', 'reset')
67 61
 
68 62
     def __str__(self):
69
-        return '%s aime %s' % (self.liker, self.reset)
63
+        return _('%(liker)s likes %(reset)s') % {'liker': self.liker, 'reset': self.reset}
70 64
 
71 65
 
72 66
 class Keyword(models.Model):
73 67
     text = models.CharField('texte', max_length=128, unique=True)
74 68
 
75 69
     class Meta:
76
-        verbose_name = 'mot-clé'
77
-        verbose_name_plural = 'mots-clés'
70
+        verbose_name = _('keyword')
71
+        verbose_name_plural = _('keywords')
78 72
 
79 73
     def __str__(self):
80 74
         return '#%s' % (self.text)
81 75
 
82 76
 
83 77
 class Hashtag(models.Model):
84
-    keyword = models.ForeignKey('Keyword', verbose_name='hashtag', related_name='hashtags')
85
-    reset = models.ForeignKey('Reset', verbose_name='remise à zéro', related_name='hashtags')
78
+    keyword = models.ForeignKey('Keyword', verbose_name=_('hashtag'), related_name='hashtags')
79
+    reset = models.ForeignKey('Reset', verbose_name=_('reset'), related_name='hashtags')
86 80
 
87 81
     class Meta:
88
-        verbose_name = 'hashtag'
89
-        verbose_name_plural = 'hashtags'
82
+        verbose_name = _('hashtag')
83
+        verbose_name_plural = _('hashtags')
90 84
 
91 85
     def __str__(self):
92
-        return '%s pour %s' % (self.keyword, self.reset)
86
+        return _('%(keyword)s for %(who)s') % {'keyword': self.keyword, 'who': self.reset}

+ 109 - 5
locale/en/LC_MESSAGES/django.po

@@ -8,7 +8,7 @@ msgid ""
8 8
 msgstr ""
9 9
 "Project-Id-Version: PACKAGE VERSION\n"
10 10
 "Report-Msgid-Bugs-To: \n"
11
-"POT-Creation-Date: 2017-01-21 13:36+0100\n"
11
+"POT-Creation-Date: 2017-01-21 14:29+0100\n"
12 12
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13 13
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14 14
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,6 +17,110 @@ msgstr ""
17 17
 "Content-Type: text/plain; charset=UTF-8\n"
18 18
 "Content-Transfer-Encoding: 8bit\n"
19 19
 
20
+#: counter/models.py:12
21
+msgid "name"
22
+msgstr ""
23
+
24
+#: counter/models.py:13
25
+msgid "email"
26
+msgstr ""
27
+
28
+#: counter/models.py:14
29
+msgid "trigram"
30
+msgstr ""
31
+
32
+#: counter/models.py:15
33
+msgid "associated user"
34
+msgstr ""
35
+
36
+#: counter/models.py:16
37
+msgid "email notifications"
38
+msgstr ""
39
+
40
+#: counter/models.py:17
41
+msgid "sort by SeumScore"
42
+msgstr ""
43
+
44
+#: counter/models.py:20
45
+#, python-format
46
+msgid "%(trigram)s (%(name)s)"
47
+msgstr ""
48
+
49
+#: counter/models.py:23
50
+msgid "counter"
51
+msgstr ""
52
+
53
+#: counter/models.py:27 counter/models.py:55
54
+msgid "datetime"
55
+msgstr ""
56
+
57
+#: counter/models.py:28
58
+msgid "reason"
59
+msgstr ""
60
+
61
+#: counter/models.py:29
62
+msgid "victim"
63
+msgstr ""
64
+
65
+#: counter/models.py:30
66
+msgid "seum giver"
67
+msgstr ""
68
+
69
+#: counter/models.py:34
70
+#, python-format
71
+msgid "%(counter)s : %(datetime)s (%(reason)s)"
72
+msgstr ""
73
+
74
+#: counter/models.py:48 counter/models.py:79
75
+msgid "reset"
76
+msgstr ""
77
+
78
+#: counter/models.py:49
79
+msgid "resets"
80
+msgstr ""
81
+
82
+#: counter/models.py:53
83
+msgid "liker"
84
+msgstr ""
85
+
86
+#: counter/models.py:54
87
+msgid "seum"
88
+msgstr ""
89
+
90
+#: counter/models.py:58
91
+msgid "like"
92
+msgstr ""
93
+
94
+#: counter/models.py:59
95
+msgid "likes"
96
+msgstr ""
97
+
98
+#: counter/models.py:63
99
+#, python-format
100
+msgid "%(liker)s likes %(reset)s"
101
+msgstr ""
102
+
103
+#: counter/models.py:70
104
+msgid "keyword"
105
+msgstr ""
106
+
107
+#: counter/models.py:71
108
+msgid "keywords"
109
+msgstr ""
110
+
111
+#: counter/models.py:78 counter/models.py:82
112
+msgid "hashtag"
113
+msgstr ""
114
+
115
+#: counter/models.py:83
116
+msgid "hashtags"
117
+msgstr ""
118
+
119
+#: counter/models.py:86
120
+#, python-format
121
+msgid "%(keyword)s for %(who)s"
122
+msgstr ""
123
+
20 124
 #: counter/templates/hashtagTemplate.html:20
21 125
 msgid "Seums containing"
22 126
 msgstr ""
@@ -45,10 +149,10 @@ msgstr ""
45 149
 msgid "Back to counters list"
46 150
 msgstr ""
47 151
 
48
-#: seum/settings.py:110
49
-msgid "French"
50
-msgstr ""
51
-
52 152
 #: seum/settings.py:111
53 153
 msgid "English"
54 154
 msgstr ""
155
+
156
+#: seum/settings.py:112
157
+msgid "French"
158
+msgstr ""

+ 113 - 5
locale/fr/LC_MESSAGES/django.po

@@ -8,7 +8,7 @@ msgid ""
8 8
 msgstr ""
9 9
 "Project-Id-Version: PACKAGE VERSION\n"
10 10
 "Report-Msgid-Bugs-To: \n"
11
-"POT-Creation-Date: 2017-01-21 13:36+0100\n"
11
+"POT-Creation-Date: 2017-01-21 14:29+0100\n"
12 12
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13 13
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14 14
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -18,6 +18,114 @@ msgstr ""
18 18
 "Content-Transfer-Encoding: 8bit\n"
19 19
 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
20 20
 
21
+#: counter/models.py:12
22
+msgid "name"
23
+msgstr "nom"
24
+
25
+#: counter/models.py:13
26
+msgid "email"
27
+msgstr "email"
28
+
29
+#: counter/models.py:14
30
+msgid "trigram"
31
+msgstr "trigramme"
32
+
33
+#: counter/models.py:15
34
+msgid "associated user"
35
+msgstr "utilisateur associé"
36
+
37
+#: counter/models.py:16
38
+msgid "email notifications"
39
+msgstr "notifications par email"
40
+
41
+#: counter/models.py:17
42
+msgid "sort by SeumScore"
43
+msgstr "trier par SeumScore"
44
+
45
+#: counter/models.py:20
46
+#, python-format
47
+msgid "%(trigram)s (%(name)s)"
48
+msgstr "%(trigram)s (%(name)s)"
49
+
50
+#: counter/models.py:23
51
+msgid "counter"
52
+msgstr "compteur"
53
+
54
+#: counter/models.py:27 counter/models.py:55
55
+msgid "datetime"
56
+msgstr "date et heure"
57
+
58
+#: counter/models.py:28
59
+msgid "reason"
60
+msgstr "raison"
61
+
62
+#: counter/models.py:29
63
+#, fuzzy
64
+#| msgid "Victim"
65
+msgid "victim"
66
+msgstr "victime"
67
+
68
+#: counter/models.py:30
69
+#, fuzzy
70
+#| msgid "Seum giver"
71
+msgid "seum giver"
72
+msgstr "fouteur de seum"
73
+
74
+#: counter/models.py:34
75
+#, python-format
76
+msgid "%(counter)s : %(datetime)s (%(reason)s)"
77
+msgstr "%(counter)s : %(datetime)s (%(reason)s)"
78
+
79
+#: counter/models.py:48 counter/models.py:79
80
+msgid "reset"
81
+msgstr "remise à zéro"
82
+
83
+#: counter/models.py:49
84
+msgid "resets"
85
+msgstr "remises à zéro"
86
+
87
+#: counter/models.py:53
88
+msgid "liker"
89
+msgstr "likeur"
90
+
91
+#: counter/models.py:54
92
+msgid "seum"
93
+msgstr "seum"
94
+
95
+#: counter/models.py:58
96
+msgid "like"
97
+msgstr "like"
98
+
99
+#: counter/models.py:59
100
+msgid "likes"
101
+msgstr "likes"
102
+
103
+#: counter/models.py:63
104
+#, python-format
105
+msgid "%(liker)s likes %(reset)s"
106
+msgstr "%(liker)s aime %(reset)s"
107
+
108
+#: counter/models.py:70
109
+msgid "keyword"
110
+msgstr "mot-clé"
111
+
112
+#: counter/models.py:71
113
+msgid "keywords"
114
+msgstr "mots-clés"
115
+
116
+#: counter/models.py:78 counter/models.py:82
117
+msgid "hashtag"
118
+msgstr "hashtag"
119
+
120
+#: counter/models.py:83
121
+msgid "hashtags"
122
+msgstr "hashtags"
123
+
124
+#: counter/models.py:86
125
+#, python-format
126
+msgid "%(keyword)s for %(who)s"
127
+msgstr "%(keyword)s pour %(who)s"
128
+
21 129
 #: counter/templates/hashtagTemplate.html:20
22 130
 msgid "Seums containing"
23 131
 msgstr "Liste des seums contenant"
@@ -46,13 +154,13 @@ msgstr "Nombre de likes"
46 154
 msgid "Back to counters list"
47 155
 msgstr "Retour à la liste des compteurs"
48 156
 
49
-#: seum/settings.py:110
50
-msgid "French"
51
-msgstr "Français"
52
-
53 157
 #: seum/settings.py:111
54 158
 msgid "English"
55 159
 msgstr "Anglais"
56 160
 
161
+#: seum/settings.py:112
162
+msgid "French"
163
+msgstr "Français"
164
+
57 165
 #~ msgid "Seum"
58 166
 #~ msgstr "Seum"