This page is a translated version of the page ToolTranslate and the translation is 50% complete.

זה המדריך של כלי_תרגום. אפשר לתרגם אותו בשמחה!

כלי_תרגום בפעולה

ייעוד

לכלים רבים ב־Toolforge חסרים תרגומי מנשק, כלומר, שהם זמינים בשפה אחת, בדרך כלל אנגלית. אפילו כלים שתומכים במגוון שפות במנשק משתמשות בשיטות מוזרות להוספת שפות חדשות ותרגומים. כלי_תרגום מציע דרך מרכזית וידידותית לקהילה (TM) לאספקת תרגומים לכלים. כלים צריכים לתמוך במנגנון הזה, כלומר שצריך „לשפץ” אותם פעם אחת כדי שישתמשו בשיטה דינמית במקום בטקסט סטטי במנשק. הרשומה המקורית בבלוג.

תרגום

  1. יש לגשת אל הכלי
  2. אם יש צורך, לעבור אימות של הכלי
  3. לבחור כלי לתרגום מהרשימה הנפתחת בראש או בעמוד הראשי
  4. לבחור או להוסיף את שפת היעד לתרגום
  5. ללחוץ פעמיים על ה„תא” בו אמור להתווסף התרגום שלך, או התרגום שברצונך לשפר
  6. יש להקליד את הטקסט שלך. אפשר להשתמש ב־HTML (בלי JavaScript!). יכולות להופיע הצעות לתרגום מכלי שונה עם אותו „שם מפתח”, אפשר להשתמש בזה כבסיס לטקסט שלך.
  7. ללחוץ על אישור. זהו! למעט כל מיני בעיות אחסון בזיכרון של הדפדפן, התרגום שלך אמור להופיע בכלי המיועד בטעינה הבאה שלו.

משאבים

טכנולוגיה

תרגומים מאוחסנים במסד נתונים ב־Toolforge. גרסאות ישנות של תרגומים נשמאות והתרגומים משויכים לעורכים שלהם. (יש גם כלי „שינויים אחרונים”.)

כדי להקל על הגישה לנתוני התרגום, כל התרגומים מאוחסנים גם בקובצי JSON, שמתעדכנים עם כל שינוי. למשל „demotool1”:

  • toolinfo.json, קובץ JSON עם מידע על הכלי
  • en.json, קובץ ה־JSON שמכיל את התרגום של הכלי לאנגלית. שפות נוספות עובדות באותו האופן, עם קוד השפה התואם שלהם

יש גם קובץ JSON עם כל השפות התקפות.

מסד נתונים

נתוני המקור מאוחסנים במסד הנתונים s53069__tooltranslate_p ב־tools-db ב־Toolforge (mysql --defaults-file=~/replica.my.cnf -h tools-db s53069__tooltranslate_p). משם אפשר למשוך את הנתונים במקרה הצורך. הטבלאות הבאות זמינות:

  • tool
    • id | name | label | url | owner
  • translation
    • id | tool_id | language | key | json | user | timestamp | current

איך לתרגם: HTML/JS

HowTo: PHP

There is a PHP class that you can include on Toolforge, like so:

require_once ( "/data/project/tooltranslate/public_html/tt.php") ;

You can then instantiate the class:

$tt = new ToolTranslation ( array ( 'tool' => 'your_tool_key' , 'language' => 'de' , 'fallback' => 'en' , 'highlight_missing' => true ) ) ; // <span lang="en" dir="ltr" class="mw-content-ltr">Everything except 'tool' is optional</span>

Direct usage

There are two ways of getting interface translations in PHP. One is directly getting a translated string

print "<p>" . $tt->t('translation_key') . "</p>" ;

But this has the disadvantage that the translation cannot be changed without reloading the page.

Use via JS

You can instead add HTML "translation tags" (see above), and have the class add the necessary JS invocation. Another advantage is that the PHP class does not need to load any translation files if you never use the "direct" translation above. To use HTML/JS translation, the <head> section of your pages' HTML needs to contain

<script src="https://tools-static.wmflabs.org/tooltranslate/tt.js">

(You will also need jQuery.) When generating the page, instead of the above, write:

print "<p tt='translation_key'></p>" ;

Somewhere in the output (maybe towards the end), you will need to add the invocation code:

print $tt->getJS() ;

This will initialize the required JS, reproducing the parameters used in the PHP instance (fallback language etc.). If you want a "translation dropdown", add a wrapper element in your HTML code

<div id='tooltranslate_wrapper'></div>

then give the jQuery accessor as a parameter to the getJS method call:

print $tt->getJS('#tooltranslate_wrapper') ;

See this tool for a working example.