Files
descrybe/docs/category-prompt-translations.md
2026-10-14 18:47:00 +02:00

83 lines
4.1 KiB
Markdown

# Category prompts: all languages, permanent default, A1 cleanup
The **content language** selector supports 25 languages: en, fr, de, es, it, nl,
pt, pl, cs, sk, hu, ro, bg, hr, sl, sv, da, fi, el, et, lv, lt, mt, ga, ja.
The dropdown may show only 24 when a language (such as Slovenian) is already
selected, because the Add Language selector excludes the current language.
## Global platform defaults
- All new non-custom categories receive the A1-inspired naming formula, **five
distinct benefit sections** and sourced technical specifications. The standard
metadata rule starts with the title and limits meta descriptions to 140 chars.
- The title keeps existing category-specific product-model ordering where supplied
in the bundled taxonomy; otherwise it defaults to brand, product type, model, color.
- Prompt instructions are versioned and their translations are cached globally in
`default_category_prompt_translations` (migration 048).
- **Custom prompts and custom structured formulas are protected**. The seed only
adds missing languages to current defaults, or upgrades an exact snapshot of the
previous built-in default. A1 Slovenija is explicitly excluded from the generic
backfill.
- The editor displays language-specific examples for all 25 languages. Examples
are read-only until clicked with "Use example".
- New categories reuse translations automatically once the shared cache is seeded.
Run from the repo root:
```bash
npm run migrate
npm run seed:category-prompts:i18n -- -dry-run
npm run seed:category-prompts:i18n
```
**The seed ships with 25 prelocalized title, description and meta instruction sets.**
There are **no network translation calls, no OpenAI credentials, and no costs**
for translation. Only `DATABASE_URL` is required. The platform-standard
translations are intentionally shared across taxonomy categories; the original
category-specific English defaults and structured title/description formulas
remain available in English. This preserves the default layout and avoids
inventing localized category-specific naming variants. Company-authored prompts
in any language are never replaced. Running the seed stores missing defaults
in the cache for future companies and categories, and cleans duplicates in
A1's existing category prompts without replacing A1's custom instructions.
The seed never overwrites previously stored language values, including values
from older runs. For a subset you can run `-langs sl,hr,de` or `-limit 1`.
Failures are reported and produce a nonzero exit code.
## A1 Slovenia: rewrite repeated benefits without losing sections
The bundled `scripts/seed/a1-category-prompts.json` is normalized so it
contains **no duplicate H2 benefit instructions**. When a live A1 prompt repeats
an instruction, the cleanup rewrites later headings/paragraph instructions with
distinct benefit numbers rather than deleting sections. The paragraph's original
product-name inclusion/exclusion rule, naming formula, meta rules and technical
specifications are retained. It avoids inventing specific product claims.
Existing DB categories can be cleaned with:
```bash
# Preview; does not write anything
npm run cleanup:a1:prompts
# Apply, A1 Slovenija only
npm run cleanup:a1:prompts -- -apply
```
The global translation seed now also performs this A1 cleanup automatically.
The standalone command remains available to rerun separately. It differentiates
repeated benefit instructions in stored category prompt language variants and
structured description templates; it never rewrites title or SEO formulas.
It uses optimistic concurrency checks, preserves section counts, and can be rerun. Take a database backup first.
A1 reimport, A1 repair, and WordPress SQL input now normalize duplicate pairs
before saving, so the older source cannot reintroduce them.
## Validation
- 25-language example test: pass.
- Offline Go tests for 25 bundled locales, HTML A1 normalization, structured A1 normalization, and idempotence: pass.
- Backend integration suite: not run here; project requires Go 1.25 and PostgreSQL.
- Full frontend test suite: 288 passed, 6 pre-existing locale-key failures (not
introduced by this change).