You should be able to add a lang="xx" attribute to the <mapframe> tag to choose a custom language. If there is no lang attribute, it should use the page language as it does now.
Description
Details
Event Timeline
Change 426322 had a related patch set uploaded (by Catrope; owner: Catrope):
[mediawiki/extensions/Kartographer@master] Add lang parameter to <mapframe>
Change 426322 merged by jenkins-bot:
[mediawiki/extensions/Kartographer@master] Add lang parameter to <mapframe>
I don't think https://gerrit.wikimedia.org/r/426322 should have been merged. Besides the no tests, it uses user language, not content language. As such, this ends up with weird behavior: if content author created a <mapframe lang=xx>, it will always show the map in xx, but if they didn't specify lang param, it will use User's language, not the content language.
It does use the content language, not the user language. $this->getLanguage() ends up using $this->parser->getTargetLanguage(), which is the page language (which is generally the content language, except in weird cases like translated pages).
My apologies, missed the second file's change, and thought you used $context->getLanguage(). All's good.
Change 426368 had a related patch set uploaded (by Catrope; owner: Catrope):
[mediawiki/extensions/Kartographer@master] Also pass language code through leaflet for dynamic maps
Change 426389 had a related patch set uploaded (by Catrope; owner: Catrope):
[mediawiki/extensions/Kartographer@master] Respect lang attribute in VisualEditor modules
Change 426368 merged by jenkins-bot:
[mediawiki/extensions/Kartographer@master] Also pass language code through leaflet for dynamic maps
Change 426389 merged by jenkins-bot:
[mediawiki/extensions/Kartographer@master] Respect lang attribute in VisualEditor modules
Checked in betalabs for enwiki and cawiki.
I used - ja for Japanese language.
<mapframe width="700" height="400" zoom="9" longitude="8.5062" latitude="46.8151" align="right" lang="ja" />
(1)
enwiki (beta) - displays available labels in Japanese on a page and on a map full view - e.g. https://en.wikipedia.beta.wmflabs.org/wiki/Mavetuna14
cawiki (beta) - - displays available labels in Japanese on a page but not on a map full view -
e.g. https://ca.wikipedia.beta.wmflabs.org/wiki/Mavetuna (https://ca.wikipedia.beta.wmflabs.org/wiki/Mavetuna#/map/0)
@Catrope - should lang be recognized in full map view on cawiki(beta)?
(2) When the lang parameter is not recognized, the fallback will be to the content lang of a wiki.
Change 428404 had a related patch set uploaded (by Catrope; owner: Catrope):
[mediawiki/extensions/Kartographer@master] Make lang attribute work for static maps too
Change 428404 merged by jenkins-bot:
[mediawiki/extensions/Kartographer@master] Make lang attribute work for static maps too
Checked in cawiki betalabs(for static maps) and enwiki betalabs for view on a page and full-map view.
- maps will display available labels according to lang="[lang]" attribute
- unavailable/invalid or absent lang entry will result in the fallback to the wiki content lang
QA recommendation: Resolve.