From a4ed4e04d02bdeeec3d97118215876dcce52852a Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Fri, 22 Jan 2016 20:42:59 +0200 Subject: [PATCH] plural: DRY out `compile_zero` --- babel/plural.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/babel/plural.py b/babel/plural.py index 5cc7289b..f2e9f480 100644 --- a/babel/plural.py +++ b/babel/plural.py @@ -485,6 +485,9 @@ def _unary_compiler(tmpl): return lambda self, x: tmpl % self.compile(x) +compile_zero = lambda x: '0' + + class _Compiler(object): """The compilers are able to transform the expressions into multiple output formats. @@ -557,10 +560,10 @@ class _JavaScriptCompiler(_GettextCompiler): # XXX: presently javascript does not support any of the # fraction support and basically only deals with integers. compile_i = lambda x: 'parseInt(n, 10)' - compile_v = lambda x: '0' - compile_w = lambda x: '0' - compile_f = lambda x: '0' - compile_t = lambda x: '0' + compile_v = compile_zero + compile_w = compile_zero + compile_f = compile_zero + compile_t = compile_zero def compile_relation(self, method, expr, range_list): code = _GettextCompiler.compile_relation( -- 2.47.3