Actions

Custom translation/ja: Difference between revisions

From LimeSurvey Manual

(Created page with "データベースの翻訳では、LimeSurveyはYiiフレームワークの[https://www.yiiframework.com/doc/api/1.1/CDbMessageSource CDbMessageSource]に着想を得た方法を使用しています。")
(Created page with "# SourceMessageテーブルのlime_source_message->messageで文字列を検索し、lime_source_message->idからidを取得します。 # 存在する場合、対象のid lime_message->idを持つ言語lime_message->languageのlime_message->translationからMessageテーブルの関連する翻訳を検索します。")
Line 16: Line 16:
データベースの翻訳は、LimeSurveyはYiiフレームワークの[https://www.yiiframework.com/doc/api/1.1/CDbMessageSource CDbMessageSource]から着想を得た方法を使用しています。
データベースの翻訳は、LimeSurveyはYiiフレームワークの[https://www.yiiframework.com/doc/api/1.1/CDbMessageSource CDbMessageSource]から着想を得た方法を使用しています。


<div lang="en" dir="ltr" class="mw-content-ltr">
# SourceMessageテーブルのlime_source_message->messageで文字列を検索し、lime_source_message->idからidを取得します。
# find the string in SourceMessage table lime_source_message->message, get the id : lime_source_message->id
# 存在する場合、対象のid lime_message->idを持つ言語lime_message->languageのlime_message->translationからMessageテーブルの関連する翻訳を検索します。
# if exists, find the related translation in Message table lime_message->translation for current language lime_message->language with current id lime_message->id
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">

Revision as of 11:12, 25 May 2024

Other languages:

はじめに

LimeSurvey 5.4.0以降では、データベースへの直接アクセスによって全言語のあらゆる文字列を独自に翻訳することができます。

既存の翻訳がビジネスニーズに適合しない場合にこのしくみを使用することができます。

LimeSurveyの中核部分のテキストを変更すると、データベースを変更する必要があるため、特定の場合にのみ使用してください。

さらに、このしくみを使用すれば、アンケートテーマ固有の文字列を翻訳することもできます。

データベース翻訳のしくみ

データベースの翻訳は、LimeSurveyはYiiフレームワークのCDbMessageSourceから着想を得た方法を使用しています。

  1. SourceMessageテーブルのlime_source_message->messageで文字列を検索し、lime_source_message->idからidを取得します。
  2. 存在する場合、対象のid lime_message->idを持つ言語lime_message->languageのlime_message->translationからMessageテーブルの関連する翻訳を検索します。

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

  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 (recommended solution)

This method uses a solution with your own template, it updates the default string for all other languages as well.

  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');