Lino Website

Documentation · Modules · adamo · Examples

Let's take the designation of a Currency as example for BabelFields in a multilingual environment.

Here is the code:

from lino.apps.ledger.ledger_demo import startup
from lino.apps.ledger.ledger_tables import Currency

sess=startup(langs="en fr")
qry=sess.query(Currency,"id name")
# show in default language:
# switch to FR and show again:

The Populator in sprl.demo inserts a few rows the Currencies table, specifying their description («name» field) in all known languages. The Populator is not visible in the code snippet, it is a part of demo.startup(). Take a look at the source code in module lino.apps.ledger.demo.

Some of these descriptions won't even be stored, because the populator runs in a certain Database which has a set of supported languages. This set can be specified at startup with the langs= parameter. The default for this field is "en", so usually only the English description is stored. But this time we specify two languages at startup.


id |name                                                                       
BEF|Belgian Francs                                                             
USD|US Dollar                                                                  
EEK|Estonian kroon                                                             

id |name                                                                       
BEF|Franc belge                                                                
USD|Dollar US                                                                  
EEK|Couronne estonienne                                                        

TODO: more remarks...

Refering articles:

Copyright 2001-2007 Luc Saffre.
Generated 2007-06-07 16:23:39