========
Django's field that stores labels in more than one language in database.
Just working on newforms-admin branch.
Installing and using
====================
Installation Download, unpack and copy files to ${PYTHON_PATH}/site-packages/transdb (or anywhere else if you know what you're doing)
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!
Serialization
==============
Due to technical reasons, serialization on models with TransDb fields has some specific restrictions.
Django comes with two serialization formats, xml and json.
TransDb requires two diferent methods when serializing, one that serializes information for all languages (for example for saving data as fixture). Other method should just return the current language (serialization for ajax processing).
Probably will change in the future, but now TransDb applies a method depending on the format, so
Use xml format for including all languages in serialization objects (and use TransDb serializer, see below).
User json format for returning just the current language in serialization objects.
For using TransDb serializer add next lines to your settings.py file:
SERIALIZATION_MODULES = {
'xml': 'transdb.xml_serializer',
}
Migration from non-translatable fields (and previous versions of TransDb)
========================================================================
There is a wiki page MigrationProcedure http://code.google.com/p/transdb/wiki/MigrationProcedure that covers this subject.
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'Other lang .. '}'
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
Metadata
Release files for transdb 0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| transdb-0.9.tar.gz | 5.7 kB | Without provenance | Details for transdb-0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| transdb-0.9-py2.5.egg | Legacy Egg format | - | - | Details for transdb-0.9-py2.5.egg |
Total release size: 18.3 kB
Release files / transdb-0.9.tar.gz
| Download URL | transdb-0.9.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c44534f5cfe1889a062c3fe4ba457f91cbf0e1a95eabc2fd92d71a2958b2ef08
|
|
BLAKE2b-256 checksum How to use checksums |
ccd4ed2a6b0d1c404a1d89847b23127555137ec765d41a92568bd9730157ee39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / transdb-0.9-py2.5.egg
| Download URL | transdb-0.9-py2.5.egg |
|---|---|
| Size | 12.6 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
894a1590b86e1074807ee19ac1c62f645702389a380ae74b58f37326fdeb80fc
|
|
BLAKE2b-256 checksum How to use checksums |
a2ea3daf54bd4f84e4da2a54fab3c41d25489b612c2728fe1447b677b2ac787c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for transdb 0.9
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.