5

Is there a way to create multilingual SVG files for the web?

I have an SVG with text that I use on a website.

Now if the user changes the language on the website I should normally create a new images for that language. Is there a way to add translation strings to an SVG that change based on some parameter?

  • 1
    I'm very interested in the solution too, but only, if it can be put into one SVG file. I'm not used to work with javascript, browser detection and xml-nodes, but I guess it should be possible to hide a node by name, or set its transparency to 100%. – user unknown Oct 31 '15 at 15:43
1

If I were you I would use jQuery to detect what language the browser is and use separate files, such as:

icon_de.svg
icon_en.svg
icon_se_svg

Then with jQuery use navigator.language to detect the language and if you have that SVG set then append to icon_.svg.

Example for navigator.language:

if (window.navigator.language != "en") {       
  doLangSelect(window.navigator.language); 
}

Research:

  • Content negotiation - if the web server supports this - should do the trick without any client-side scripting: en.wikipedia.org/wiki/Content_negotiation – Michael Schumacher Oct 30 '15 at 15:23
  • 1
    You say use jQuery but your code given doesn't use jQuery... There's no need for jQuery for this type of thing (or much of one in general these days) – Zach Saucier Nov 1 '15 at 21:34
  • I'm looking for a single file solution if possible. – juFo Jan 11 '16 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.