Hi Guilherme, 

well, maybe I should have explained what I'm trying to do in the original email. Fixing this mistake now. 

I have a tool called Wikinity. The tool takes data from Wikidata and displays items with no image uploaded. It became to be used by Czech Commons users in the preparation step for their photo trip. The source is awful, to say the most important parts from how its written:
Yeah, I know its awful (but working :D). I plan to rewrite it. As I already use Translatewiki, which generates locales in certain format, I want to keep it. The fornat is straightforward to me and not like gettext which I managed to understood, but I think this is more clear. Of course, you might not agree, that's my current point of view. 

My plan is to convert this into a simple Flask app, which should incorporate several backend CGI scripts written in Python into one file with much more clear structure. This Flask app should ofc do the same things like the current tool does. I know how to do everything from the function side. The only one thing I'm thinking about is the localization - more certainly, what way I should use to use locales in this format in a Flask app (more precisely, in its Jinja2 templates, I do not have anything to localize in the Python part). 

BTW, I tried to use Flask-Babel and I manged to have working localization. The only one thing I don't like is that it uses gettext, which I don't like and its not like "modify this json file and the locales will change automatically", but "modify this .po file, then compile it it and maybe it will work". 

Martin

út 18. 9. 2018 v 19:10 odesílatel Guilherme Gonçalves <guilherme.p.gonc@gmail.com> napsal:
Hi Martin,

I know of a few approaches, depending on the complexity of your tool:
  • You can get pretty far with having your strings in, say, JSON files that you load and format yourself in code based on placeholders.
  • The Python standard library has a built-in gettext module if you prefer a more standard format.
  • For a more comprehensive solution that adds date formatting, I heard good things about Flask-Babel, but never used it myself.
Whichever way you choose, I'd definitely recommend managing the translations through TranslateWiki, which you might already know about.

Em ter, 18 de set de 2018 às 15:14, Martin Urbanec <martin.urbanec@wikimedia.cz> escreveu:
Hi, 

I'm sometimes use Flask for my Toolforge tools. I'd like to localize them, ideally with messages directory in similar format like MediaWiki has in i18n directory. 

I know about Intuition for PHP, does anybody know about similar thing for Flask application? 

Best,
Martin
_______________________________________________
Wikimedia Cloud Services mailing list
Cloud@lists.wikimedia.org (formerly labs-l@lists.wikimedia.org)
https://lists.wikimedia.org/mailman/listinfo/cloud


--
Guilherme P. Gonçalves
_______________________________________________
Wikimedia Cloud Services mailing list
Cloud@lists.wikimedia.org (formerly labs-l@lists.wikimedia.org)
https://lists.wikimedia.org/mailman/listinfo/cloud