Listing translated locales in Flask-Babel
- From:
- LeafStorm
- Date:
- 2010-06-17 @ 20:27
I'm working on a pastebin application, and while I don't have the
infrastructure fully ready to be translated yet, I'm wondering how I can
get a list of languages that do actually have translations. (i.e.
something that will check the 'translations' folder for me and read the
languages there.) Right now, I'm considering either:
- Having a hardcoded list of AVAILABLE_LANGUAGES in the code
- Manually 'os.listdir'-ing the 'translations' folder and taking
anything that is a directory
The second one is a bit low-level and kludgy for my tastes, and the
first one would be a slight maintenance headache. Sadly, I can't find
out much from the Babel docs, so does anyone know of a function that can
do that? (Or, better yet, add said functionality to Flask-Babel?)
--
Regards,
LeafStorm (http://www.leafstorm.us/)
Re: [flask] Listing translated locales in Flask-Babel
- From:
- Armin Ronacher
- Date:
- 2010-06-17 @ 21:30
Hi,
On 6/17/10 10:27 PM, LeafStorm wrote:
> - Having a hardcoded list of AVAILABLE_LANGUAGES in the code
Easy method, not that bad either because you can explicitly disable
translations that are not up-to-date.
> The second one is a bit low-level and kludgy for my tastes, and the
> first one would be a slight maintenance headache.
Babel itself does not handle gettext loading because you could load
translations from pretty much anywhere if you like (for example files in
/usr/local/translations or even a database).
However Flask-Babel does suggest a specific place for these so it makes
a lot of sense to add a method to list translations. I will add one.
Regards,
Armin