Open flosch opened 10 years ago
+1
+1 Honestly we have some crunches to solve this task, but I hope you have more beautiful solution.
Haven't thought any deeper about this issue yet; I appreciate any design suggestions or ideas for supporting a good internationalization in templates. Ideas welcome!
The most important functions are the tags "trans" and "blocktrans". It is very useful that Pongo2 could parse the templates and return the trans and blocktrans strings with the file name, row and column. This data can be used by another system in order to help the creation of the translation maps.
Are there any gettext or other sort of translation libraries out there in the Go world you guys know of? I prefer using the PO file format since there are already some nice tools out there for creating/managing translations (for example Poedit). Doing so would require me to write a translation library first (for PO files/gettext) and to use this library in pongo2 afterwards.
Would really suck to hard dependency on something like gettext, as I won't be using this for example and want to limit the number of dependencies I'm using. I like how light pongo2 is on dependencies, please bear this in mind :).
Absolutely. pongo2 only uses the stdlib; any tags/filters which require external dependencies are in pongo2-addons. If it turns out we need/use some sort of external 3rd-party-library (which is not developed by me) it won't go into pongo2, but in pongo2-i18n or something like that which then will be easy importable like pongo2-addons.
Any progress / best practice / example solutions for this issue?
Dear all, any progress of the i18n support?
{{ _("orig string") }}
in template file like Jinja2?{{ fn("orig string") }}
for translation? Is it possible and a good idea?No progress yet. I'm happy to discuss proposals and accept pull requests. You can pass the function through the context and call it from there.
Dear @flosch,
Thanks for the reply.
Maybe not the best solution, but want to share my idea:
{{ _(“text”) }}
. So that we can use tool like pybabel to extract strings from (pongo2) html files for translation in pot file format, then compile the pot file to “.mo” file. It should be better if pongo2 offers command line tool to extract/update pot file directly, this way we don't need to rely on Python + Babel.Any idea / comment?
Dear @flosch,
Any comment?
I just published an implementation of the 'trans'/'blocktrans'-tags that I've been using for a while in a private project.
It contains an implementation that uses 'gotext' under the hood, but can be used with other translators if needed.
The repo is here: https://github.com/yzzyx/pongo-trans The project in the _example-folder showcases how to use it with pongo2 in a webserver setting.
As a bonus, I've published a related repo to extract the strings used in tags in templates and updating the po-files that works in a very similar fashion to djangos 'makemessage'. It can be found here
(stub) i18n/i10n
Open questions:
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.