pombredanne / transdb Goto Github PK
View Code? Open in Web Editor NEWThis project forked from christian-schilling/transdb
License: GNU General Public License v3.0
This project forked from christian-schilling/transdb
License: GNU General Public License v3.0
OVERVIEW Django's field that stores labels in more than one language in database. INSTALLATION See Installation file in this directory. USAGE Create your models: from transdb import TransCharField, TransTextField [...] class MyModel(models.Model): [...] my_char_field = TransCharField(max_length=32) my_text_field = TransTextField() If you need to use in models in a more advanced way: from transdb import TransDbField from django.conf import settings from django.utils.translation import get_language from django.template.defaultfilters import slugify [...] class MyModel(models.Model): [...] my_char_field = TransCharField(max_length=32) my_text_field = TransTextField() slug_field = models.SlugField(editable=False) def __unicode__(self): return self.my_char_field def save(self): self.slug_field = slugify(self.my_char_field.get_in_language(settings.LANGUAGE_CODE)) super(MyModel, self).save() [...] Use as any other field in templates: [...] <p>{{ object.my_field }}</p> [...] And that's all, enjoy! MIGRATION Migration from non-translatable fields (and previous versions of TransDb) There is a wiki page that covers the migration procedure from non-translatable fields: http://code.google.com/p/transdb/wiki/MigrationProcedure TECHINCAL INFORMATION Internally data is stored in database as a string in dictionary format, for example: u'{u'en': u'This is english', u'ca': u'Això és català'}' Field uses a subclass of unicode class, adding a raw_data attribute to store the string with all languages, and implementing the get_in_language(language) method to allow access to a diferent language (diferent from the user's current language). KNOWN ISSUES See the list in http://code.google.com/p/transdb/issues/list
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.