Skip to main content

SQLAlchemy internationalisation

Project description

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.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

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

traduki-1.3.2.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

traduki-1.3.2-py2.py3-none-any.whl (8.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file traduki-1.3.2.tar.gz.

File metadata

  • Download URL: traduki-1.3.2.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/2.7.16

File hashes

Hashes for traduki-1.3.2.tar.gz
Algorithm Hash digest
SHA256 b931dc1444df958939ad43e5ec27dc24820b02e8fbf3247e180d5a4da1265652
MD5 f9013623c655caf6ae1af24d731ab55f
BLAKE2b-256 ecf9d426f9c861d672fe3c9a401786fbb033a2ba81aae650c72087becee00ab5

See more details on using hashes here.

File details

Details for the file traduki-1.3.2-py2.py3-none-any.whl.

File metadata

  • Download URL: traduki-1.3.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/2.7.16

File hashes

Hashes for traduki-1.3.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f9ada30a15d1518f67163c6c999251aa1b470f8d53e36fb0c26a62c67ad05b6c
MD5 0f3a3b07b4b56b1d70bda56a582727bc
BLAKE2b-256 778fa8b76d5fc3ffe2e1b01a1b9ae03c0bcc66625129ee4be9d5b36da0b9e232

See more details on using hashes here.

Supported by

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