Custom translation
From LimeSurvey Manual
Introduction
Since LimeSurvey 5.4.0 you can have your own translation for all strings in all included languages with direct access to your database.
This system can be used if an existing translation is not compatible with your business needs.
It should be reserved for specific cases, since text modifications in the heart of LimeSurvey will again require a modification of your database.
Furthermore, you can use this method for translating Survey Theme specific strings.
How database translations works
For database translations, LimeSurvey uses a method inspired by CDbMessageSource from the Yii framework.
- find the string in SourceMessage table lime_source_message->message, get the id : lime_source_message->id
- if exists, find the related translation in Message table lime_message->translation for current language lime_message->language with current id lime_message->id
LimeSurvey creates the array with translations from po file (see Translating LimeSurvey for information how to update this file), and afterwards merges it with all translations from the database.
Then the translations from the database are always returned if they exist.
Sample for “Submit” button in English and French
You want to show _Validate_ and not _Submit_ for the submit button in all of your surveys (with a specific theme). If you just update the theme and replace gT('Submit') by gT('Validate') : it always shows _Validate_ in all languages.
For all surveys with all themes
- Create the source message
INSERT INTO lime_source_message (id, category, message) VALUES (NULL, NULL, 'Submit');
- Check the ID (if it's the 1st : ID is 1) and use it for next instruction
- Create the related translation :
INSERT INTO lime_message (id, language, translation) VALUES ('1', 'en', 'Validate'), ('1', 'fr', 'Valider');
Using your own theme (recommended solution)
This method uses a solution with your own template, it updates the default string for all other languages as well.
- In Theme editor select the Navigation part
- Search for
Template:GT("Submit")
(in navigator.twig) - Replace by
Template:GT("Validate")
- Create the source message
INSERT INTO lime_source_message (id, category, message) VALUES (NULL, NULL, 'Validate');
- Check the ID (if it's the 1st : ID is 1) and use it for next instruction
- Create the related translation :
INSERT INTO lime_message (id, language, translation) VALUES ('1', 'fr', 'Valider');