Is it possible to translate the words in the database? I want to use the standard tools: python setup.py extract_messages and use file locale/fr/LC_MESSAGES/*.po for translate.
It is possible. Just pass the text returned from the database to a TranslationString.
You can use TranslationStringFactory(domain)
to build your string and pass it to a localizer. The problem you might have is extracting strings from database. I'm not sure how you can do it but you might be able to pass an extractor to extract messages from database.
The other way which might be a bit better is to create a dummy file with strings. Extract all to a file formatted like gettext.
You can add it to revision and the current message extractors will get the text like usual
edit
Since how things are stored in database is always pretty custom, there is no such tool as far as I can tell. But it should be easy to write.
It should look like this.
with open(registry.settings['db_locale_file'], 'w') as f:
for result in my_query_results:
f.writeline('_(u"%s")' % result.key_you_want)
That's a pretty simple example but it should be more complicated. You can make it a script using pyramid bootstrap and then call
your_script
python setup.py extract_messages
python setup.py update_catalog
????
python setup.py compile_catalog
????
#profit!