{"id":8113,"library":"django-rosetta","title":"Django Rosetta","description":"django-rosetta is a Django application designed to simplify the translation process for Django projects. It works by providing a web-based interface to edit gettext `.po` files, without requiring any database models or creating tables. The library is actively maintained, with recent updates in version 0.10.3 adding support for Django 6.0 and modernizing its JavaScript codebase by dropping jQuery. It also features integration with various AI translation services like DeepL and OpenAI for translation suggestions.","status":"active","version":"0.10.3","language":"en","source_language":"en","source_url":"https://github.com/mbi/django-rosetta","tags":["django","i18n","translation","admin","localization"],"install":[{"cmd":"pip install django-rosetta","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Core dependency for a Django application. Specific versions are required by rosetta versions.","package":"Django","optional":false},{"reason":"Required for OpenAI translation suggestions if ROSETTA_ENABLE_TRANSLATION_SUGGESTIONS is True and OpenAI API is configured.","package":"openai","optional":true},{"reason":"Required for Google Translation API suggestions if configured.","package":"google-cloud-translate","optional":true}],"imports":[{"note":"Add 'rosetta' to your INSTALLED_APPS list to enable the application.","symbol":"'rosetta'","correct":"# settings.py\nINSTALLED_APPS = [\n    # ...\n    'rosetta',\n]"},{"note":"Modern Django uses `path` or `re_path` from `django.urls`. The `patterns` function was deprecated and removed in Django 2.0.","wrong":"from django.conf.urls import patterns, url, include\nurlpatterns = patterns('',\n    url(r'^rosetta/', include('rosetta.urls')),\n)","symbol":"include('rosetta.urls')","correct":"# urls.py\nfrom django.urls import include, path\n\nurlpatterns = [\n    # ...\n    path('rosetta/', include('rosetta.urls')),\n]"}],"quickstart":{"code":"import os\n\n# settings.py\nINSTALLED_APPS = [\n    # ... default Django apps\n    'rosetta',\n    'django.contrib.admin', # Rosetta often accessed via admin\n]\n\n# Example for translation suggestions\nROSETTA_ENABLE_TRANSLATION_SUGGESTIONS = True\n\n# Configure DeepL or OpenAI if desired\n# DEEPL_AUTH_KEY = os.environ.get('DEEPL_AUTH_KEY', '')\n# OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY', '')\n# OPENAI_BASE_URL = os.environ.get('OPENAI_BASE_URL', '') # for self-hosted LLM\n\n# urls.py (in your project's main urls.py)\nfrom django.contrib import admin\nfrom django.urls import include, path\n\nurlpatterns = [\n    path('admin/', admin.site.urls),\n    path('rosetta/', include('rosetta.urls')),\n]\n\n# After configuration and running makemessages:\n# python manage.py makemessages -l es\n# python manage.py compilemessages\n# Then, navigate to /rosetta/ in your browser.","lang":"python","description":"To quickly set up django-rosetta, first install it via pip. Then, add `'rosetta'` to your `INSTALLED_APPS` in `settings.py` and include `rosetta.urls` in your project's `urls.py`. Ensure your Django project is already configured for internationalization (i18n) by defining `LANGUAGES` and `LOCALE_PATHS`, and running `python manage.py makemessages` and `python manage.py compilemessages` to create and compile translation files."},"warnings":[{"fix":"Review and update any custom JavaScript that interacts with Rosetta's frontend to remove jQuery dependencies or adapt to the new vanilla JS implementation.","message":"As of version 0.10.2, django-rosetta has rewritten its `rosetta.js` to drop jQuery, modernizing its frontend. If your custom frontend JavaScript heavily relied on jQuery in the Rosetta interface, it might break.","severity":"breaking","affected_versions":"0.10.2+"},{"fix":"Check the official documentation or PyPI for the exact Django/Python version requirements for your django-rosetta version and upgrade your Django/Python environment if necessary.","message":"Django and Python version compatibility has been frequently updated. Version 0.10.0 and later require Django 4.2+ and Python 3.9+. Older versions (0.9.9) required Django 3.2+ and Python 3.8+. Ensure your environment meets the minimum requirements for your installed rosetta version.","severity":"breaking","affected_versions":"0.9.9+"},{"fix":"Configure a persistent cache backend (e.g., Memcached, Redis) in your Django settings and ensure `ROSETTA_STORAGE_CLASS` is set to `'rosetta.storage.CacheRosettaStorage'`. Avoid using `signed_cookies` with `SessionRosettaStorage` for large PO files.","message":"When running django-rosetta in a multi-process environment (e.g., Gunicorn, mod_wsgi) with Django's default `LocMemCache` as the cache backend, you may encounter issues with translation data not persisting between requests.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review your `Content-Security-Policy` headers and potentially add `nonce` attributes or specific `'self'` sources for styles and scripts if you encounter CSP violations after upgrading.","message":"Version 0.10.1 improved Content Security Policy (CSP) support by avoiding inline styles and server-side rendered stylesheets. If your project has a very strict CSP, you might need to adjust your CSP directives to allow Rosetta's assets, especially if you had custom overrides.","severity":"gotcha","affected_versions":"0.10.1+"},{"fix":"Set `DEEPL_AUTH_KEY`, `OPENAI_API_KEY`, or other relevant API keys in your `settings.py` (e.g., using `os.environ.get`) and ensure `ROSETTA_ENABLE_TRANSLATION_SUGGESTIONS` is `True`.","message":"Using translation suggestion APIs (DeepL, OpenAI, etc.) requires configuring API keys in your Django settings. These keys should be securely managed, ideally via environment variables, to avoid exposure.","severity":"gotcha","affected_versions":"0.10.1+"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Add `'rosetta'` to the `INSTALLED_APPS` list in `settings.py`:\n\n```python\nINSTALLED_APPS = [\n    # ... other apps\n    'rosetta',\n]\n```","cause":"The 'rosetta' app has not been added to the INSTALLED_APPS list in your Django project's settings.py file.","error":"django.core.exceptions.ImproperlyConfigured: 'rosetta' is not in your INSTALLED_APPS setting."},{"fix":"Add `path('rosetta/', include('rosetta.urls'))` to your project's `urlpatterns` in `urls.py`:\n\n```python\nfrom django.urls import include, path\n\nurlpatterns = [\n    # ... other url patterns\n    path('rosetta/', include('rosetta.urls')),\n]\n```","cause":"The `rosetta.urls` have not been included in your project's main `urls.py` file or are incorrectly included.","error":"NoReverseMatch at /rosetta/ 'rosetta' is not a registered namespace"},{"fix":"Run `python manage.py compilemessages` from your project root. If `ROSETTA_WSGI_AUTO_RELOAD` is enabled and your web server supports it, changes might apply immediately, but a server restart is often needed. Ensure `LOCALE_PATHS` is correctly configured in `settings.py`.","cause":"After editing `.po` files in Rosetta, the corresponding `.mo` (machine object) files, which Django uses for translations, have not been recompiled or the web server hasn't been restarted. This can also happen if `LOCALE_PATHS` is incorrect or `makemessages` wasn't run for the relevant strings.","error":"Translated strings do not appear on the website after editing in Rosetta."},{"fix":"Update any custom JavaScript that runs within the Rosetta interface to remove its dependency on jQuery or ensure a compatible jQuery version is explicitly loaded if absolutely necessary.","cause":"Your custom JavaScript or an older version of your frontend assets in the Rosetta interface is still trying to use jQuery, but django-rosetta versions 0.10.2 and later have removed jQuery from its core.","error":"Uncaught ReferenceError: jQuery is not defined in rosetta interface."}]}