Skip to main content

A Django app with utilites to assist in project-wide translation

Project description

django-db-translate is an app with utilites to assist in project-wide translation.

With django-db-translate, you can:

  1. Select fields from the database to include in .po files using makemessages

  2. Edit translations directly in the admin site

Note

This app is a work in progress and may break unexpectedly.

Quick start (Database Translations)

  1. Add “django_db_translate” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...,
        "django_db_translate",
    ]
  2. Add your project’s locale directory to your LOCALE_PATHS setting like this:

    LOCALE_PATHS = [
        BASE_DIR / 'locale'
    ]
  3. Run python manage.py migrate to create the models.

  4. Add a translatable_fields class attribute to any model with fields you want to be translatable:

    class MyModel(models.Model):
        translatable_fields = ('txt_field',)
        txt_field = models.CharField()
  5. Run python manage.py makemessages --all --include-db-strings to generate the .po files

Quick start (Admin Translation Editing)

  1. Follow steps 1-3 from Quick start (Database Translations)

  2. Include the custom admin site inplace of the standard admin site in your project’s URLconf:

    from django_db_translate import admin
    urlpatterns = [
        ..., # Your other URLs here
        path("admin/", admin.site.urls),
    ]
  3. Add “django_db_translate.middleware.DBTranslateAdminMiddleware” to your MIDDLEWARE setting after any other Locale manipulating middlewares:

    MIDDLEWARE = [
        ...,
        'django_db_translate.middleware.DBTranslateAdminMiddleware'
    ]
  4. Give the Dbtranslate | db translate permissions | Manage translations permission to any user that requires translation editing permissions

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_db_translate-0.2.5.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_db_translate-0.2.5-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file django_db_translate-0.2.5.tar.gz.

File metadata

  • Download URL: django_db_translate-0.2.5.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for django_db_translate-0.2.5.tar.gz
Algorithm Hash digest
SHA256 f53dcbb0aca8706ac9140b8e2c27de5010d1c9f02d89fcafb81478a2d1fcfa1d
MD5 12c9b2a5e8c0c04e786d9a62c41e6fd6
BLAKE2b-256 08444bc64dc373efd652df45bd774fe4df4a9432f7320fdf8bc51fb10d501a6d

See more details on using hashes here.

File details

Details for the file django_db_translate-0.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for django_db_translate-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4355e61f6f2e37bbce6f9ba16c07be78b32408552ac38808f59e6f2c48d15368
MD5 569ce5600a21acf340d6dcf5d70d2907
BLAKE2b-256 963e2b6d1112b8e30c1fc9c3e74f79aa5f75ade62ae8c382bdfbe06c50fbde98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page