Re: Javascript translations - Mailing list pgadmin-hackers

From Dave Page
Subject Re: Javascript translations
Date
Msg-id CA+OCxozd9bc2NqcF05-Xti4YQf1sFY0a=y4yUro1FaG9oxWRAg@mail.gmail.com
Whole thread Raw
In response to Re: Javascript translations  (Sarah McAlear <smcalear@pivotal.io>)
Responses Re: Javascript translations  (Sarah McAlear <smcalear@pivotal.io>)
List pgadmin-hackers
Hi

On Mon, Mar 27, 2017 at 11:33 AM, Sarah McAlear <smcalear@pivotal.io> wrote:
> Hi Hackers!
>
> We updated the documentation and included the ability to generate the
> messages.pot files again. We changed the file and function from translate.js
> to gettext.js to be consistent with Python and also to have it automatically
> picked up without having to add extensions to Pybabel. See patch attached.

This doesn't seem to work so well - message extraction now crashes on
various JS files, possibly because babel.cfg treats them as Python not
Javascript. For example:

extracting messages from
pgadmin/browser/static/vendor/aciTree/jquery.aciTree.core.js
(extensions="jinja2.ext.autoescape,jinja2.ext.with_")
Traceback (most recent call last):
  File "/Users/dpage/.virtualenvs/pgadmin4/bin/pybabel", line 11, in <module>
    sys.exit(main())
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/babel/messages/frontend.py",
line 1151, in main
    return CommandLineInterface().run(sys.argv)
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/babel/messages/frontend.py",
line 665, in run
    return getattr(self, cmdname)(args[1:])
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/babel/messages/frontend.py",
line 919, in extract
    for filename, lineno, message, comments, context in extracted:
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/babel/messages/extract.py",
line 163, in extract_from_dir
    strip_comment_tags):
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/babel/messages/extract.py",
line 190, in extract_from_file
    strip_comment_tags))
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/babel/messages/extract.py",
line 267, in extract
    for lineno, funcname, messages, comments in results:
  File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/babel/messages/extract.py",
line 359, in extract_python
    for tok, value, (lineno, _), _, _ in tokens:
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tokenize.py",
line 363, in generate_tokens
    raise TokenError, ("EOF in multi-line statement", (lnum, 0))
tokenize.TokenError: ('EOF in multi-line statement', (2545, 0))

The update should probably also ignore node_modules and static/vendor
directories.

Thanks.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgadmin-hackers by date:

Previous
From: Dave Page
Date:
Subject: pgAdmin 4 commit: Ensure client-side translations are correctlyextract
Next
From: Sarah McAlear
Date:
Subject: Re: Javascript translations