| Filename | Latest commit message | Latest commit date |
|---|---|---|
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> |
||
| .. | ||
| csv_to_sql.php | ||
| labels.csv | ||
| README.md | ||
| sync_labels.php | ||
Translating the theme labels — tutorial
The custom theme options page (options/options.twig) shows every label through
LimeSurvey's gT() translation function. LimeSurvey merges translations from two
sources: the core gettext catalogs (locale/<lang>/<lang>.mo, ~60 languages, core
strings only) and the database tables lime_source_message + lime_message
(merged at DBVersion >= 480). The theme's own labels are translated per installation
through those database tables — pure data, no core change needed.
This directory makes that easy with a spreadsheet:
labels.csv— every translatable theme label, one row per source stringsync_labels.php— keepslabels.csvin sync withconfig.xmlcsv_to_sql.php— turns a filled-in language column into SQL for the DB tables
1. Open the spreadsheet
Open translations/labels.csv in Excel, LibreOffice Calc or Google Sheets
(import as CSV, comma-separated, UTF-8). Layout:
| column | meaning |
|---|---|
context |
where the string appears (option key / category / dropdown) |
key |
the config.xml option key (or (category name)) |
source |
the exact English source string — this is the gT() lookup key |
nl |
the Dutch translation (one column per language) |
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 — multiple languages
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:
- HTML in labels is intentional and must be kept, e.g.
<strong>...</strong>. - Some labels contain a line break (
XLarge\n(20 px)) — keep it. - Strings like
Yes/No/Inheritare core strings and already translated by the gettext catalogs; translating them here only overrides them for this installation.
3. Keep the spreadsheet up to date during development
Whenever config.xml changes (new option, renamed title, new dropdown entry),
re-run:
php translations/sync_labels.php
This re-extracts all labels from config.xml and merges them into labels.csv:
new strings are appended with empty translation cells, your existing translations
are preserved, strings that disappeared from config.xml are removed (and
reported on screen). To check staleness without writing (e.g. in a dev check):
php translations/sync_labels.php --check # exit 1 when out of sync
4. Generate the SQL and load it into the database
One language:
php translations/csv_to_sql.php translations/labels.csv nl > 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. 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
translations with the theme itself, commit the filled-in labels.csv to this
repository; other installations can then load them the same way.
5. Verify
Log into LimeSurvey with the target UI language (e.g. Nederlands), open
Theme options of a survey that uses this theme, and check the labels on the custom
options page. If a label still shows English, its source cell in the CSV does
not exactly match the title=/label in config.xml — re-run sync_labels.php
and compare.