Module talk:Json2table
Lang
The documentation here (at the top of the module) says:
lang – language code to pick the correct translation from multilingual fields; if omitted the site’s content language (English on Commons) is used.
And the documentation of the corresponding template at Template:Json2table says:
lang– language code to pick the correct translation from multilingual fields; if omitted the site’s content language (English on Commons) is used.
Both of these statements appear to be wrong. The second example at Template:Json2table/doc (the first of two using Data:COVID-19 hospitalizations in Denmark.tab) is rendered for me in Swedish. Commons is not a Swedish wiki, nor am I a Swedish user. But the entries for the table description and the field names (column names) in the JSON file are given in multiple languages, and Swedish (lang code sv) just happens to be the last language specified in each of these cases. So, is the last language provided in the JSON file used if no lang parameter is specified? - dcljr (talk) 13:09, 14 August 2025 (UTC)
[time passes]
Looks like this might be a little more complicated than I was thinking. If not specified in the call (or not specified correctly), the language is set in the module by this:
_, lang = mw.wikibase.getLabelWithLang( 'Q2' )
So, maybe Swedish is being used in the example because whatever is actually returned by mw.wikibase.getLabelWithLang( 'Q2' ) (have not tested this) is not one of the languages in the JSON file? So, the last language defined is used as a kind of "fallback", a la switch? - dcljr (talk) 18:59, 14 August 2025 (UTC)
- Checked the above code in the module sandbox and got
en. Then changed my local language preference (for this wiki) to Spanish and gotes. So apparently that's not the problem. - dcljr (talk) 01:51, 21 August 2025 (UTC)