Problem: Switch-translated SVGs can hold multiple translations in the same file. However when such files are used on other wikis, they need to have a lang=<lang-code> parameter for the image to render in the correct language.
Here's an example image: https://commons.wikimedia.org/wiki/File:Neural_crest.svg which contains translations for ru, hr and de as apparent from the Render this image in dropdown -
This dropdown was added in this patch in 2014.
Here's the image usage in ruwiki, hrwiki, dewiki. If you at the source, they contain lang=ru/lang=hr/lang=de after the file name (like [[File:abc.svg|lang=de]])
This is problematic because:
- The file will not be updated on articles even if a translation is added for it on Commons. This is the case for a lot of files out there.
- It is an unfair work burden on non-enwiki contributors.
Proposed solution: MediaWiki should be smart enough to automatically show the file in the wiki language, if that translation exists. If not, it should fallback to the default.
General direction for this investigation:
- Find out what loads and creates the SVG links
- Find out what it means to conditionally change the SVG links based on content language
- Come up with an implementation plan, or, if there are multiple options, describe all relevant
- T60920: lang support for SVG images using SystemLanguageAttribute ill-defined and not properly supported in browsers
- T201207#4503458 - last few paragraphs
- MediaWiki stores the available translations for each SVG in the img_metadata field of the image table and this information is available via the getAvailableLanguages() function in MediaWiki's SvgHandler class.
- The thumbnails displayed on each wiki are actually PNG thumbnails generated by librsvg. librsvg handles rendering the SVG into a PNG with the desired systemLanguage.
- The solution of just generating thumbnails for every language was previously rejected as unnecessary cache fragmenting, as most languages won't actually have translations and thus would be identical to the English (default) thumbnail.