Giter Site home page Giter Site logo

chubz / django-datatrans Goto Github PK

View Code? Open in Web Editor NEW

This project forked from larsc/django-datatrans

0.0 2.0 0.0 272 KB

Translate Django models without changing anything to existing applications and their underlying database.

License: Other

Python 100.00%

django-datatrans's Introduction

django-datatrans

Authors:

Important note when upgrading to version 0.1.2

The migration script adds a new unique index, like it was before. But this can fail because duplicates might exist in the database. The new unique index on the model KeyValue consists out of the following fields: ('language', 'content_type', 'field', 'object_id', 'digest')

You can make sure manually that you don't have duplicate entries in your database or you can use the following command to delete duplicates:

python manage.py deleteduplicates

It retains the oldest record and deletes the newest duplicates. It only works for mysql since it executes raw queries, this is way more faster that using the south api (it lasts for hours).

Features

  • Translate Django models without changing anything to existing applications and their underlying database.
  • Uses a registration approach.
  • All translations are stored in one extra lookup table. Existing database tables remain untouched.
  • Recovery and cleanup of obsolete translations.
  • Translation admin interface included (uses CSS from django admin).
  • Transparent model API (in 99% of all cases, nothing has to be changed to original code).
  • Infinite caching for all strings (based on id and hash)

How to use

  1. Add it to INSTALLED_APPS

  2. Syncdb

  3. Register models (example for FlatPage model):

    from datatrans.utils import register

    class FlatPageTranslation(object):

    fields = ('title', 'content')

    register(FlatPage, FlatPageTranslation)

  4. Include the datatrans.urls in your urlconf somewhere, and point your browser to it!

  5. Translate away!

Note: you can also search through your objects using translated query strings with the datatrans_filter on your manager. For example:

FlatPageTranslation.objects.datatrans_filter(title__icontains='zoek dit', language='nl')

will return a QuerySet containing those objects whose dutch title contains the string 'zoek dit'. Note that this filter API is not identical to Django's, read the docstring for more info.

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.