Actions

Custom translation: Difference between revisions

From LimeSurvey Manual

(page creation)
 
mNo edit summary
Line 30: Line 30:
# Create the related translation : <code>INSERT INTO lime_message (id, language, translation) VALUES ('1', 'en', 'Validate'), ('1', 'fr', 'Valider'); </code>
# Create the related translation : <code>INSERT INTO lime_message (id, language, translation) VALUES ('1', 'en', 'Validate'), ('1', 'fr', 'Valider'); </code>


==using your own theme (ecommended solution)==
==Using your own theme (ecommended solution)==


This method use a solution with your own template, it updates the default string for all other language too/.
This method use a solution with your own template, it updates the default string for all other language too/.

Revision as of 18:10, 16 May 2024

Introduction

Since LimeSurvey 5.4.0 you can have your own translation for all string in all included language 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.

You can use this method too for translating Survey Theme specific string.

How database translation works

For database translation, LimeSurvey uses a method inspired by CDbMessageSource from the Yii framework.

  1. find the string in SourceMessage table lime_source_message->message, get the id : lime_source_message->id
  2. if exist find the related transtaion in Message table lime_message->translation for current language lime_message->language with current id lime_message->id

LimeSurvey create the array with translation from po file (see Translating LimeSurvey for update this file), and aftre merge with all translation form database.

Then the translation from the database are always return if exist.

Sample for _Submit_ button in english and french

You want to show _Validate_ and not _Submit_ for the submit button in all of yours survey (with a specific theme). If you just update the theme and replace gT('Submit') by gT('Validate') : it always shows _Validate_ in all language.

For all surveys with all theme

  1. Create the source message INSERT INTO lime_source_message (id, category, message) VALUES (NULL, NULL, 'Submit');
  2. Check the ID (if it's the 1st : ID is 1) and use it for next instruction
  3. Create the related translation : INSERT INTO lime_message (id, language, translation) VALUES ('1', 'en', 'Validate'), ('1', 'fr', 'Valider');

Using your own theme (ecommended solution)

This method use a solution with your own template, it updates the default string for all other language too/.

  1. In Theme editor select the Navigation part
  2. Search for Template:GT("Submit") (in navigator.twig)
  3. Replace by Template:GT("Validate")
  4. Create the source message INSERT INTO lime_source_message (id, category, message) VALUES (NULL, NULL, 'Validate');
  5. Check the ID (if it's the 1st : ID is 1) and use it for next instruction
  6. Create the related translation : INSERT INTO lime_message (id, language, translation) VALUES ('1', 'fr', 'Valider');