Soluling home   Document home

Why you should use Soluling when localizing XML, JSON and YAML based files such as SVG, TMX, XLIFF, XAML, ResX

Why you should use Soluling when localizing XML, JSON and YAML based files such as SVG, TMX, XLIFF, XAML, ResX

Many localization tools claim to support localization of XML, JSON and YAML based files such as SVG, TMX, XLIFF, XAML, ResX. However, they do not have direct support for each file format, but they use a generic XML parser to read and write files. This has several disadvantages.

Hard to configure the parser to extract the right values

The first disadvantage is that you have to teach the parser to extract the elements you want to translate. It might be difficult or at least is very tedious to configure the parser to scan the elements you need to localize. Soluling uses dedicated parsers for each XML based files. This means a dedicated SVG parser, a dedicated TMX parser, etc. This makes localization easy, complete, and safe. You don't have to teach the parser, but it already knows the format and extracts only those elements that need to be translated.

The parser might interpret the value incorrectly

The second disadvantage is that the generic XML parser interprets values as strings even if the value is not actually a string. It might be difficult to translate such a string. This also lets your translator to translate them to any value - possible an invalid value that will break the localized file. The localized file might be valid XML but not contain valid data. Let's have an example. Take a look at the following SVG element.

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<text id="header" x="5" y="20" fill="dodgerblue" font-family="sans-serif" font-size="20">Car</text> <image id="image" x="5" y="25" width="64" height="64" xlink:href="data:image/png;base64,​iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAAC​qaXHeAAAX+ElEQVR42u2aeZScV3nmf/dbai/1vqi71d..." />
<text id="description" x="5" y="110">Car is a wheeled motor vehicle used for transporting passengers.</text>
</svg>

Let's assume that you want to localize the fill, font-family, and font-size attributes in addition to the text value and xlink:href attribute of the image element. If the parser you use does not know what data type an attribute contains, the parser extracts it as a string, and you will have the following lines in your tool.

Original value Translation
Car  
sans-serif  
20  
dodgerblue  
data:image/png;base64,​iVBORw0KGgoAAAANSUhEUgAAAEA​AAABACAYAAAC​qaXHeAAAX+ElEQVR42u2aeZScV3n​mf/dbai/1vqi71d...  
Car is a wheeled motor vehicle used for transporting passengers.  
{Binding ElementName=textBox, Path=Text, StringFormat=Distance is {0} meters.}  

Now it is very likely that the translator just translates them al,l and you might end having the following values.

Original value Finnish translation Is Finnish value valid?
Car Auto yes
sans-serif ilman serifiä no
20 kaksikymmentä no
dodgerblue dodgerin sininen no
data:image/png​;base64,​iVBORw0KGgoAAAAN​SUhEUgAAAEAAAABA
CAYAAACqaX​HeAAAX+ElEQVR42u2a​eZScV3nmf/​dbai/1vqi71d...
tieto:​kuva/png;perus64,​iVBORw0KG​goAAAANS​UhEUgAAAEA​AAABACAYAAACqa​XHeAAAX+ElEQVR4
2u2aeZScV3nmf/db​ai/1vqi71d...
no
Car is a wheeled motor vehicle used for transporting passengers. Auto on pyörillä liikkuva henkilöiden kuljetukseen tarkoitettu moottorin voimin liikkuva ajoneuvo. yes
{Binding ElementName=​textBox, Path=Text, StringFormat=​Distance is {0} meters.} {Binding ElementName=​tektsiLaatikko, Path=Teksti, StringFormat=​Distance is {0} meters.} no

The first and last translations (text element value) are just OK, but all others are not. Grammatically it is OK. dodgerblue in Finnish is dodgerin sininen, but this will break your SVG file. When the tool creates the Finnish text element it will look like this:

<text id="header" x="5" y="20" fill="dodgerin sininen" font-family="ilman serifiä" font-size="kaksikymmentä">Auto</text>

This is invalid SVG data because the fill attribute must contain a color value that is either one of the predefine named values such as red, blue, green, etc., or rgb(RR,GG,BB), or #RRGGBB. "dodgerin sininen" is invalid value and depending on you SVG viewer an error might occur or at least the text element does not render with the right color value but with the default one. The localized font attributes also contain invalid data and that might prevent the SVG rendering, or at least the desired font is not used but the default one is. Finally, the binary value of xlink:href attribute (bease64 encoded with mime header) is is totally impossible or at least very hard for a translator to enter a localized image data.

Soluling's parsers handle all non-string values as non-strings. So, for example, color values are extracted as color, shown to the translator as colors, and finally written to localized files as color. Soluling's SVG parser knows SVG and correctly extracts all elements with the right type. Instead of having "dodgerblue" in the translator's edit box, Soluling shows the color visually. The translator can only choose from a valid color value. Soluling always interprets color, font, and media data correctly and shows the items visually. There is no way your translator can enter values in such a way that the localized file would contain invalid data.

Localizing XML, JSON and YAML based files with Soluling is safe. You never enter translations that would break the localized file.

The parser might not extract all data

The third disadvantage is that generic XML parsers might not extract all data but are limited to string data only. Soluling's parsers can extract all data from your files. This means text, color, image, audio and video data. You save both time and money by using Soluling when localizing XML, JSON and YAML based files.

Generic XML, JSON and YAML parsers

Soluling also contains generic XML, JSON and YAML parser. You should use it if there is no dedicated parser for files you need to localize.