Jump to content

Topic on Module talk:TNT

Provide language for doc function

3
Mps (talkcontribs)

Hi, I would like to change local data = loadData(dataset) to local data = loadData(dataset, frame.args.lang) in the doc function.

The reason being, I would like to be able to do:

{{#invoke:TNT|doc|Graph:Lines|lang={{int:lang}}}}

This would allow that the TemplateData content is displayed in the language set by the user, and not by the Wikipedia language version. Currently, if a user on the German Wikipedia has set his preferred language to English, the UI as well as the TemplateData captions and so on are in English, but the the data coming from the translation dataset is in German.

I tried to use the Scribunto/Lua equivalent of {{int:lang}}, i.e. mw.message.new("lang"):plain(), but strangely this also returns the Wikipedia content language and not the user language.

I'm specifically asking to be on the safe side as you specifically put a TODO above the line I want to change.

Yurik (talkcontribs)

@Mps hi, thx for writing. I think that TNT should use user's language as oppose to content language in very few cases. TNT produces parts of content, not parts of the user interface. So for example, if you are reading an article with a graph, you expect the text under the graph to be in the same language as the rest of the article. On the other hand, the toolbars and commands at the top should all be in the user-selected language, as that's part of the interface.

That said, I totally agree that template data may benefit from being in the interface language.

As for your question... I don't know for sure, but I have a suspicion that it was done on purpose - WMF doesn't want content to have non-content language, because that fragments the cache, and greatly increases server load. Imagine, instead of having one version of the page, WMF has to have potentially 300 the moment you add some UI-language-dependent template to it.

So, if the {{int:...}} approach works, I would simply create a template wrapper for calling TNT module. What do you think?

P.S. I also think it might be a good idea to use something like https://beta.observablehq.com/ to have a simple conversion tool -- to convert existing template data to a table json format.

Mps (talkcontribs)

Hi @Yurik:, sorry for not answering earlier. Yes a wrapper template seems to be the best choice as it could also help remove the fluff, i.e. providing the method name which is always the same and even the name of the template to describe as this could also be inferred e.g. via {{#titleparts:{{PAGENAME}}|1}}, so that in most cases the user would just need to inject the TNT wrapper template without any parameters to get proper localized template data.

Regarding the PS: A converter for existing template data JSON to data table JSON would certainly be helpful. I can't really say much about beta.observablehq.com as I am myself not much of of a web guy. So I don't know how much of a fitting framework it is.

Reply to "Provide language for doc function"