Mercurial > babel > old > mirror
changeset 407:b730d1d40942
Added support for string concatenation to javascript lexer. _("foo" + "bar") is now equivalent to _("foobar")
author | aronacher |
---|---|
date | Sun, 24 Aug 2008 14:36:18 +0000 |
parents | abe62ab2a889 |
children | b69105958843 |
files | babel/messages/extract.py |
diffstat | 1 files changed, 18 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/babel/messages/extract.py +++ b/babel/messages/extract.py @@ -454,6 +454,7 @@ messages = [] last_argument = None translator_comments = [] + concatenate_next = False encoding = options.get('encoding', 'utf-8') last_token = None call_stack = -1 @@ -513,19 +514,29 @@ [comment[1] for comment in translator_comments]) funcname = message_lineno = last_argument = None + concatenate_next = False translator_comments = [] messages = [] call_stack = -1 elif token.type == 'string': - last_argument = unquote_string(token.value) + new_value = unquote_string(token.value) + if concatenate_next: + last_argument = (last_argument or '') + new_value + concatenate_next = False + else: + last_argument = new_value - elif token.type == 'operator' and token.value == ',': - if last_argument is not None: - messages.append(last_argument) - last_argument = None - else: - messages.append(None) + elif token.type == 'operator': + if token.value == ',': + if last_argument is not None: + messages.append(last_argument) + last_argument = None + else: + messages.append(None) + concatenate_next = False + elif token.value == '+': + concatenate_next = True elif call_stack > 0 and token.type == 'operator' \ and token.value == ')':