Closed vtrlx closed 9 years ago
Fixed the commits such that URL languages are now supported.
Thanks for the pull request! Unfortunately things still aren't running here.
When I try to compile the strings, I get the following message:
$ pybabel compile -d translations/
catalog 'translations/fr/LC_MESSAGES/messages.po' is marked as fuzzy, skipping
... and no output is created. Is this perhaps because both the POT and the PO file are missing the expected gettext header per https://www.gnu.org/software/gettext/manual/html_node/Header-Entry.html ? I think that stripping the header to avoid merge conflicts is, unfortunately, creating an invalid set of POT and PO.
My first runtime error with this new pull request is that the global variable "g" in line 178 of ris2web is not actually defined anywhere.
I can resolve that by adding "g" to the "from flask import ..." line, but that pollutes the main namespace with a very generic variable name; I'd prefer to just "import flask" and use "flask.g.get()" to keep its usage explicit and contained.
After fixing that, I get another error:
File "/home/dan/source/ris2sql/templates/home.html", line 6, in <module>
{{ _("The <em>Labour Studies Index</em> offers %s
File "/home/dan/venv/ris2web/lib/python3.4/site-packages/jinja2/ext.py", line 132, in _gettext_alias
return __context.call(__context.resolve('gettext'), *args, **kwargs)
TypeError: gettext() takes 2 positional arguments but 3 were given
It looks like the template should be structured more like the following, providing an explicit name for the variable that's being replaced. While we're at it, might as well switch from string formatting (%s) to integer formatting (%d):
{{ _("The <em>Labour Studies Index</em> offers %(num)d citations of journal articles, books, book chapters, theses, and other literature.", num=summary.total) }}
Another error is that the following code from line 179 is not valid:
if not session['lang']:
This will result in a KeyError exception, and should instead be:
if 'lang' not in session:
(Actually, is the session-related code even relevant anymore? Looks like a leftover from the cookie-based effort that should be cleaned up).
Once you get a working Python 3 environment and can actually run the code using a clean checkout of the ris2web master branch and a merge of your translation branch, then please reopen this pull request. Thanks!
Requesting again because the last pull broke.
Still fixes #4 tho