Git Product home page Git Product logo

traduki's Introduction

traduki: SQLAlchemy internationalisation

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

https://api.travis-ci.org/paylogic/traduki.png 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.

traduki's People

Contributors

youtux avatar bubenkoff avatar spirosikmd avatar blaise-io avatar movermeyer avatar

Watchers

Òscar Vilaplana avatar Harro van der Klauw avatar Andrii Makhnach avatar Marco Buccini avatar Peter Odding avatar Bart Kroon avatar  avatar James Cloos avatar Moises Ribeiro Jr avatar Bohdan Leseiko avatar Oleg Pidsadnyi avatar  avatar  avatar Orestis Ioakeimidis avatar  avatar Paylogic Gatekeepers avatar  avatar Sean Murphy avatar Patrick Vogel avatar  avatar

Forkers

isabella232

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.