Commons:Graphic Lab/Translations

Shortcut: COM:GL/T Note that instead of using the questionable SVG Translate tool, you can use any text editor capable of using UTF-8.
Reducing tool-inserted code garbage increases the readability of the SVG. A (not yet public) script can clean SVG code from tool-inserted bloatings which decrease the readabilty.

Choice for translations edit

There are two choices for translating an existing monolingual file:

  • either into a new file name, usually just by adding the two-letter country code, for a separate translation into each language,000or
  • by adding multiple languages within the same file using the SVG <switch> elements.

In latter case, the resulting multilingual file has the advantage of sharing graphics: if the graphics are updated, then all the languages get the benefit of the updated graphics. Compare to having several translated files: an update to one of the files does not propagate to any of the other language versions.

Creating new multilingual files

The best strategy may be to first create the graphics, either by hand, or more complicated graphics with an SVG tool.
That is just the same as using an existing file, either without any text, or with monolingual text, or some multilingual text.
In a second step the text is added, with the help of a text editor. When it overlays parts of the graphic, it has to be defined after their drawing; when possible, it is a good choice to have the text near to the begin of the SVG code - the next editor can find it easily.
At Drupe fruit diagram.svg all text can be written in advance; at Titan's atmosphere after the black background, but at Structural-Iceberg afterwards.

Editing existing multilingual files

Of course, even in an existing file it can be possible to move the text from the end to the begin of the code.

How to maintain translations using a text editor edit

Often this might be a possibility for more advanced users as text coordinates adjustments might be needed.
Experienced users can perform small changes using Rillke's "Edit SVG" feature, using the link at the left "tools" bar.

Otherwise the SVG file can be

  1. downloaded to your disk unit, then
  2. edited with the text editor and tested with the browser, repeated as often as needed, until it gets
  3. uploaded again to wikimedia.

Find text to translate by searching for <text> tags.
A code sequence looking like

<switch ...>
<text systemLanguage="ca">Catalan text</text>
<text systemLanguage="cs">Czech text</text>
<text systemLanguage="en,nl">Text for English and also Dutch</text>
. . . 
. . . 
</switch>

can now easily be altered (changed, expanded, more languages added). ISO 639-1 should be used, normally.
Be aware that browsers may display text differently to the librsvg layout!

More complicated text layout, e.g. with <tspan>, will need more experience. Often it is easy to copy parts of the present code for new text insertions.
The category SVG simplification by text switch contains many examples of simple to different complexity, e.g. Astronomical unit.svg.


In the same way, an expansion of monolingual to multilingual text can be edited: an appropriate <switch> clause must be added, more text lines need more switches - one for each line. In most cases it will be required to set the text coordinates (and other attributes) with e.g. <switch transform="translate(100 200)">


Please use appropriate templates to tag the files, e.g {{ Translateswitch = y }} and {{ NoInkscape- }} (together with Image generation)

  This file is translated using SVG <switch> elements. All translations are stored in the same file! Learn more.

For most Wikipedia projects, you can embed the file normally (without a lang parameter). The Wikipedia will use its language if the SVG file supports that language. For example, the German Wikipedia will use German if the SVG file has German. To embed this file in a particular language use the lang parameter with the appropriate language code, e.g. [[Commons:Graphic Lab/Translations|lang=en]] for the English version. Do not specify a lang parameter if it is not needed. The parameter may prevent the use of a subsequent translation.

To translate the text into your language, you can use the SVG Translate tool. Alternatively, you can download the file to your computer, add your translations using whatever software you're familiar with, and re-upload it with the same name. You will find help in Graphics Lab if you're not sure how to do this.

  Please do not upload a version translated with the buggy SVG Translate without first cleaning it from all the garbage the tool adds!

Templates for smaller boxes exist. {{ Igen/embswitch = S }}

  
 This file is translated using SVG switch elements: all translations are stored in the same file.
  
 Please do not maintain the embedded languages with the buggy SVG translator