Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get translatable text from an external source into catalog

Possibly i am overlooking an obvious solution or thinking the wrong way...

I have a limited amount of text, words in a database, that I want to display translated to users in a flask/jinja/babel webapp. eg. "running" is a possible value of an "activity" column and that should be "laufen" for my german users.

Words in templates and code are extracted and put into the catalog, but how do i get additional words into the catalog? Is there a simple text file extractor?

The only thing i could think of is, just create a .py file and put lots of _('...') lines in them, but that feels just wrong... is it?

like image 443
Florian Avatar asked Jan 07 '12 07:01

Florian


1 Answers

I created a messages.txt with my "words" like gettext function calls:

_('cycling')
_('running')

and added it to my babel.cfg as python source:

[python: messages.txt]

plain, simple, stupid, but works.

like image 200
Florian Avatar answered Sep 22 '22 04:09

Florian