Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.1, 2.1.1, and 2.1.2

Merge with stable

Changeset 0d5e347012e8

Parents 5a8c15e64db4

Parents 9f9c5eb5cd35

by Steve Borho

Changes to 4 files · Browse files at 0d5e347012e8 Showing diff from parent 5a8c15e64db4 9f9c5eb5cd35 Diff from another changeset...

Change 1 of 1 Show Entire File i18n/​msgfmt.py Stacked
 
164
165
166
167
 
 
 
168
169
170
 
 
 
 
 
 
 
 
 
 
171
172
173
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
176
177
 
164
165
166
 
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
 
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
@@ -164,14 +164,39 @@
  l = l[7:]   msgctxt = ''   # Now we are in a msgid section, output previous section - elif l.startswith('msgid'): + elif l.startswith('msgid') and not l.startswith('msgid_plural'): + if section == STR: + add(msgid, msgstr, fuzzy)   section = ID   l = l[5:]   msgid = msgstr = '' + is_plural = False + # This is a message with plural forms + elif l.startswith('msgid_plural'): + if section != ID: + print >> sys.stderr, 'msgid_plural not preceeded by msgid on %s:%d' %\ + (infile, lno) + sys.exit(1) + l = l[12:] + msgid += '\0' # separator of singular and plural + is_plural = True   # Now we are in a msgstr section   elif l.startswith('msgstr'):   section = STR - l = l[6:] + if l.startswith('msgstr['): + if not is_plural: + print >> sys.stderr, 'plural without msgid_plural on %s:%d' %\ + (infile, lno) + sys.exit(1) + l = l.split(']', 1)[1] + if msgstr: + msgstr += '\0' # Separator of the various plural forms + else: + if is_plural: + print >> sys.stderr, 'indexed msgstr required for plural on %s:%d' %\ + (infile, lno) + sys.exit(1) + l = l[6:]   # Skip empty lines   l = l.strip()   if not l:
 
155
156
157
158
 
159
160
161
 
155
156
157
 
158
159
160
161
@@ -155,7 +155,7 @@
  elif item == 'age':   date = ctx.date()   if date: - return hglib.age(date) + return hglib.age(date).decode('utf-8')   return None   elif item == 'rawbranch':   return ctx.branch() or None
 
108
109
110
111
 
112
113
114
 
108
109
110
 
111
112
113
114
@@ -108,7 +108,7 @@
  'Tags': self.gettags,   'Branch': self.getbranch,   'Filename': lambda ctx, gnode: gnode.extra[0], - 'Age': lambda ctx, gnode: hglib.age(ctx.date()), + 'Age': lambda ctx, gnode: hglib.age(ctx.date()).decode('utf-8'),   'LocalTime':lambda ctx, gnode: hglib.displaytime(ctx.date()),   'UTCTime': lambda ctx, gnode: hglib.utctime(ctx.date()),   'Changes': self.getchanges,
 
25
26
27
 
28
29
30
 
275
276
277
278
279
280
281
 
476
477
478
 
 
 
 
 
 
 
 
479
480
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
481
482
483
 
25
26
27
28
29
30
31
 
276
277
278
 
279
280
281
 
476
477
478
479
480
481
482
483
484
485
486
487
 
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
@@ -25,6 +25,7 @@
   from tortoisehg.util import paths  from tortoisehg.util.hgversion import hgversion +from tortoisehg.util.i18n import _, ngettext    def tounicode(s):   """ @@ -275,7 +276,6 @@
  Returns the dict {name: message} of extensions expected to be disabled.   message is 'utf-8'-encoded string.   """ - from tortoisehg.util.i18n import _ # avoid cyclic dependency   exts = {}   if os.name != 'posix':   exts['inotify'] = _('inotify is not supported on this platform') @@ -476,8 +476,33 @@
 def utctime(date):   return time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(date[0]))   +agescales = [((lambda n: ngettext("%d year", "%d years", n)), 3600 * 24 * 365), + ((lambda n: ngettext("%d month", "%d months", n)), 3600 * 24 * 30), + ((lambda n: ngettext("%d week", "%d weeks", n)), 3600 * 24 * 7), + ((lambda n: ngettext("%d day", "%d days", n)), 3600 * 24), + ((lambda n: ngettext("%d hour", "%d hours", n)), 3600), + ((lambda n: ngettext("%d minute", "%d minutes", n)), 60), + ((lambda n: ngettext("%d second", "%d seconds", n)), 1)] +  def age(date): - return templatefilters.age(date) + '''turn a (timestamp, tzoff) tuple into an age string.''' + # This is i18n-ed version of mercurial.templatefilters.age(). + + now = time.time() + then = date[0] + if then > now: + return _('in the future') + + delta = int(now - then) + if delta == 0: + return _('now') + if delta > agescales[0][1] * 2: + return util.shortdate(date) + + for t, s in agescales: + n = delta // s + if n >= 2 or s == 1: + return _('%s ago') % (t(n) % n)    def username(user):   author = templatefilters.person(user)