{"id":10349,"library":"weblate","title":"Weblate","description":"Weblate is a free and open-source web-based continuous localization system that tightly integrates with version control systems (Git, Mercurial, SVN, etc.). It helps streamline the translation workflow for software projects, documentation, and websites. The current stable version is 5.17, and it generally follows Django's release cadence, with frequent updates.","status":"active","version":"5.17","language":"en","source_language":"en","source_url":"https://github.com/WeblateOrg/weblate","tags":["localization","l10n","i18n","translation","django","devops","gettext","xliff"],"install":[{"cmd":"pip install 'weblate[all]' # For a full installation with all dependencies","lang":"bash","label":"Full installation"},{"cmd":"pip install weblate # For a minimal installation, dependencies will need to be added separately","lang":"bash","label":"Minimal installation"}],"dependencies":[{"reason":"Weblate is a Django application and requires a compatible Django version (>=4.2,<5.2 for Weblate 5.17).","package":"Django","optional":false},{"reason":"Used for background tasks and asynchronous operations.","package":"Celery","optional":false},{"reason":"This is a separate Python client library for interacting with Weblate's REST API. Not required for running Weblate itself, but essential for programmatic access from external scripts.","package":"weblate_api","optional":true}],"imports":[{"note":"Common import for defining custom translation checks within Weblate.","symbol":"BaseCheck","correct":"from weblate.checks.base import BaseCheck"},{"note":"Common import for defining custom add-ons to extend Weblate's functionality.","symbol":"BaseAddon","correct":"from weblate.addons.base import BaseAddon"},{"note":"The core translation entry model was moved/renamed. Direct access is often via 'TranslationEntry'.","wrong":"from weblate.trans.messages import Message","symbol":"messages","correct":"from weblate.trans.models import TranslationEntry as messages"}],"quickstart":{"code":"import os\nfrom weblate.checks.base import BaseCheck\nfrom weblate.checks.base import CheckResult, WARNING\n\n# This example defines a custom Weblate check.\n# To run it, you would add it to your Weblate configuration (settings.py).\n# It is not directly executable as a standalone script outside a Weblate instance.\n\nclass MyCustomLengthCheck(BaseCheck):\n    # Unique ID for the check\n    check_id = 'my-custom-length-check'\n    # Human-readable name\n    name = 'Too Long Translation Check'\n    # Description for the user interface\n    description = 'Checks if a translation exceeds a maximum allowed length.'\n    # Default parameters, configurable via Weblate UI\n    params = {'max_length': 50}\n\n    def check(self, check_context):\n        translation = check_context.translation\n        source = check_context.source_string\n\n        if translation and translation.text and source and source.text:\n            max_len = self.get_param('max_length')\n            if len(translation.text) > max_len:\n                yield CheckResult(\n                    start=0,\n                    end=len(translation.text),\n                    severity=WARNING,\n                    message=f'Translation is too long ({len(translation.text)} chars), max allowed is {max_len} chars.'\n                )\n\n# Example of how you *might* register it (typically done in settings.py):\n# WLB_CHECKS = {'my-custom-length-check': 'my_module.my_custom_check.MyCustomLengthCheck'}\n\nprint(\"Custom check 'MyCustomLengthCheck' defined. Register it in your Weblate settings.py to use it.\")","lang":"python","description":"This quickstart demonstrates how to define a custom translation check for Weblate. Weblate is a Django application, and its 'library' usage primarily involves extending its functionality (e.g., custom checks, add-ons) by importing its base classes. This code is not standalone runnable but serves as an example of an extension you would integrate into a running Weblate instance by configuring it in `settings.py`."},"warnings":[{"fix":"Upgrade your Python environment to 3.12+ before installing or upgrading Weblate 5.2+. Check Weblate's release notes for specific version compatibility.","message":"Weblate has strict Python version requirements. Version 5.17 (and generally 5.2+) requires Python 3.12 or newer. Older versions required Python 3.10/3.11. Ensure your environment matches.","severity":"breaking","affected_versions":"5.2.x onwards"},{"fix":"Always consult Weblate's official documentation and release notes for the required Django version for your specific Weblate release. For Weblate 5.17, Django >=4.2,<5.2 is required.","message":"Weblate's major versions are often tied to specific Django versions. Upgrading Weblate without ensuring Django compatibility can lead to `django.core.exceptions.ImproperlyConfigured` or migration failures.","severity":"breaking","affected_versions":"All major versions, especially 5.x"},{"fix":"Use `pip install weblate` to set up the Weblate server. Use `pip install weblate_api` in *separate* projects if you want to programmatically interact with a Weblate API. Do not try to import API client functionality directly from the `weblate` package.","message":"There are two distinct Python packages: `weblate` (the server application) and `weblate_api` (a client library for Weblate's API). Do not confuse them; `weblate` provides the server, while `weblate_api` is used by *other* Python applications to interact with a running Weblate instance.","severity":"gotcha","affected_versions":"All"},{"fix":"Always run `weblate migrate` (or `django-admin migrate` in a Weblate context) after upgrading Weblate, and always back up your database before performing major upgrades.","message":"Database migrations are critical for Weblate upgrades. Skipping them or running them incorrectly can corrupt your translation data.","severity":"gotcha","affected_versions":"All versions on upgrade"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Ensure you have installed Weblate: `pip install 'weblate[all]'` (recommended) or `pip install weblate`. If using a virtual environment, activate it first.","cause":"The `weblate` package is not installed in the current Python environment or the virtual environment is not activated.","error":"ModuleNotFoundError: No module named 'weblate'"},{"fix":"Ensure your database settings are correct in `settings.py` and run Weblate's migration command: `weblate migrate`. For fresh installations, ensure the database is initialized.","cause":"The Django database migrations have not been applied, or the database connection is misconfigured.","error":"django.db.utils.OperationalError: no such table: main.django_migrations"},{"fix":"Set a strong `SECRET_KEY` in your Weblate's `settings.py` or via the `WEBLATE_SECRET_KEY` environment variable. Generate a new, unique key for production environments.","cause":"The `SECRET_KEY` is a mandatory Django setting, crucial for security, and is missing from your Weblate configuration.","error":"django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty."},{"fix":"Upgrade the `weblate_api` client library to match or exceed the version of your Weblate server: `pip install --upgrade weblate_api`.","cause":"You are using an older version of the `weblate_api` client library that does not support features introduced in a newer Weblate server version.","error":"AttributeError: 'WeblateAPI' object has no attribute 'some_new_method' (or similar API client method missing)"}]}