update
This commit is contained in:
1 parent
3bfeb6b61e
commit
7537a41955
30 files changed
+1441
-85
No files matched your search
@@ -0,0 +1,73 @@
|
||||
# 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 does not come with precalculated live translations.** When executed,
|
||||
OpenAI translates the built-in prompts for each of the 25 supported languages
|
||||
into a shared PostgreSQL cache. This can make thousands of translation API calls,
|
||||
so run with a controlled budget and review output. `OPENAI_API_KEY` and
|
||||
`DATABASE_URL` must be set. The seed is resumable and never overwrites an existing
|
||||
cached translation. `-langs sl,hr,de` and `-limit 1` can be used for pilot runs.
|
||||
The script validates placeholders, HTML tags, language selection and text length.
|
||||
If any language fails, it logs the failure and exits with an error; rerun to retry
|
||||
missing values.
|
||||
|
||||
## A1 Slovenia: remove repeated descriptions
|
||||
|
||||
The bundled `scripts/seed/a1-category-prompts.json` has been cleaned of **exact
|
||||
repeated** H2/paragraph pairs in 59 category definitions. The product-naming,
|
||||
benefit inclusion/exclusion, HTML specification list, and SEO rules are kept.
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
This command only removes exact duplicate heading/paragraph pairs from stored
|
||||
category prompt language variants and structured description templates; it never
|
||||
rewrites the category title formula or SEO metadata. It uses optimistic
|
||||
concurrency checks and can be rerun. Take a database backup first.
|
||||
|
||||
If A1 content is later re-imported from an older WordPress SQL dump, that dump
|
||||
may reintroduce duplicates. Run the cleanup command again after that import.
|
||||
|
||||
## Validation
|
||||
|
||||
- 25-language example test: pass.
|
||||
- Isolated Go default/formula and A1 duplicate tests: 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).
|
||||
Reference in new issue
Block a user