Creating international graphics
Tuesday, April 3rd, 2007I’m going to show you how to internationalize your graphics using inkscape and the gnome desktop.

Prior Considerations
Translations are always going to be variable length.
What might look short and snappy in Simplified Chinese may be a whole sentence to explain in Brazillian Portugese.
For this reason you should create designs with generous amounts of space around your words.
With SVG you may need to define a flowtext region. This is done in Inkscape by selecting the text tool and dragging. Centering text also works a treat.
We’re going to be creating .po files for translation without the need of opening the entire SVG XML or editing with inkscape. If you work with a translation community, this is much more considerate than throwing them headfirst into a text editor or inkscape.
Right, so here we go
Say we have a web graphic, a presentation, an advertisement, diagram whatever.
We’re going to translate it into 23 languages and walkaway unharmed.
Something to avoid is duplicating editable text.
You might want a drop shadow, blurred mask or some other effect layered above or behind your text. If so, make sure you clone (<use>) and not copy. You may be getting free translations from the community, it helps to not make them type the same phrase over and over again.
xml2po to the rescue
gnome-doc-utils sure is a beautiful package. The awesome GNOME developers have created a tool that will pull strings of text from your xml document and issue them as strings in a pofile.
Here is a test file for you to use for this exercise. Make sure you right click the link and select “save link as”.
xml2po -a -o en-US.po chrome.svg
Create locale specific po files
We’re just going to copy the upstream po file and rename it as per each locale.
cp en-US.po as-IN.po cp en-US.po bn-IN.po cp en-US.po de-DE.po cp en-US.po es-ES.po cp en-US.po fr-FR.po cp en-US.po gu-IN.po cp en-US.po hi-IN.po cp en-US.po it-IT.po cp en-US.po ja-JP.po cp en-US.po kn-IN.po cp en-US.po ko-KR.po cp en-US.po ml-IN.po cp en-US.po mr-IN.po cp en-US.po or-IN.po cp en-US.po pa-IN.po cp en-US.po pt-BR.po cp en-US.po ru-RU.po cp en-US.po si-LK.po cp en-US.po ta-IN.po cp en-US.po te-IN.po cp en-US.po zh-CN.po cp en-US.po zh-TW.po
Translate the po files
kbabel or gtranslator are the apps of choice for many open source translators. They will open up your pofiles and give friendly preview of only the text strings in your SVG and nothing else.

A word of warning. The depth of text in your SVG reflects the order the strings will appear in your pofiles.
This means you may confuse the logical flow of text by arranging text above or below shapes. Text sent to the bottom depth is displayed at the start of the generated pofile.
Another word of warning to your translators
That “image/svg+xml” string you see at the top of each pofile is unfortunately pulled into your pofiles via xml2po and shouldn’t be translated otherwise you may break the validity of your SVG.
Time to merge translated pofiles back into SVG
Once your pofiles are given the all clear from translators you can generate the translation changes back into svg files specific to their locale.
xml2po -a -p en-US.po chrome.svg > chrome-as-IN.svg xml2po -a -p as-IN.po chrome.svg > chrome-as-IN.svg xml2po -a -p bn-IN.po chrome.svg > chrome-bn-IN.svg xml2po -a -p de-DE.po chrome.svg > chrome-de-DE.svg xml2po -a -p es-ES.po chrome.svg > chrome-es-ES.svg xml2po -a -p fr-FR.po chrome.svg > chrome-fr-FR.svg xml2po -a -p gu-IN.po chrome.svg > chrome-gu-IN.svg xml2po -a -p hi-IN.po chrome.svg > chrome-hi-IN.svg xml2po -a -p it-IT.po chrome.svg > chrome-it-IT.svg xml2po -a -p ja-JP.po chrome.svg > chrome-ja-JP.svg xml2po -a -p kn-IN.po chrome.svg > chrome-kn-IN.svg xml2po -a -p ko-KR.po chrome.svg > chrome-ko-KR.svg xml2po -a -p ml-IN.po chrome.svg > chrome-ml-IN.svg xml2po -a -p mr-IN.po chrome.svg > chrome-mr-IN.svg xml2po -a -p or-IN.po chrome.svg > chrome-or-IN.svg xml2po -a -p pa-IN.po chrome.svg > chrome-pa-IN.svg xml2po -a -p pt-BR.po chrome.svg > chrome-pt-BR.svg xml2po -a -p ru-RU.po chrome.svg > chrome-ru-RU.svg xml2po -a -p si-LK.po chrome.svg > chrome-si-LK.svg xml2po -a -p ta-IN.po chrome.svg > chrome-ta-IN.svg xml2po -a -p te-IN.po chrome.svg > chrome-te-IN.svg xml2po -a -p zh-CN.po chrome.svg > chrome-zh-CN.svg xml2po -a -p zh-TW.po chrome.svg > chrome-zh-TW.svg
Now you have a directory of svg images the same as your upstream.
Export Images
If you are working with an environment that deals with PDF’s, you may want to ignore this step.
SVG’s are best sent through things like Batik when using FOP to create a pdf rather than rendered PNG for obvious reasons (vector=love)
If you are exporting to web or something else and want to be friendly to software that cant read your Inkscape crafted SVG:
This is the step for you.
for i in *.svg;do inkscape -e "${i/.svg/.png}" "$i" ;done
Compressing PNG’s
Of course on the web every byte counts
pngcrush will give you the best file size without losing a pixel.
for i in *.png;do pngcrush -brute -d tmp "$i" ;done; mv -f tmp/* .; rm -rf tmp



Benefits of using this technique…
If you are a creating technical illustrations or diagrams you may want to alter your upstream version (In this case: en-US) as the conceptual changes.
Thankfully xml2po will regenerate translations from upstream regardless of new objects you create, styles you change or transformations you make to your original. This is wonderful for when management ask for their illustrations to be larger and changed to cornflower blue. More on automating that sort of thing across a set in a later post.
UPDATE:
My good mate prokoudine has ported this article to RU








