Revision: 178
Author:
esc...@gmail.com
Date: Mon Oct 15 01:55:12 2012
Log: Edited wiki page InstallationAndUsage through web user interface.
http://code.google.com/p/django-modeltranslation/source/detail?r=178
Modified:
/wiki/InstallationAndUsage.wiki
=======================================
--- /wiki/InstallationAndUsage.wiki Fri Oct 12 06:43:26 2012
+++ /wiki/InstallationAndUsage.wiki Mon Oct 15 01:55:12 2012
@@ -17,6 +17,7 @@
* Features
* Installation
+ * Setup
* Configure the project's `settings.py`
* Registering models and their fields for translation
* Changes automatically applied to the model class
@@ -31,6 +32,7 @@
* Inlines
* Using tabbed translation fields
* The `update_translation_fields` command
+ * The `sync_translation_fields` command
* Caveats
* Accessing translated fields outside views
* Related projects
@@ -51,12 +53,17 @@
= Installation =
-To install the application please follow these steps. Each step is
described in detail in the following sections:
+{{{
+pip install django-modeltranslation
+}}}
+
+= Setup =
+
+To setup the application please follow these steps. Each step is described
in detail in the following sections:
# Add the `modeltranslation` app to the `INSTALLED_APPS` variable of
your project's `settings.py`.
# Configure your `LANGUAGES` in `settings.py`.
# Create a `translation.py` in your app directory and register
`TranslationOptions` for every model you want to translate.
- # Configure the `MODELTRANSLATION_TRANSLATION_FILES` variable in your
`settings.py`.
# Sync the database using `manage.py syncdb` (note that this only
applies if the models registered in the `translations.py` did not have been
synced to the database before. If they did - read further down what to do
in that case.
@@ -104,7 +111,9 @@
*New in 0.4*
-In order to be able to import the `translation.py` registration files of
your apps, `MODELTRANSLATION_TRANSLATION_FILES` must be set to a value in
the form:
+Modeltranslation uses an autoregister feature similiar to the one in
Django's admin. The autoregistration process will look for a
`translation.py` file in the root directory of each application that is in
`INSTALLED_APPS`.
+
+A setting `MODELTRANSLATION_TRANSLATION_FILES` is provided to limit or
extend the modules that are taken into account. It uses the following
syntax:
{{{
('<APP1_MODULE>.translation',
@@ -135,7 +144,7 @@
== Registering models and their fields for translation ==
-The `modeltranslation` app can translate `CharField` and `TextField` based
fields of any model class. For each model to translate a translation option
class containg the fields to translate is registered with the
`modeltranslation` app.
+The `modeltranslation` app can translate `CharField` and `TextField` based
fields (as well as `FileField` and `ImageField` as of version 0.4) of any
model class. For each model to translate a translation option class
containing the fields to translate is registered with the
`modeltranslation` app.
Registering models and their fields for translation requires the following
steps:
@@ -156,11 +165,11 @@
text = models.TextField()
}}}
-In order to tell the `modeltranslation` app to translate the `title` and
`text` field, create a `translation.py` file in your project directory and
add the following:
+In order to tell the `modeltranslation` app to translate the `title` and
`text` field, create a `translation.py` file in your news app directory and
add the following:
{{{
from modeltranslation.translator import translator, TranslationOptions
-from some.news.models import News
+from news.models import News
class NewsTranslationOptions(TranslationOptions):
fields = ('title', 'text',)
@@ -168,7 +177,7 @@
translator.register(News, NewsTranslationOptions)
}}}
-Note that this does not require to change the `News` model in any way,
it's only imported. The `NewsTranslationOptions` derives from
`TranslationOptions` and provides the `fields` attribute. Finally the model
and it's translation options are registered at the `translator` object.
+Note that this does not require to change the `News` model in any way,
it's only imported. The `NewsTranslationOptions` derives from
`TranslationOptions` and provides the `fields` attribute. Finally the model
and its translation options are registered at the `translator` object.
At this point you are mostly done and the model classes registered for
translation will have been added some auto-magical fields. The next section
explains how things are working under the hood.
@@ -411,12 +420,12 @@
class NewsAdmin(TranslationAdmin):
class Media:
js = (
- '/static/modeltranslation/js/force_jquery.js',
+ 'modeltranslation/js/force_jquery.js',
'
http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js',
- '/static/modeltranslation/js/tabbed_translation_fields.js',
+ 'modeltranslation/js/tabbed_translation_fields.js',
)
css = {
- 'screen':
('/static/modeltranslation/css/tabbed_translation_fields.css',),
+ 'screen':
('modeltranslation/css/tabbed_translation_fields.css',),
}
}}}
@@ -438,6 +447,12 @@
All translated models (as specified in the project's `translation.py` will
be populated with initial data.
+= The `sync_translation_fields` command =
+
+*New in 0.4*
+
+TODO
+
= Caveats =
Consider the following example (assuming the default language is `de`):