Skip to main content

traduki: SQLAlchemy internationalisation

The traduki package provides internationalisation helper classes for SQLAlchemy-based projects.

https://api.travis-ci.org/paylogic/traduki.png https://img.shields.io/pypi/v/traduki.svg https://coveralls.io/repos/paylogic/traduki/badge.png?branch=master

Installation

pip install traduki

Usage

traduki usage example:

from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

import traduki

def get_current_language():
    """Current language callback for our project."""
    return request.locale

def get_language_chain():
    """Language chain (fallback rule) callback for our project."""
    return {'*': request.locale}

i18n_attributes = traduki.initialize(Base, ['en', 'ru'], get_current_language, get_language_chain)

Session = sessionmaker(bind=engine)
sess = Session()

class MyModel(Base)

    title_id = i18n_attributes.i18n_column(nullable=False, unique=False)
    title = i18n_attributes.i18n_relation(title_id)
    """Title."""

my_object = MyModel()
my_object.title = {'en': 'English title', 'pt': 'Portugese title'}
sess.add(my_object)
sess.commit()

assert sess.refresh(my_object).title.get_dict() == {'en': 'English title', 'pt': 'Portugese title'}

Contact

If you have questions, bug reports, suggestions, etc. please create an issue on the GitHub project page.

License

This software is licensed under the MIT license

See License

© 2018 Paylogic International.

Changelog

1.3.3

  • Fix sqlalchemy 2.0 compatibility warning by using sqlalchemy.orm.Mapper instead of sqlalchemy.orm.mapper.

1.3.2

  • Fix a bug where the get_ordered_languages would mutate in place the list of configured languages.

1.3.1

  • Fix UnicodeDecodeError when installing this library on python 3 on some configurations.

1.3.0

  • Fix python 3 compatibility

  • Declare support for python 2.7, 3.5, 3.6, 3.7, 3.8

1.2.0

  • Do not use deprecated AttributeExtension, use Attribute Events instead.

1.1.0

  • Use an OR operator for LIKE_OPS to find matches in all language columns.

1.0.1

  • Fix get_text_from_dict raising an exception when no language can be detected.

1.0.0

  • Initial public release

Metadata

Release files for traduki 1.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for traduki 1.3.3
File Size Uploaded Provenance Actions
traduki-1.3.3.tar.gz 7.9 kB Without provenance Details for traduki-1.3.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for traduki 1.3.3
File Interpreter ABI Platform Actions
traduki-1.3.3-py2.py3-none-any.whl Python 2, Python 3 none any Details for traduki-1.3.3-py2.py3-none-any.whl

Total release size: 16.0 kB

Release files / traduki-1.3.3.tar.gz

Download URL traduki-1.3.3.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
25937b30d78e6a68e0065215e3742da1d6a9e454cc19e9382d33871fbbf81057
BLAKE2b-256 checksum
How to use checksums
af0f8b0cf6d9b67e789bfab7a0e38e6a86a7910011f692cb0dbfef9fbcba81d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / traduki-1.3.3-py2.py3-none-any.whl

Download URL traduki-1.3.3-py2.py3-none-any.whl
Size 8.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
627500e4a24517b02ef6e4e4874c4f5616c1eda31a5b3cb60e1df0a2ca2222c5
BLAKE2b-256 checksum
How to use checksums
53c77211917638872a90f7e642916a105a8db0638beb00d34a88e6ec7a1edd6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Security for traduki 1.3.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page