feat(translations): multi-language support in csv_to_sql + tutorial
csv_to_sql.php now accepts several language codes in one call (labels.csv nl de fr > all.sql) and reports per-language counts; unknown or missing columns are rejected with exit 1. translations/README.md shows a concrete nl+de example and documents that sync_labels.php preserves any language columns added to the CSV header. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
07f70bd00c
commit
6786adf092
1 changed files with 68 additions and 34 deletions
|
|
@ -28,10 +28,19 @@ Open `translations/labels.csv` in Excel, LibreOffice Calc or Google Sheets
|
|||
Do not edit the `source` column: the source string must match the `title=` /
|
||||
label in `config.xml` exactly, or the translation is not picked up.
|
||||
|
||||
## 2. Translate
|
||||
## 2. Translate — multiple languages
|
||||
|
||||
Fill in the translation cells for the languages you need. Add another language
|
||||
by adding a column to the header row, e.g. `de`, `fr`, `pt_PT`.
|
||||
Fill in the translation cells for the languages you need. The CSV ships with
|
||||
one language column (`nl`); **other languages follow the same pattern**: add a
|
||||
column to the header row for each language, e.g. `de`, `fr`, `pt_PT`:
|
||||
|
||||
context,key,source,nl,de,fr
|
||||
category,"(category name)",Header,Koptekst,Überschrift,Titre
|
||||
option font (Default font and colors),font,"Default font (body text)","Standaard lettertype (bodytekst)","Standardschriftart (Fließtext)","Police par défaut (texte)"
|
||||
|
||||
`sync_labels.php` preserves every language column automatically — adding a
|
||||
column never loses translations, and new strings get an empty cell in each
|
||||
language column.
|
||||
|
||||
Notes:
|
||||
|
||||
|
|
@ -57,12 +66,18 @@ reported on screen). To check staleness without writing (e.g. in a dev check):
|
|||
|
||||
## 4. Generate the SQL and load it into the database
|
||||
|
||||
One language:
|
||||
|
||||
php translations/csv_to_sql.php translations/labels.csv nl > nl.sql
|
||||
mysql -h localhost -u <dbuser> -p <dbname> < nl.sql
|
||||
|
||||
Or several languages in one go (one SQL file with all of them):
|
||||
|
||||
php translations/csv_to_sql.php translations/labels.csv nl de fr > all.sql
|
||||
mysql -h localhost -u <dbuser> -p <dbname> < all.sql
|
||||
|
||||
The generated SQL is idempotent (`INSERT IGNORE` + `ON DUPLICATE KEY UPDATE`), so
|
||||
re-run it after every edit of the CSV. Repeat per language (`... labels.csv de >
|
||||
de.sql`, etc.). Empty translation cells are skipped.
|
||||
re-run it after every edit of the CSV. Empty translation cells are skipped per
|
||||
language.
|
||||
|
||||
The admin sees the translations as soon as their UI language matches — no theme
|
||||
reset or asset flush is needed (the message tables are read at runtime). To ship
|
||||
|
|
|
|||
Loading…
Reference in a new issue