New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add translation system to pygeoapi #725
Conversation
edcf472
to
55d31d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start @pvgenuchten and happy to see that it was easy to put the translations in place!
For the links sections (as generated by api.py
) we should have a look how to properly build in the Babel/gettext stuff there, but it might be better to do this after the API refactor, don't you agree @tomkralidis?
translations = Translations.load('locale', [locale_]) | ||
env.install_gettext_translations(translations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might need to check how efficient this is (loading all translations each time when render_j2_template
is called). If the locale has not changed, there's no need to reload all translations. But perhaps Babel and/or install_gettext_translations
already has such a mechanism in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start @pvgenuchten and happy to see that it was easy to put the translations in place!
For the links sections (as generated byapi.py
) we should have a look how to properly build in the Babel/gettext stuff there, but it might be better to do this after the API refactor, don't you agree @tomkralidis?
+1
pygeoapi/util.py
Outdated
@@ -44,7 +44,8 @@ | |||
|
|||
import dateutil.parser | |||
# from babel.support import Translations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this line :)
locale/fr/LC_MESSAGES/messages.po
Outdated
|
||
#: pygeoapi/templates/landing_page.html:35 | ||
msgid "License" | ||
msgstr "License" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
License in French is spelled Licence
, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work here @pvgenuchten ! Minor comments. I would also add a sentence or two in https://docs.pygeoapi.io/en/latest/language.html
locale/readme.md
Outdated
@@ -0,0 +1,32 @@ | |||
# Howto set up language files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename file to locale/README.md
e17a13f
to
fdf9cd3
Compare
@tomkralidis is it okay to merge this (after rebase)? |
@GeoSander +1, let me know when rebased. |
just did a rebase |
commit 70edc3c Author: Tom Kralidis <tomkralidis@gmail.com> Date: Thu Aug 26 16:30:46 2021 -0400 update TinyDB q= support for multiple terms (geopython#765) commit 1ff9dfa Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 08:24:28 2021 -0400 update id field passing to HTML template (geopython#764) commit 6fb64e6 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 07:22:53 2021 -0400 fix JSON filter in HTML items/item templates (geopython#761) (geopython#763) commit 6dcd10b Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 06:34:39 2021 -0400 test for item prev and next links on item queries (geopython#752) (geopython#757) commit 7192012 Author: Alexandre Leroux <alexandreleroux@gmail.com> Date: Tue Aug 24 06:37:03 2021 -0400 updates to French translation (geopython#759) commit 995ab2f Author: paul van genuchten <paul.vangenuchten@geocat.net> Date: Mon Aug 23 02:42:10 2021 +0200 add translation system to pygeoapi (geopython#725) * adds translation keys to templates * adds translation keys to templates * suggestions from github pr 2 commit bc97ed4 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Sun Aug 22 08:28:56 2021 -0400 add geometry to queryables (geopython#755) commit 9d92090 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 18 15:28:55 2021 -0400 update OAProc execute handling (geopython#754) * fix OAProc default output to raw * control outputs list from api machinery * fix tests
commit 774ff49 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Sep 1 09:02:28 2021 -0400 update translations (geopython#760) (geopython#762) * update translations (geopython#760) * fix syntax * update translations * update docs * fix typos commit cf9bd22 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Tue Aug 31 10:11:31 2021 -0400 Update plugins.rst (geopython#770) commit 70edc3c Author: Tom Kralidis <tomkralidis@gmail.com> Date: Thu Aug 26 16:30:46 2021 -0400 update TinyDB q= support for multiple terms (geopython#765) commit 1ff9dfa Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 08:24:28 2021 -0400 update id field passing to HTML template (geopython#764) commit 6fb64e6 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 07:22:53 2021 -0400 fix JSON filter in HTML items/item templates (geopython#761) (geopython#763) commit 6dcd10b Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 06:34:39 2021 -0400 test for item prev and next links on item queries (geopython#752) (geopython#757) commit 7192012 Author: Alexandre Leroux <alexandreleroux@gmail.com> Date: Tue Aug 24 06:37:03 2021 -0400 updates to French translation (geopython#759) commit 995ab2f Author: paul van genuchten <paul.vangenuchten@geocat.net> Date: Mon Aug 23 02:42:10 2021 +0200 add translation system to pygeoapi (geopython#725) * adds translation keys to templates * adds translation keys to templates * suggestions from github pr 2 commit bc97ed4 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Sun Aug 22 08:28:56 2021 -0400 add geometry to queryables (geopython#755) commit 9d92090 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 18 15:28:55 2021 -0400 update OAProc execute handling (geopython#754) * fix OAProc default output to raw * control outputs list from api machinery * fix tests
* Update plugin.py for SPARQL * Create sparql.py * Update requirements-provider.txt * Add files via upload * Update requirements-provider.txt * Update api.py * Update plugin.py * Update plugin.py * Update plugin.py * Squashed commit of the following: commit 70edc3c Author: Tom Kralidis <tomkralidis@gmail.com> Date: Thu Aug 26 16:30:46 2021 -0400 update TinyDB q= support for multiple terms (geopython#765) commit 1ff9dfa Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 08:24:28 2021 -0400 update id field passing to HTML template (geopython#764) commit 6fb64e6 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 07:22:53 2021 -0400 fix JSON filter in HTML items/item templates (geopython#761) (geopython#763) commit 6dcd10b Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 06:34:39 2021 -0400 test for item prev and next links on item queries (geopython#752) (geopython#757) commit 7192012 Author: Alexandre Leroux <alexandreleroux@gmail.com> Date: Tue Aug 24 06:37:03 2021 -0400 updates to French translation (geopython#759) commit 995ab2f Author: paul van genuchten <paul.vangenuchten@geocat.net> Date: Mon Aug 23 02:42:10 2021 +0200 add translation system to pygeoapi (geopython#725) * adds translation keys to templates * adds translation keys to templates * suggestions from github pr 2 commit bc97ed4 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Sun Aug 22 08:28:56 2021 -0400 add geometry to queryables (geopython#755) commit 9d92090 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 18 15:28:55 2021 -0400 update OAProc execute handling (geopython#754) * fix OAProc default output to raw * control outputs list from api machinery * fix tests * Squashed commit of the following: commit 774ff49 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Sep 1 09:02:28 2021 -0400 update translations (geopython#760) (geopython#762) * update translations (geopython#760) * fix syntax * update translations * update docs * fix typos commit cf9bd22 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Tue Aug 31 10:11:31 2021 -0400 Update plugins.rst (geopython#770) commit 70edc3c Author: Tom Kralidis <tomkralidis@gmail.com> Date: Thu Aug 26 16:30:46 2021 -0400 update TinyDB q= support for multiple terms (geopython#765) commit 1ff9dfa Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 08:24:28 2021 -0400 update id field passing to HTML template (geopython#764) commit 6fb64e6 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 07:22:53 2021 -0400 fix JSON filter in HTML items/item templates (geopython#761) (geopython#763) commit 6dcd10b Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 06:34:39 2021 -0400 test for item prev and next links on item queries (geopython#752) (geopython#757) commit 7192012 Author: Alexandre Leroux <alexandreleroux@gmail.com> Date: Tue Aug 24 06:37:03 2021 -0400 updates to French translation (geopython#759) commit 995ab2f Author: paul van genuchten <paul.vangenuchten@geocat.net> Date: Mon Aug 23 02:42:10 2021 +0200 add translation system to pygeoapi (geopython#725) * adds translation keys to templates * adds translation keys to templates * suggestions from github pr 2 commit bc97ed4 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Sun Aug 22 08:28:56 2021 -0400 add geometry to queryables (geopython#755) commit 9d92090 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 18 15:28:55 2021 -0400 update OAProc execute handling (geopython#754) * fix OAProc default output to raw * control outputs list from api machinery * fix tests * Prepare for merge into internetofwater/pygeoapi
* Update plugin.py for SPARQL * Create sparql.py * Update requirements-provider.txt * Add files via upload * Update requirements-provider.txt * Update api.py * Update plugin.py * Update plugin.py * Update plugin.py * Squashed commit of the following: commit 70edc3c Author: Tom Kralidis <tomkralidis@gmail.com> Date: Thu Aug 26 16:30:46 2021 -0400 update TinyDB q= support for multiple terms (geopython#765) commit 1ff9dfa Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 08:24:28 2021 -0400 update id field passing to HTML template (geopython#764) commit 6fb64e6 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 07:22:53 2021 -0400 fix JSON filter in HTML items/item templates (geopython#761) (geopython#763) commit 6dcd10b Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 06:34:39 2021 -0400 test for item prev and next links on item queries (geopython#752) (geopython#757) commit 7192012 Author: Alexandre Leroux <alexandreleroux@gmail.com> Date: Tue Aug 24 06:37:03 2021 -0400 updates to French translation (geopython#759) commit 995ab2f Author: paul van genuchten <paul.vangenuchten@geocat.net> Date: Mon Aug 23 02:42:10 2021 +0200 add translation system to pygeoapi (geopython#725) * adds translation keys to templates * adds translation keys to templates * suggestions from github pr 2 commit bc97ed4 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Sun Aug 22 08:28:56 2021 -0400 add geometry to queryables (geopython#755) commit 9d92090 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 18 15:28:55 2021 -0400 update OAProc execute handling (geopython#754) * fix OAProc default output to raw * control outputs list from api machinery * fix tests * Squashed commit of the following: commit 774ff49 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Sep 1 09:02:28 2021 -0400 update translations (geopython#760) (geopython#762) * update translations (geopython#760) * fix syntax * update translations * update docs * fix typos commit cf9bd22 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Tue Aug 31 10:11:31 2021 -0400 Update plugins.rst (geopython#770) commit 70edc3c Author: Tom Kralidis <tomkralidis@gmail.com> Date: Thu Aug 26 16:30:46 2021 -0400 update TinyDB q= support for multiple terms (geopython#765) commit 1ff9dfa Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 08:24:28 2021 -0400 update id field passing to HTML template (geopython#764) commit 6fb64e6 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 07:22:53 2021 -0400 fix JSON filter in HTML items/item templates (geopython#761) (geopython#763) commit 6dcd10b Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 06:34:39 2021 -0400 test for item prev and next links on item queries (geopython#752) (geopython#757) commit 7192012 Author: Alexandre Leroux <alexandreleroux@gmail.com> Date: Tue Aug 24 06:37:03 2021 -0400 updates to French translation (geopython#759) commit 995ab2f Author: paul van genuchten <paul.vangenuchten@geocat.net> Date: Mon Aug 23 02:42:10 2021 +0200 add translation system to pygeoapi (geopython#725) * adds translation keys to templates * adds translation keys to templates * suggestions from github pr 2 commit bc97ed4 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Sun Aug 22 08:28:56 2021 -0400 add geometry to queryables (geopython#755) commit 9d92090 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 18 15:28:55 2021 -0400 update OAProc execute handling (geopython#754) * fix OAProc default output to raw * control outputs list from api machinery * fix tests * Prepare for merge into internetofwater/pygeoapi
* Update plugin.py for SPARQL * Create sparql.py * Update requirements-provider.txt * Add files via upload * Update requirements-provider.txt * Update api.py * Update plugin.py * Update plugin.py * Update plugin.py * Squashed commit of the following: commit 70edc3c Author: Tom Kralidis <tomkralidis@gmail.com> Date: Thu Aug 26 16:30:46 2021 -0400 update TinyDB q= support for multiple terms (geopython#765) commit 1ff9dfa Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 08:24:28 2021 -0400 update id field passing to HTML template (geopython#764) commit 6fb64e6 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 07:22:53 2021 -0400 fix JSON filter in HTML items/item templates (geopython#761) (geopython#763) commit 6dcd10b Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 06:34:39 2021 -0400 test for item prev and next links on item queries (geopython#752) (geopython#757) commit 7192012 Author: Alexandre Leroux <alexandreleroux@gmail.com> Date: Tue Aug 24 06:37:03 2021 -0400 updates to French translation (geopython#759) commit 995ab2f Author: paul van genuchten <paul.vangenuchten@geocat.net> Date: Mon Aug 23 02:42:10 2021 +0200 add translation system to pygeoapi (geopython#725) * adds translation keys to templates * adds translation keys to templates * suggestions from github pr 2 commit bc97ed4 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Sun Aug 22 08:28:56 2021 -0400 add geometry to queryables (geopython#755) commit 9d92090 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 18 15:28:55 2021 -0400 update OAProc execute handling (geopython#754) * fix OAProc default output to raw * control outputs list from api machinery * fix tests * Squashed commit of the following: commit 774ff49 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Sep 1 09:02:28 2021 -0400 update translations (geopython#760) (geopython#762) * update translations (geopython#760) * fix syntax * update translations * update docs * fix typos commit cf9bd22 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Tue Aug 31 10:11:31 2021 -0400 Update plugins.rst (geopython#770) commit 70edc3c Author: Tom Kralidis <tomkralidis@gmail.com> Date: Thu Aug 26 16:30:46 2021 -0400 update TinyDB q= support for multiple terms (geopython#765) commit 1ff9dfa Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 08:24:28 2021 -0400 update id field passing to HTML template (geopython#764) commit 6fb64e6 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 07:22:53 2021 -0400 fix JSON filter in HTML items/item templates (geopython#761) (geopython#763) commit 6dcd10b Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 25 06:34:39 2021 -0400 test for item prev and next links on item queries (geopython#752) (geopython#757) commit 7192012 Author: Alexandre Leroux <alexandreleroux@gmail.com> Date: Tue Aug 24 06:37:03 2021 -0400 updates to French translation (geopython#759) commit 995ab2f Author: paul van genuchten <paul.vangenuchten@geocat.net> Date: Mon Aug 23 02:42:10 2021 +0200 add translation system to pygeoapi (geopython#725) * adds translation keys to templates * adds translation keys to templates * suggestions from github pr 2 commit bc97ed4 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Sun Aug 22 08:28:56 2021 -0400 add geometry to queryables (geopython#755) commit 9d92090 Author: Tom Kralidis <tomkralidis@gmail.com> Date: Wed Aug 18 15:28:55 2021 -0400 update OAProc execute handling (geopython#754) * fix OAProc default output to raw * control outputs list from api machinery * fix tests * Prepare for merge into internetofwater/pygeoapi
this pr adds a translation system to pygeoapi, see locale/readme.md on how to set up
pybabel extract -F babel-mapping.ini -o locale/messages.pot ./
pybabel update -d locale -l fr -i locale/messages.pot
pybabel compile -d locale -l fr
Run pygeoapi and switch language to french ?lang=fr, notice some hardcoded strings translated.