Topic on Project:Support desk

Wiktionary: How possible would it be to create a Magic Word which gives the most recent L2 heading

6
Pengo (talkcontribs)

Every entry on Wiktionary is organised with L2 language headings,

e.g. https://en.wiktionary.org/wiki/action contains:

==English==
...
==French==
...
==Middle French==
...

Under each of these headings are numerous templates, almost all of which either contain the L2 language's code as a parameter or as part of the template's name

e.g. Every bolded en or lang=en below is redundant, as they could be (theoretically) inferred from the "English" heading above them:

==English==
From {{etyl|enm|en}} 
...
* {{IPA|/ˈæk.ʃən/|lang=en}}
* {{audio|en-us-action.ogg|Audio (US)|lang=en}}
* {{rhymes|ækʃən|lang=en}} 
...
{{en-noun}}

And there are many more templates with similar redundant parameters on this page in the English, French, and Middle French sections.

This is a huge amount of unnecessary redundancy, and it creates many opportunities for error.

Surely it would be possible to create some solution in MediaWiki to automatically pass the most recent L2 heading as a parameter to templates, or to somehow make it available as a magic word? This would have an enormous pay off in terms of simplifying Wiktionary editing, especially for new editors.

If you're wondering, there is already lua module code to translate the heading to a code (e.g. "French" to "fr"), so giving the full heading text rather than the code is not an issue.

So how difficult would it be to create an {{{H2}}} magic word for Wiktionary?

I've poked around in MediaWiki's parsing functions before but I really haven't touched PHP in a long time. I'm hoping this would be something fairly easy though and would be worth implementing for its potential to hugely simplify Wiktionary wikitext for its editors.

101.160.40.121 (talkcontribs)
Pengo (talkcontribs)

Thanks. The variables extension looks like a good solution. It also looks like it is not currently installed.

I imagine it would do the trick if this were installed and then before every heading it was added like:

{{#vardefine:lang|French}}
 ==French==
 ...

The docs say that the variable should then be available to included templates.

But would it be possible for the page to behave as if the #vardefine was there without actually including it?

101.160.40.121 (talkcontribs)

Use a template?

{{#vardefineecho: lang | {{{1}}} }}
== {{lang sec|French}} ==
Pengo (talkcontribs)

Yeah... That works... Though was hoping to have less impact on the existing style. But I'll try suggesting it to the editors.

Pengo (talkcontribs)

Seems the solution is not at all unpopular. (Wiktionary discussion) Thanks again, ip-address-ending-in-121.

Reply to "Wiktionary: How possible would it be to create a Magic Word which gives the most recent L2 heading"