Metadata-Version: 2.4
Name: django-altified
Version: 0.1.1
Summary: Django SDK for syncing model content with Altified translations.
Author: Altified
Classifier: Framework :: Django
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: Django>=4.2
Requires-Dist: requests>=2.31

# django-altified

Django SDK for syncing configured model fields to Altified and reading translated values from Django cache.

## Install

```bash
pip install django-altified
```

## Configure

```python
INSTALLED_APPS = [
    ...,
    "django_altified",
]

ALTIFIED_API_KEY = "altified_..."
ALTIFIED_API_URL = "https://api.altified.com/api/v1"
```

The API key points to a Altified project, so the SDK does not need the project default or target languages in Django settings. Configure those languages in the Altified dashboard.

At runtime the SDK uses Django active language, or an explicit language passed to `translate_field`, as the requested locale. Altified validates that locale against the project connected to the API key and returns the source text when the requested locale is the project default language.

Create `altified.py` beside `manage.py`:

```python
from shop.models import Product

TRANSLATIONS = {
    Product: {
        "fields": ["name", "description"],
    }
}
```

Use the safe helper first:

```python
from django_altified import translate_field, translate_fields

name = translate_field(product, "name")
copy = translate_fields(product, ["name", "description"])
```

Optionally expose the webhook endpoint:

```python
from django.urls import include, path

urlpatterns = [
    path("altified/", include("django_altified.urls")),
]
```
