Thread: [pgadmin-hackers] Javascript translations
Hi Tira, I've been spending spare minutes starting to move the JS translations to use your new mechanism with an aim to minimising the Jinja rendering. Unfortunately, I found a couple of issues; can you look into them please? 1) String extraction no longer picks up strings in JS files. I guess we may need a custom extractor for babel? 2) The docs were never updated to reflect the changes, e.g. https://www.pgadmin.org/docs4/dev/translations.html Thanks! -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Thanks Dave.
1) String extraction no longer picks up strings in JS files. I guess
we may need a custom extractor for babel?
Yeah, that's a good point. I didn't think about that. I'll put that in my team's backlog coming up.
Here's a patch for the docs.
On Thu, Mar 23, 2017 at 8:37 AM, Dave Page <dpage@pgadmin.org> wrote:
Hi Tira,
I've been spending spare minutes starting to move the JS translations
to use your new mechanism with an aim to minimising the Jinja
rendering. Unfortunately, I found a couple of issues; can you look
into them please?
1) String extraction no longer picks up strings in JS files. I guess
we may need a custom extractor for babel?
2) The docs were never updated to reflect the changes, e.g.
https://www.pgadmin.org/docs4/dev/translations.html
Thanks!
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Attachment
Thanks, applied - though I changed it to "sources/translate" and "t" as the function name as that's what's been used so far. On Thu, Mar 23, 2017 at 5:58 PM, Atira Odhner <aodhner@pivotal.io> wrote: > Thanks Dave. > >> 1) String extraction no longer picks up strings in JS files. I guess >> we may need a custom extractor for babel? > > > Yeah, that's a good point. I didn't think about that. I'll put that in my > team's backlog coming up. > > Here's a patch for the docs. > > > On Thu, Mar 23, 2017 at 8:37 AM, Dave Page <dpage@pgadmin.org> wrote: >> >> Hi Tira, >> >> I've been spending spare minutes starting to move the JS translations >> to use your new mechanism with an aim to minimising the Jinja >> rendering. Unfortunately, I found a couple of issues; can you look >> into them please? >> >> 1) String extraction no longer picks up strings in JS files. I guess >> we may need a custom extractor for babel? >> >> 2) The docs were never updated to reflect the changes, e.g. >> https://www.pgadmin.org/docs4/dev/translations.html >> >> Thanks! >> >> -- >> Dave Page >> Blog: http://pgsnake.blogspot.com >> Twitter: @pgsnake >> >> EnterpriseDB UK: http://www.enterprisedb.com >> The Enterprise PostgreSQL Company > > -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Hi On Thu, Mar 23, 2017 at 1:58 PM, Atira Odhner <aodhner@pivotal.io> wrote: > Thanks Dave. > >> 1) String extraction no longer picks up strings in JS files. I guess >> we may need a custom extractor for babel? > > > Yeah, that's a good point. I didn't think about that. I'll put that in my > team's backlog coming up. Do you have an ETA for that? It's holding up one of our translators for whom I need to do an extract/merge/compile ASAP. -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company
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.
Thanks!
Joao and Sarah
Joao and Sarah
On Sun, Mar 26, 2017 at 8:33 PM, Dave Page <dpage@pgadmin.org> wrote:
Hi
On Thu, Mar 23, 2017 at 1:58 PM, Atira Odhner <aodhner@pivotal.io> wrote:
> Thanks Dave.
>
>> 1) String extraction no longer picks up strings in JS files. I guess
>> we may need a custom extractor for babel?
>
>
> Yeah, that's a good point. I didn't think about that. I'll put that in my
> team's backlog coming up.
Do you have an ETA for that? It's holding up one of our translators
for whom I need to do an extract/merge/compile ASAP.
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company--
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
Attachment
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
Hi Hackers,
Sorry about that, we attached the wrong patch file. Attaching the correct one
Thanks
Joao & Sarah
On Mon, Mar 27, 2017 at 1:58 PM, Dave Page <dpage@pgadmin.org> wrote:
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
Attachment
Hi On Mon, Mar 27, 2017 at 2:06 PM, Sarah McAlear <smcalear@pivotal.io> wrote: > Hi Hackers, > Sorry about that, we attached the wrong patch file. Attaching the correct > one It no longer errors, but it's still not working correctly - after running an extract, there are no strings from about.js or dashboard.js in the resulting template. I wonder if that's because they are still templates (and thus use the Jinja2 extractor), but are using client side translation? -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Good catch. We looked into this and it appears that the language interpretation that is defined in the babel.cfg only picks up one definition per file. Since we are in the process of moving things over to the new gettext() functionality, it looks like we will have to be more specific in the config file for now. Whichever path gets defined first is the interpreter that will be used for that file. We updated the config file and included dashboard.js and about.js more specifically. They are now being interpreted using Javascript. When we are done moving other files over we should be able to eliminate some of the configuration again. Here's a new patch that should fix this.
Thanks,
Matt & Sarah
On Mon, Mar 27, 2017 at 9:19 PM, Dave Page <dpage@pgadmin.org> wrote:
Hi
On Mon, Mar 27, 2017 at 2:06 PM, Sarah McAlear <smcalear@pivotal.io> wrote:
> Hi Hackers,
> Sorry about that, we attached the wrong patch file. Attaching the correct
> one
It no longer errors, but it's still not working correctly - after
running an extract, there are no strings from about.js or dashboard.js
in the resulting template. I wonder if that's because they are still
templates (and thus use the Jinja2 extractor), but are using client
side translation?
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Attachment
Hi Was that the correct patch? I don't see the changes you describe. On Tue, Mar 28, 2017 at 12:29 PM, Sarah McAlear <smcalear@pivotal.io> wrote: > Good catch. We looked into this and it appears that the language > interpretation that is defined in the babel.cfg only picks up one definition > per file. Since we are in the process of moving things over to the new > gettext() functionality, it looks like we will have to be more specific in > the config file for now. Whichever path gets defined first is the > interpreter that will be used for that file. We updated the config file and > included dashboard.js and about.js more specifically. They are now being > interpreted using Javascript. When we are done moving other files over we > should be able to eliminate some of the configuration again. Here's a new > patch that should fix this. > > Thanks, > Matt & Sarah > > > > On Mon, Mar 27, 2017 at 9:19 PM, Dave Page <dpage@pgadmin.org> wrote: >> >> Hi >> >> On Mon, Mar 27, 2017 at 2:06 PM, Sarah McAlear <smcalear@pivotal.io> >> wrote: >> > Hi Hackers, >> > Sorry about that, we attached the wrong patch file. Attaching the >> > correct >> > one >> >> It no longer errors, but it's still not working correctly - after >> running an extract, there are no strings from about.js or dashboard.js >> in the resulting template. I wonder if that's because they are still >> templates (and thus use the Jinja2 extractor), but are using client >> side translation? >> >> -- >> Dave Page >> Blog: http://pgsnake.blogspot.com >> Twitter: @pgsnake >> >> EnterpriseDB UK: http://www.enterprisedb.com >> The Enterprise PostgreSQL Company > > -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company
There should be 2 additional lines in the babel.cfg file. We can see them when we download the patch from the email. The additional lines are
+[javascript: **/templates/about/**.js]
+[javascript: **/templates/dashboard/**.js]
Thanks!
On Tue, Mar 28, 2017 at 1:56 PM, Dave Page <dpage@pgadmin.org> wrote:
Hi
Was that the correct patch? I don't see the changes you describe.
On Tue, Mar 28, 2017 at 12:29 PM, Sarah McAlear <smcalear@pivotal.io> wrote:
> Good catch. We looked into this and it appears that the language
> interpretation that is defined in the babel.cfg only picks up one definition
> per file. Since we are in the process of moving things over to the new
> gettext() functionality, it looks like we will have to be more specific in
> the config file for now. Whichever path gets defined first is the
> interpreter that will be used for that file. We updated the config file and
> included dashboard.js and about.js more specifically. They are now being
> interpreted using Javascript. When we are done moving other files over we
> should be able to eliminate some of the configuration again. Here's a new
> patch that should fix this.
>
> Thanks,
> Matt & Sarah
>
>
>
> On Mon, Mar 27, 2017 at 9:19 PM, Dave Page <dpage@pgadmin.org> wrote:
>>
>> Hi
>>
>> On Mon, Mar 27, 2017 at 2:06 PM, Sarah McAlear <smcalear@pivotal.io>
>> wrote:
>> > Hi Hackers,
>> > Sorry about that, we attached the wrong patch file. Attaching the
>> > correct
>> > one
>>
>> It no longer errors, but it's still not working correctly - after
>> running an extract, there are no strings from about.js or dashboard.js
>> in the resulting template. I wonder if that's because they are still
>> templates (and thus use the Jinja2 extractor), but are using client
>> side translation?
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>
>
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
On Tue, Mar 28, 2017 at 2:04 PM, Sarah McAlear <smcalear@pivotal.io> wrote: > There should be 2 additional lines in the babel.cfg file. We can see them > when we download the patch from the email. The additional lines are > > +[javascript: **/templates/about/**.js] > +[javascript: **/templates/dashboard/**.js] > > Thanks! Sorry, now it's my turn to be working with the wrong patch :-( Patch committed. Thanks! -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company