Skip to main content

Model translations

Project description

Taal

Taal is a framework for translating your data. It plugs in to e.g. SQLAlchemy or Kaiso, providing a TranslatableString field type and a mechanism for storing and retrieving content in multiple languages.

For use-cases where the most common interaction with the translated data is for reading, an application can be set up so that language context and translations are handled centrally, after which business logic can be written almost as it would for a single-language app.

Philosophy

Taal uses a two-phase process for managing translatable data. Upon retrieval, data is marked up as “requires translation”. Subsequently (typically higher up in the stack, e.g. in some middleware), information about which particular language we are interested in may be supplied to find the actual translation string.

Example use

class MyModel(Base):
    __tablename__ = "my_model"

    id = Column(Integer, primary_key=True)
    name = Column(TranslatableString())
>>> instance = session.query(MyModel).first()
>>> instance.name
<TranslatableString: (...)>

>>> translator = get_translator('en')
>>> translator.translate(instance.name)
"Spam"

Development

To make your life easier, create a setup.cfg file with a [pytest] section to define your database and neo4j connection strings:

$ cat setup.cfg
[pytest]
addopts= --neo4j_uri=http://... --db_uri=mysql://...

(Note that pytest gets upset if you indent the addopts line)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mthpower-taal-0.9.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

mthpower_taal-0.9.0-py2-none-any.whl (17.9 kB view details)

Uploaded Python 2

File details

Details for the file mthpower-taal-0.9.0.tar.gz.

File metadata

File hashes

Hashes for mthpower-taal-0.9.0.tar.gz
Algorithm Hash digest
SHA256 4b2f2adad3cbe28bd2147c4aa5a1b8f1abe843fcf8d377aa73b9b86aee684aa0
MD5 189ae2c50e55ce5fdad3632fa8b1d311
BLAKE2b-256 e61be8c24c41a3e4b848a298ebcd4ee9b220158ab9800c2ff6513b994e737c11

See more details on using hashes here.

File details

Details for the file mthpower_taal-0.9.0-py2-none-any.whl.

File metadata

File hashes

Hashes for mthpower_taal-0.9.0-py2-none-any.whl
Algorithm Hash digest
SHA256 7336c2f681e73edd61d631e0afd0bf46af5ffdc08888740ac796d1595a942ef4
MD5 2340a167c0d72fb2a5af160f8f852651
BLAKE2b-256 fe9097527b5f1d91616647411da050c544dc6695874857bd046f7da58cd004a3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page