Display SVGs in target language
authorMax Semenik <maxsem.wiki@gmail.com>
Sat, 6 Oct 2018 00:56:53 +0000 (17:56 -0700)
committerMax Semenik <maxsem.wiki@gmail.com>
Tue, 30 Oct 2018 23:12:11 +0000 (16:12 -0700)
commitc16704c33a278b729c11922916445b41ce05253b
treeb62ba4c40ac9d25c3244b67cbded5cdc5e4705df
parentfa7510eb1b5c9f3bba33131a4f21115ed06402fb
Display SVGs in target language

Previously, they were always displayed in defult language unless
forced explicitly in wikitext, e.g. [[File:Foo.svg|lang=ru]].
This change adds a feature flag that would enable always trying to
display in page language.

* If enabled, Parser will pass a new parameter - 'pagelang' - to
  the media handler.
* SvgHandler uses page language when determining what language to
  render the image in.
* 'pagelang' can always be overridden by 'lang'.
* If no translation in page language is available, the default
  language (English) will be used for thumbnail URLs, to prevent
  cluttering media storage and HTTP caches with useless copies.

Performance: this requires accessing image's metadata during parsing.
My testing indicates there were no code path where this wasn't the
case already, so no performance hit is expected, however we should
still keep an eye on page save performance.

Bug: T205040
Change-Id: I348840ef405e1370cc0c17d69051bce30153c9c0
RELEASE-NOTES-1.33
includes/DefaultSettings.php
includes/Linker.php
includes/media/ImageHandler.php
includes/media/SvgHandler.php
includes/parser/Parser.php
tests/parser/ParserTestRunner.php
tests/parser/parserTests.txt
tests/phpunit/includes/media/SVGTest.php [deleted file]
tests/phpunit/includes/media/SvgHandlerTest.php [new file with mode: 0644]