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

taal-0.5.3.tar.gz (12.1 kB view details)

Uploaded Source

File details

Details for the file taal-0.5.3.tar.gz.

File metadata

  • Download URL: taal-0.5.3.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for taal-0.5.3.tar.gz
Algorithm Hash digest
SHA256 6e81a9d6c5a5e16b160a8f8102518ab8febba5d510ba4dad816d682a3b026c07
MD5 5c5b03d803d6c6c6f34921e788055d28
BLAKE2b-256 5d847921de6b4dce76591f0be5edb07272574c50779826c8e5b4c27b4d59a4cb

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