comparison mercurial/templater.py @ 21960:2896d450fec4 stable

templater: add i18n comments to error messages of newly added functions This patch adds i18n comments to error messages of newly added functions "startswith" (introduced by 4a445dc5abff) and "word" (by 8f23f8096606).
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Fri, 01 Aug 2014 02:14:24 +0900
parents 8f23f8096606
children 5678b0e3608f b6531d806de8
comparison
equal deleted inserted replaced
21959:dccbf52ffe9f 21960:2896d450fec4
466 src = stringify(_evalifliteral(args[2], context, mapping)) 466 src = stringify(_evalifliteral(args[2], context, mapping))
467 yield re.sub(pat, rpl, src) 467 yield re.sub(pat, rpl, src)
468 468
469 def startswith(context, mapping, args): 469 def startswith(context, mapping, args):
470 if len(args) != 2: 470 if len(args) != 2:
471 # i18n: "startswith" is a keyword
471 raise error.ParseError(_("startswith expects two arguments")) 472 raise error.ParseError(_("startswith expects two arguments"))
472 473
473 patn = stringify(args[0][0](context, mapping, args[0][1])) 474 patn = stringify(args[0][0](context, mapping, args[0][1]))
474 text = stringify(args[1][0](context, mapping, args[1][1])) 475 text = stringify(args[1][0](context, mapping, args[1][1]))
475 if text.startswith(patn): 476 if text.startswith(patn):
478 479
479 480
480 def word(context, mapping, args): 481 def word(context, mapping, args):
481 """return nth word from a string""" 482 """return nth word from a string"""
482 if not (2 <= len(args) <= 3): 483 if not (2 <= len(args) <= 3):
484 # i18n: "word" is a keyword
483 raise error.ParseError(_("word expects two or three arguments, got %d") 485 raise error.ParseError(_("word expects two or three arguments, got %d")
484 % len(args)) 486 % len(args))
485 487
486 num = int(stringify(args[0][0](context, mapping, args[0][1]))) 488 num = int(stringify(args[0][0](context, mapping, args[0][1])))
487 text = stringify(args[1][0](context, mapping, args[1][1])) 489 text = stringify(args[1][0](context, mapping, args[1][1]))