Wikipedia talk:Lua: Difference between revisions
Ricordisamoa (talk | contribs) |
|||
Line 1: | Line 1: | ||
{{WikiProject Lua |
{{WikiProject Lua header|sc1=WT:LUA}} |
||
{{central|text=all [[Special:PrefixIndex/Wikipedia talk:Lua/|Wikipedia:Lua subpages' talk pages]] and [[Help talk:Lua]] redirect here.}} |
|||
{{merged-from|Wikipedia:Lua/Requests|5 February 2016|talk=no|target=Wikipedia talk:Lua}} |
|||
{{Old MfD|date=21 May 2015|page=Wikipedia:Lua/To do|altpage=Wikipedia:Lua/To do|result='''keep'''}} |
|||
{{archive box |
|||
|search=yes |
|||
|bot=ClueBot III |
|||
|1={{flatlist}} |
|||
Current archives: |
|||
{{User:ClueBot III/ArchiveThis |
{{User:ClueBot III/ArchiveThis |
||
|archiveprefix=Wikipedia talk:Lua/Archive |
|archiveprefix=Wikipedia talk:Lua/Archive |
||
|format= %%i |
|format= %%i |
||
|age=2160 |
|age=2160 |
||
|archivebox=no |
|||
|index=yes |
|index=yes |
||
|maxarchsize=150000 |
|maxarchsize=150000 |
||
|archivebox=yes |
|||
|box-advert=yes |
|||
|minkeepthreads=1 |
|minkeepthreads=1 |
||
}} |
|||
Requests archives: |
|||
* [[Wikipedia:Lua/Requests/Archive 1|1]] |
|||
* [[Wikipedia:Lua/Requests/Archive 2|2]] |
|||
* [[Wikipedia:Lua/Requests/Archive 3|3]] |
|||
* [[Wikipedia:Lua/Requests/Archive 4|4]] |
|||
* [[Wikipedia:Lua/Requests/Archive 5|5]] |
|||
Other: |
|||
* [[Wikipedia talk:Lua/Requests/Archive 1|Requests discussion]] |
|||
* [[Wikipedia talk:Lua/To do/Archive 1|To do discussion]] |
|||
{{endflatlist}} |
|||
}} |
}} |
||
== Legislationuk / Legislationlistuk == |
|||
== [[Module:Fake object]] == |
|||
If you ever find yourself doing testing with title objects, you might be interested in [[Module:Fake object]]. It puts a metatable wrapper round another object and allows you to overwrite its fields without generating errors. I'm using it in [[Module:Protection banner/testcases]], where it is saving me from having to find actual pages with the namespaces and protection levels I need, and from having to fix the test cases when someone changes a protection level somewhere. Also, if anyone can see any ways to improve it, suggestions would be very welcome. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 02:57, 17 July 2014 (UTC) |
|||
:{{ping|Mr. Stradivarius}} What does that module let you do that rawset doesn't? [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 03:01, 17 July 2014 (UTC) |
|||
::Now that's a good question. I can't think of anything - it looks like I just wrote that module for nothing. And if you use rawset, methods using a check self function still work. Well, it was good practice at writing metamethods, at least... — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 03:08, 17 July 2014 (UTC) |
|||
:::I've gone ahead and deleted the module, as rawset seems to be generally superior. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 23:40, 18 July 2014 (UTC) |
|||
== mw.log output is now visible == |
|||
A change was deployed a few hours ago that makes mw.log output from pages visible. It will now show up in the parser profiling data when previewing. To see a useful example of this, look at the log output of one of the pages in [[:Category:Location maps with possible errors]] - it will contain details about the problem that caused the page to be placed in the tracking category. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 01:18, 18 July 2014 (UTC) |
|||
:That's very useful, thanks. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 01:34, 18 July 2014 (UTC) |
|||
:I tried this; it is indeed useful. (For the uninitiated, you ''don't'' actually need to enable scripts to use this, but you ''do'' have to preview the page with the error on it) Though tracking and fixing these errors is still no picnic... [[User:Wnt|Wnt]] ([[User talk:Wnt|talk]]) 19:43, 18 July 2014 (UTC) |
|||
== mw.math library error checking == |
|||
Would anyone mind taking a look at [[gerrit:143678]]? We're in the process of adding a mw.math library to Scribunto to fill in the gaps from Lua's standard math library, but [[User:Jackmcbarn|Jackmcbarn]] and I are disagreeing over whether to add type checking or not. The argument for type checking is that it will make debugging easier and that the other Scribunto libraries do it; and the argument against is that type checking would make it impossible to use mw.math to do advanced things involving metatables, etc. I don't want this disagreement to hold up the deployment of mw.math altogether, so some outside opinions would be very welcome. You can comment here if you want, or you can comment over at Gerrit if you [//wikitech.wikimedia.org/enwiki/w/index.php?title=Special:UserLogin&type=signup make yourself a Wikitech account]. We also need more reviewers in general, so feel free to look at the other submissions in the [https://gerrit.wikimedia.org/r/#/projects/mediawiki/extensions/Scribunto,dashboards/default:open open changes queue]. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 06:22, 19 July 2014 (UTC) |
|||
:I haven't looked at this nearly hard enough to settle anything, but just thinking out loud: I see there's a suggestion to require at least one argument, but the unit tests list ideas like sum() = 0, product() = 1. I think there's some merit to having convenient behavior for the empty set, especially if it can be passed in as a table. Question: is there going to be a conflict if you're using custom numbers (tables with metatables) and you also accept that a table as the first argument indicates that the fields of the table are the arguments? I'm thinking that you could differentiate between the two if you check whether a metatable exists in that case, but it seems a bit odd. [[User:Wnt|Wnt]] ([[User talk:Wnt|talk]]) 11:58, 19 July 2014 (UTC) |
|||
::Indeed, that is an issue. As the code is written now, the solution is that if you use tables-with-metatables-as-numbers, then you have to use the table form of the function call as well. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 14:50, 19 July 2014 (UTC) |
|||
:::Hmmmm... personally I'm not a great fan of almost-but-not-quite synonyms. If there's not a way to make a(x,y,z) precisely equal to a{x,y,z}, would it be better just to have the second way? [[User:Wnt|Wnt]] ([[User talk:Wnt|talk]]) 20:43, 19 July 2014 (UTC) |
|||
::::That was my original idea. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 02:14, 20 July 2014 (UTC) |
|||
FYI, the general pattern for a{x,y,z} = a(x,y,z) is: |
|||
<syntaxhighlight lang="lua"> |
|||
function a(x, y, z) |
|||
if type(x) == "table" then |
|||
x, y, z = unpack(x) |
|||
end |
|||
end |
|||
</syntaxhighlight> |
|||
--<span style="font: bold 10pt 'courier new', comic, sans, ms;">[[User:Darklama|<font color="midnightblue">dark</font>]][[User_talk:Darklama|<font color="green">lama</font>]]</span> 15:15, 25 July 2014 (UTC) |
|||
:That's a nice trick, but I think the idea behind passing a table was to avoid the overhead of unpacking a table (on the assumption that the caller already had the numbers to be summed in a table). My opinion is that library functions should behave like Lua does, and a{x,y,z} means a({x,y,z}), so the table should not be unpacked as if that were standard behavior. If that were wanted, have a separate function to sum values in a table. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 00:37, 26 July 2014 (UTC) |
|||
== Let's get rid of the Lua/todo page == |
|||
About [[Wikipedia:Lua/To do]]. It has little activity. And rightly so: we at wikipedia do not list one another jobs 'to do'. There is very little activity since its creation on [https://en.wikipedia.org/enwiki/w/index.php?title=Wikipedia%3ALua%2FTo_do&action=history November 2013]. Also, and relevant to wiki, there is the danger of mis-communication: editors talking on page A, while on page B the same issue proceeds. (Links may be preserved). |
|||
For these two reasons, I propose to delete: [[Wikipedia:Lua/To do]]. -[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 01:40, 23 July 2014 (UTC) |
|||
:I suppose as its creator I would say this, but I think it has a useful role to play in identifying templates that need to be converted. I admit that it hasn't had a very high level of activity, but that doesn't mean that it isn't serving its purpose. I've removed a couple of stale entries, but the others are all tasks that still need doing. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 03:04, 23 July 2014 (UTC) |
|||
::After [[WT:Lua]] and [[WP:Lua/Request]] this is a third (fourth, ...) ''coordiantion'' place. That means sooner of later, but surely, information & communications will be lost. A Todo list could be in top of the Lua talkpage? -[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 19:42, 16 August 2014 (UTC) |
|||
== How to use template parameter names as Lua variables. == |
|||
For example, in a template: <code>{{#invoke:Sandbox|function|{{{1|}}}|{{{2|}}}|...|{{{42|}}}|...}}</code>, I need to define each template parameters one by one. Is there any way I just need to define template as "<code>{{#invoke:Sandbox|function|{{{1}}}}}}</code>", input "<tt>a|b|...</tt>" just as a normal template, then Lua recognize "<tt>1=</tt>" "<tt>2=</tt>" ... also as variables?--[[User:JamesQQ5|JamesQQ5]] ([[User talk:JamesQQ5|talk]]) 06:07, 7 August 2014 (UTC) |
|||
{{od|1}}Yes, that's easy. |
|||
<syntaxhighlight lang=Lua> |
|||
local pframe = frame:getParent() |
|||
local config = frame.args -- arguments from the template definition |
|||
local args = pframe.args -- arguments from the page calling the template |
|||
</syntaxhighlight> |
|||
If a page contains <code><nowiki>{{example|abc|def}}</nowiki></code> and Template:Example contains <code><nowiki>{{#invoke:example|main|hello}}</nowiki></code>, and after the above code, <code>config[1]</code> is 'hello' and <code>args[1]</code> is 'abc' while <code>args[2]</code> is 'def'. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 06:27, 7 August 2014 (UTC) |
|||
: Wow, I successed as you said, thanks for your help!--[[User:JamesQQ5|JamesQQ5]] ([[User talk:JamesQQ5|talk]]) 16:08, 7 August 2014 (UTC) |
|||
== Detect call context == |
|||
Sorry if already answered or way too obvious. Are there ways and what is the best (if there are) to detect the call context? |
|||
Say for Module:B with function doB() to detect if it is |
|||
* called sraight from a wiki-page like <nowiki>{{#invoke:B|doB}}</nowiki> |
|||
* called from a template like <nowiki>{{doB}}</nowiki> from where <nowiki>{{#invoke:B|doB}}</nowiki> |
|||
* called from Template:doB specifically and not from any other template |
|||
* called from another module using require() in that module |
|||
* called from Module:A using require() in that module and not from any other module |
|||
If possible at all I am not expecting all answers, a common general hint would be great as well. --[[User:Neolexx|NeoLexx]] ([[User talk:Neolexx|talk]]) 14:45, 21 August 2014 (UTC) |
|||
:{{ping|Neolexx}} That question sort of reminds me of the [http://mywiki.wooledge.org/XyProblem X-Y problem]. What are you doing that needs to know the call context? The one use case I can think of is to allow arguments to be passed in different ways, but using [[Module:Arguments]] is a much better solution for that than attempting to write context-sensitive functions. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 21:09, 21 August 2014 (UTC) |
|||
:Neolexx: I think for some of these things you can just use : local parent = frame:getParent(frame) |
|||
And then get the parent's name as a string using : parent:getTitle() |
|||
For other cases (such as if the module is being invoked from a template which is within an article page, and you want to know the article page), you'd need to get the 'grandparent', which doesn't seem to work. If I try the following code, 'parent' and 'grandparent' are always the same no matter the circumstances: |
|||
local parent = frame:getParent(frame) |
|||
local grandparent = frame:getParent(parent) |
|||
But maybe I'm doing something wrong. Hopefully one of the more experienced editors can show us how to get the grandparent. |
|||
[[User:BigGreenCahuna|BigGreenCahuna]] ([[User talk:BigGreenCahuna|talk]]) 22:43, 21 August 2014 (UTC) |
|||
:You currently can't get the grandparent. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 23:12, 21 August 2014 (UTC) |
|||
::Is there any other way to get the page that's using the template which is invoking a module? I can think of a lot of uses for this, such as allowing the template to automagically add some customization based on the page, without the need to tediously add a new argument on every single page that already uses the template. [[User:BigGreenCahuna|BigGreenCahuna]] ([[User talk:BigGreenCahuna|talk]]) 23:20, 21 August 2014 (UTC) |
|||
:::You can get the "root" page with mw.title.getCurrentTitle(), but if you have A -> Template:B -> Template:C -> Template:D -> Module:E, you'll get A. There's no way to get Template:B or Template:C. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 23:51, 21 August 2014 (UTC) |
|||
* Thank you all for answering, and it may indeed help to explain my reasons. It is helpful(?) to keep an OP-like paradigm with small modules to do one exact task each but doing it right - rather than having all-in-one. And then depending on the task to collect needed sets by require() chains. The problem is that even small fully internal (by its purpose) module might be seem useful for someone's purpose as it is: straight from the page or from its own template. And things gets sometimes populated very quickly on wiki. So a month later one adjusts that module and suddently crashes thousands of pages around (s)he had no idea about. There are real cases I would like to not enumerate right now. |
|||
: So instead of different spooky DON'T USE DIRECTLY or ONLY WITHIN... on the module page I was thinking of some more programmatical way of doing things. Like in Javascript we don't write PLEASE DO NOT CALL THIS CONSTRUCTOR AS A FUNCTION, there is <code>this</code> for this. Similarly I was thinking to distinguish a correct call context (from a given template or from a given parent module) from an incorrect one (straight from the page or as a stay-alone module). --[[User:Neolexx|NeoLexx]] ([[User talk:Neolexx|talk]]) 09:54, 22 August 2014 (UTC) |
|||
::Doing that would be a bad idea. If you only want code to get called from one particular module, put the code in that module as a local function. Don't put it elsewhere and then try to detect what the caller is. Don't let "good" OOP trick you into writing bad code. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 15:27, 22 August 2014 (UTC) |
|||
::: We may have very different ideas about "good" and good programming patterns. But I do respect your opinion and thank you for answering. --[[User:Neolexx|NeoLexx]] ([[User talk:Neolexx|talk]]) 09:00, 23 August 2014 (UTC) |
|||
::Although it won't prevent someone from using your helper modules if they choose to ignore your documentation, you can make them subpages of your main module. This way you can document your main module as providing the external interface to templates or other modules, and all subpages below being conceptually private. [[User:Isaacl|isaacl]] ([[User talk:Isaacl|talk]]) 22:16, 1 September 2014 (UTC) |
|||
== HtmlBuilder == |
|||
See [[#mw.html library nil behaviour]]. Many modules still use the HtmlBuilder instead of the <code>mw.html</code> library. Once they are converted on this wiki, many other projects will benefit from them. --<span style="font-variant:small-caps">[[User:Ricordisamoa|<span style="color:#004B70">Ricordi</span>]][[User talk:Ricordisamoa|<span style="color:#00703E">samoa</span>]]</span> 06:05, 1 September 2014 (UTC) |
|||
== Bug in mw.language.fetchLanguageName()? == |
|||
[[Module:Citation/CS1]] supports [[ISO639-1]] language codes in its {{para|language}} parameter. It currently does this with a table of codes and names that is in [[Module:Citation/CS1/Configuration]]. Earlier this year I did a quick experiment with <code>mw.language.fetchLanguageName()</code> that showed me that it might be possible to replace the translation table with calls <code>mw.language.fetchLanguageName()</code> |
|||
Just getting around to more complete experiments. It appears that <code>mw.language.fetchLanguageName()</code> is producing incorrect results for the ISO639-1 code for the Norwegian language, no. This simple citation uses the sandbox version of [[Module:Citation/CS1]] (should produce Norwegian): |
|||
:<code><nowiki>{{cite book/new |title=Norwegian |language=no}}</nowiki></code> |
|||
:{{cite book/new |title=Norwegian |language=no}} – see [http://www-01.sil.org/iso639-3/documentation.asp?id=nor code no] |
|||
ISO639-1 code km should produce Central Khmer |
|||
:<code><nowiki>{{cite book/new |title=Central Khmer |language=km}}</nowiki></code> |
|||
:{{cite book/new |title=Central Khmer |language=km}} – see [http://www-01.sil.org/iso639-3/documentation.asp?id=khm code km] |
|||
ISO639-1 code to should produce Tonga (Tonga Island) |
|||
:<code><nowiki>{{cite book/new |title=Tonga (Tonga Island) |language=to}}</nowiki></code> |
|||
:{{cite book/new |title=Tonga (Tonga Island) |language=to}} – see [http://www-01.sil.org/iso639-3/documentation.asp?id=ton code to] |
|||
I presume, not having read the standard, that when there is more than one approved language name for a specific code, the first listed name would be the preferred name. There are several codes where this is the case: dv, ii, ki, kl, and os. |
|||
How to get this fixed? |
|||
—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 23:45, 1 September 2014 (UTC) |
|||
:{{ping|Trappist the monk}} To clarify, exactly what parameters are you passing to mw.language.fetchLanguageName()? Are you passing 'no' as the first one and omitting the second one? Also, exactly what output do you expect, and what output do you get? [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 00:08, 2 September 2014 (UTC) |
|||
::<source lang="lua">local name = mw.language.fetchLanguageName( Language:lower(), "en" );</source> where Language is the value assigned to CS1 parameter {{para|language}}. So, in this case {{para|language|no}} |
|||
::When the citation is rendered, it should contain (in Norwegian). |
|||
:::{{cite book |title=Norwegian |language=no}} – current live (correct) version of the CS1 module using the table in [[Module:Citation/CS1/Configuration]] |
|||
:::{{cite book/new |title=Norwegian |language=no}} – sandbox (wrong) version of CS1 using <code>mw.language.fetchLanguageName()</code> |
|||
:::{{cite book/new |title=Norwegian |language=nb}} – sandbox with code nb produces correct response |
|||
::I think that I expect each of the two-character ISO639-1 codes to produce the preferred (first listed?) language name according to the [http://www.loc.gov/standards/iso639-2/php/code_list.php Library of Congress]. |
|||
::Related? {{tlc|#language:no|en}} produces {{#language:no|en}} which is the same wrong language name produced in the Norwegian language test above, and {{tlc|#language:km|en}} produces {{#language:km|en}} and {{tlc|#language:to|en}} produces {{#language:to|en}}, also both wrong according to LOC. More evidence that these issues are related: {{tlc|#language:nb|en}} produces {{#language:nb|en}} which is correct and the same as the <code>mw.language.fetchLanguageName()</code> result above. |
|||
::Have I answered your questions? |
|||
::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 00:56, 2 September 2014 (UTC) |
|||
:::{{ping|Trappist the monk}} Almost. You're saying that <code><syntaxhighlight lang="lua" enclose="none">mw.language.fetchLanguageName( 'no', 'en' )</syntaxhighlight></code> produces <code>Norwegian (bokmål)</code>. Do you want it to produce <code>Norwegian</code> or <code>Norwegian Bokmål</code>? [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 01:03, 2 September 2014 (UTC) |
|||
::::Yes, I am saying that <code><syntaxhighlight lang="lua" enclose="none">mw.language.fetchLanguageName( 'no', 'en' )</syntaxhighlight></code> produces <code>Norwegian (bokmål)</code> and I am saying that it is the wrong language name for code <code>no</code>. The correct language name and the one that I'm looking for is <code>Norwegian</code> because that is the language name associated with <code>no</code> in the [http://www.loc.gov/standards/iso639-2/php/code_list.php list of codes] at the Library of Congress website. |
|||
::::I am most concerned with <code>no</code> because it is most clearly wrong but it would be nice, barring any reasons unknown to me, if we could make sure that for all of the ISO639-1 two-character codes, <code>mw.language.fetchLanguageName()</code> (and {{tlc|#language:}} for that matter) returns the preferred name. |
|||
::::More clear? |
|||
::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 01:25, 2 September 2014 (UTC) |
|||
:::::{{ping|Trappist the monk}} I've figured it out. [[:mw:Extension:CLDR]] has a specific override in place for that language, which you can see at [https://git.wikimedia.org/blob/mediawiki%2Fextensions%2Fcldr/2f9a0b26b2c69caeca9fcf0e08eacc1f1356a2d0/LocalNames%2FLocalNamesEn.php#L365]. It was added by {{u|Siebrand}} in [[:mw:Special:Code/MediaWiki/31280]]. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 01:37, 2 September 2014 (UTC) |
|||
::::::Thanks for that. I'll drop a line to {{u|Siebrand}}. |
|||
::::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 10:05, 2 September 2014 (UTC) |
|||
I guess it's not relevant here, but searching [[List of Wikipedias]] for "Norwegian" shows "Norwegian (Bokmål)" for '''no'''wiki and "Norwegian (Nynorsk)" for '''nn'''wiki (see [[Norwegian Wikipedia]]), so adding "(Bokmål)" is done in other places. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 04:33, 2 September 2014 (UTC) |
|||
:[[List of Wikipedias]] doesn't use <code>mw.language.fetchLanguageName()</code> or {{tlc|#language:}}. There are three Norwegian language ISO639-1 codes: <code>no</code>, <code>nb</code>, and <code>nn</code>. <code>no</code> is the 'non-specific' or generic code that includes both <code>nb</code> and <code>nn</code>. <code>mw.language.fetchLanguageName()</code> produces correct results when <code>nb</code> and <code>nn</code> are specified: |
|||
::{{cite book/new |title=Norwegian Bokmål|language=nb}} |
|||
::{{cite book/new |title=Norwegian Nynorsk|language=nn}} |
|||
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 10:05, 2 September 2014 (UTC) |
|||
::Sure, but the point I was making is that for whatever reason, "Norwegian (Bokmål)" is associated with "no" in more places than mw.language. Another example is Wikidata which uses nowiki as can be seen at [[:d:Q14033926]]. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 10:53, 2 September 2014 (UTC) |
|||
:::Understood. I don't know how that wikidata page got its language name but its form (norsk bokmål) is different from either <code><nowiki>{{#language:no|en}}</nowiki></code> → {{#language:no|en}} or <code><nowiki>{{#language:nb|en}}</nowiki></code> → {{#language:nb|en}} which implies that it was not taken from [[:mw:Extension:CLDR]]. |
|||
:::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 11:37, 2 September 2014 (UTC) |
|||
::::{{ping|Trappist the monk}} That would be from {{tlf|#language:no}} (or the basically-equivalent {{tlf|#language:no|no}}), which yields {{#language:no}}. Wikidata displays languages in themselves. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 12:39, 2 September 2014 (UTC) |
|||
:::::It occurred to me to wonder in my message to {{u|Siebrand}} how <code>no</code>, <code>nb</code>, and <code>nn</code> are handled when Dutch (<code>nl</code>) is the specified output language: |
|||
:::::*{{#language:no|nl}} → {{#language:no|nl}} |
|||
:::::*{{#language:nb|nl}} → {{#language:nb|nl}} |
|||
:::::*{{#language:nn|nl}} → {{#language:nn|nl}} |
|||
:::::You can see that we get the correct results. It's the same if you do the experiment specifying other common language codes for the output language, for example <code>de</code>, <code>es</code>, <code>fr</code>, <code>it</code>, <code>ru</code>, and even <code>yi</code> all produce output equivalent to <code>Norwegian</code>, <code>Norwegian Bokmål</code> and <code>Norwegian Nynorsk</code>. This is the limit of my current experimentation but it seems that output for <code>no</code> with output language specified as code <code>en</code> and code <code>no</code> are wrong, or at the least completely inconsistent with output for other output language specifiers. |
|||
:::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:41, 2 September 2014 (UTC) |
|||
While the [[mw:Language code|language codes]] used by methods such as <code>mw.language.fetchLanguageName()</code> are similar to [[IETF language tag]]s (which draw from ISO 639 codes, among other sources), not all MediaWiki language codes are valid IETF tags or vice versa. See [[mw:Extension:Scribunto/Lua reference manual#Language library]] for more. [[User:Anomie|Anomie]][[User talk:Anomie|⚔]] 11:50, 2 September 2014 (UTC) |
|||
:From this: |
|||
::[[mw:Language code|language codes]]: "...(mostly in accordance with ISO 639-3, except two-letter codes from ISO 639-1 for "established" locales)..." |
|||
:can I infer that the two-letter language code <code>no</code> should be in compliance with ISO639-1? See [http://www-01.sil.org/iso639-3/documentation.asp?id=nor code no]. |
|||
:RFC 5646, interestingly enough, specifically mentions <code>no</code>, <code>nb</code>, and <code>nn</code> as Norwegian, Norwegian Bokmal, and Norwegian Nynorsk respectively. From [http://www.iana.org/assignments/language-subtag-registry IANA language subtag registry] (oft mentioned in RFC 5646) this for code <code>no</code>: |
|||
::<code> |
|||
::%%<br /> |
|||
::Type: language<br /> |
|||
::Subtag: no<br /> |
|||
::Description: Norwegian<br /> |
|||
::Added: 2005-10-16<br /> |
|||
::Suppress-Script: Latn<br /> |
|||
::Scope: macrolanguage<br /> |
|||
::%%</code> |
|||
:All of this suggests to me that <code>mw.language.fetchLanguageName()</code> and <code>{{#language:}}</code> should not be returning <code>Norwegian (Bokmål)</code>, <code>Norwegian Bokmål</code>, or <code>norsk bokmål</code> when the input is specified as code <code>no</code> regardless of output language code. |
|||
:Am I missing something? |
|||
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:41, 2 September 2014 (UTC) |
|||
:: Hmm. I see someone added "except two-letter codes from ISO 639-1 for 'established' locales" since last I read through that, which totally changes the meaning of the sentence. At any rate, the issue here is that the English name for MediaWiki language code "no" is currently "Norwegian (bokmål)", and if that should be changed to match ISO 639-1 then it needs to be changed in [[mw:Extension:CLDR]]. [[User:Anomie|Anomie]][[User talk:Anomie|⚔]] 23:20, 2 September 2014 (UTC) |
|||
:::Right. So how do we get that done? |
|||
:::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 10:50, 3 September 2014 (UTC) |
|||
:::: Well, you said you already tried talking to Siebrand. Next step would be to [//bugzilla.wikimedia.org/enter_bug.cgi?format=guided&product=MediaWiki%20extensions&component=CLDR#step2 file a bug], and even [[mw:How to become a MediaWiki hacker|submit a patch]] if you can. [[User:Anomie|Anomie]][[User talk:Anomie|⚔]] 12:56, 3 September 2014 (UTC) |
|||
[[Module:Legislationuk]] is used by [[Template:Legislationuk]] is used by [[Template:Legislationlistuk]] [[List of acts of the Parliament of Northern Ireland]] does not fit into the module there are a couple aspects that I am not sure on how too change |
|||
:::::It's been over a week and no response from {{u|Siebrand}}. Alas, I value my privacy so I'll not be filing any bug reports until bugzilla joins the 21st century. Wikipedia is already too much of a timesink and I fear that if I start making patches it will only become worse. |
|||
The main thing i am struggling with is that the the regnal citations for uk acts last happened in 1962, so that's how it's been set up but the regnal citation for NI acts last happened in 1942. When I say "regnal citation" I mean, "10 & 11 Geo. 5. No. 1" or "14 Geo. 6. c. 1" or "13 & 14 Geo. 5. c. 7 (N.I.)". |
|||
:::::For the time being, I can craft a workaround in [[Module:Citation/CS1]] so that rendered citations display the correct language name when {{para|language|no}} |
|||
The module uses data from [[Module:Legislationuk/data]]. |
|||
:::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:05, 10 September 2014 (UTC) |
|||
The citation happens at line 124, I think. |
|||
:::::: As a Norwegian I can elaborate on this. One problem is that 'Norwegian' ('no') is not a written language, it's only referring to "some variant of Norwegian; either Norwegian Bokmål (nb) or Norwegian Nynorsk (nn)". Historically 'no' has been used for Bokmål, while 'nn' has always been used for Nynorsk, so even today one can generally assume that 'no' means 'Norwegian Bokmål'. But following ISO 639-1 strictly one should not, so the situation is a bit messy. The best solution is generally to deprecate 'no' where possible. We're unfortunately stuck with the 'no' prefix at no.wikipedia.org, but we use 'nb' as our content language. 'no' has also been removed from translatewiki. – ''[[User:Danmichaelo|Danmichaelo]] ([[User talk:Danmichaelo|talk]])'' 20:12, 14 September 2014 (UTC) |
|||
The pseudocode for the idea I am trying to implement is something like changing ``year > 1962`` to ``year > 1962 or (year > 1942 and jurisdiction = "northern ireland")``. [[User:DotCoder|DotCoder]] ([[User talk:DotCoder|talk]]) 00:57, 20 September 2024 (UTC) |
|||
== Function names containing equals signs == |
|||
:Mainly I just don't know how to adjust the module in the correct way to apply the citation system it uses for the NI acts properly. [[User:DotCoder|DotCoder]] ([[User talk:DotCoder|talk]]) 00:59, 20 September 2024 (UTC) |
|||
In [[WT:Lua/Archive 2#Metatables will now work on export tables]], {{u|Wnt}} pointed out that a function name containing an equals sign would cause later arguments to be misnumbered. I've submitted [[gerrit:158890]] to fix this problem, which is now merged. Beginning September 18th, we'll have the ability to use the function name as a "free" parameter that users can use without worrying about escaping equals signs in it, which isn't currently doable in any other way. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 19:46, 6 September 2014 (UTC) |
|||
: |
|||
: I don't like the sound of that "'free' parameter" idea. That sounds like it'll be confusing. [[User:Anomie|Anomie]][[User talk:Anomie|⚔]] 00:47, 9 September 2014 (UTC) |
|||
:Sorry, I'm not going anywhere near that mess. The author(s) couldn't be bothered to document the code (shame. shame. shame.), couldn't be bothered to use meaningful variable names, couldn't be bothered to organize all of that text in a data module. |
|||
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 14:40, 20 September 2024 (UTC) |
|||
::If it were documented, I wouldn't be asking for help. [[User:DotCoder|DotCoder]] ([[User talk:DotCoder|talk]]) 16:01, 20 September 2024 (UTC) |
|||
== Colours for dark mode == |
|||
::Why not just forbid the equal sign in function names? [[User talk:Chillum|<b style="vertical-align:20%;text-shadow:0px 0px 4px Black;font-size:60%;color:OrangeRed">Chillum</b>]] 00:52, 9 September 2014 (UTC) |
|||
:::It has its uses, even if it's confusing. (Just like half of the parser's other obscure features, like msgnw and the reverse pipe trick, to name a few). Also, it's exactly the same as any other positional parameter now, just like all other parser functions (except #switch, sort of) take. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 00:56, 9 September 2014 (UTC) |
|||
A module sets colours for table headings by using colour names such as 'white', 'black' or hex values for text, background and cell border. This is fine for normal skins but how should it be coded to say "use the inverse colour in dark mode"? Dark mode is picking up the names and using those as absolute, where I think what I want it to say is "unless colour is specified use skin defaults for text and background" (the default for border is 'none' so that's not a problem). [[User:Nthep|Nthep]] ([[User talk:Nthep|talk]]) 15:47, 28 October 2024 (UTC) |
|||
== Proposal to disable "Allow saving code with errors" == |
|||
:Isn't styling something that could be / should be done with template styles css? |
|||
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 16:17, 28 October 2024 (UTC) |
|||
::if i understood template styles, quite possibly. [[User:Nthep|Nthep]] ([[User talk:Nthep|talk]]) 16:29, 28 October 2024 (UTC) |
|||
:This probably should have been asked on [[WP:VPT]] since it has nothing to do with modules. |
|||
:[[mw:Recommendations for night mode compatibility on Wikimedia wikis]] are the official recommendations from WMF about how to deal with dark mode consideration. The relevant section is [[mw:Recommendations_for_night_mode_compatibility_on_Wikimedia_wikis#Avoid_static_values_for_inline_background_and_text_colors|this one]]. |
|||
:You can probably be assisted further by providing a specific template/module of interest where you are trying to be dark-mode conscious. [[User:Izno|Izno]] ([[User talk:Izno|talk]]) 17:59, 28 October 2024 (UTC) |
|||
::And I gather this is about [[Module:Rugby league match squad]]. While you can do something of the "if this isn't defined, use the basic colors", you still need to cover your bases when it is defined. Basically you have these options in that case: |
|||
::# Remove custom color support with its obvious downside. Branding is not that important, and that's almost exclusively the reason that a module like this uses color. |
|||
::# Apply [https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/hue-rotate hue-rotate] using a TemplateStyles sheet. This will result in the branding color being incorrect but the table will be dark rather than light. |
|||
::# Forcibly override any colors inserted using TemplateStyles and <code>!important</code> while in dark mode. Anything using !important is usually considered to be [[technical debt]], but at least your table is dark. |
|||
::# Live with light mode colors for both light and dark. Which preserves the branding information but makes someone using dark mode have to put goggles on. :) |
|||
::That's it. That's the story. You won't get everything you want all in one nice package. :( [[User:Izno|Izno]] ([[User talk:Izno|talk]]) 18:08, 28 October 2024 (UTC) |
|||
:::@[[User:Izno|Izno]] thanks. I'd go for #1 but as I seem to be in a minority about colours among rugby editors, I can see it being reverted. I'll see what I can work out about template styles (have to say that what there is on the subject here and on media wiki isn't very helpful) and look at #3. [[User:Nthep|Nthep]] ([[User talk:Nthep|talk]]) 09:03, 29 October 2024 (UTC) |
|||
:::@[[User:Izno|Izno]] Thanks again. I managed to adapt [[ Module:Rugby league match squad/sandbox]] and it's calling template to use TemplateStyles ({{tl|Rugby league match squad/sandbox/styles.css}} which seems to work ok on my sandbox [https://en.m.wikipedia.org/enwiki/w/index.php?title=User:Nthep/sandbox3]. |
|||
:::I'm conscious that the module isn't the greatest piece of coding and is at serious risk of becoming an unitelligible mish-mash of code and styling. I see that TemplateStyles can be called from a module using <code>frame:extensionTag</code> ([[mw:Help:TemplateStyles#How_can_Lua_modules_interact_with_styles?]]) and my thought is could all the styling could all be pulled out into TemplateStyles using <code>function p.templateStyle( frame, src )</code>? [[User:Nthep|Nthep]] ([[User talk:Nthep|talk]]) 21:23, 5 November 2024 (UTC) |
|||
::::You can do something like this at the very end of <code>main()</code>: |
|||
:::::<syntaxhighlight lang="lua">return table.concat ({ |
|||
frame:extensionTag ('templatestyles', '', {src='Rugby league match squad/sandbox/styles.css'}), |
|||
return_t |
|||
});</syntaxhighlight> |
|||
::::—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 22:25, 5 November 2024 (UTC) |
|||
::::Yes, I would recommend placing the styles all in the sheet, at least those which can be. The above is the function call version, barring that I moved the TemplateStyles page just now. The object call version of it looks like <syntaxhighlight lang=lua>frame:extensionTag { name = 'templatestyles', args = {src='Module:Rugby league match squad/sandbox/styles.css'}}</syntaxhighlight> (which I prefer since it names the arguments to <code>extensionTag</code>). I normally just concatenate it like your general string, but of course you may need tostring the return item depending on what you're concatenating e.g. <syntaxhighlight lang=lua>local templatestyles = above_bit return templatestyles .. return_t</syntaxhighlight> [[User:Izno|Izno]] ([[User talk:Izno|talk]]) 22:45, 5 November 2024 (UTC) |
|||
:::::Thank you both for the replies, I will have a mess around and see where I get to. Doubtless I will be back with more questions. [[User:Nthep|Nthep]] ([[User talk:Nthep|talk]]) 10:52, 6 November 2024 (UTC) |
|||
== Request == |
|||
The "Allow saving code with errors" lets users save code even if it contains a syntax error that would prevent it from working anywhere. The reason that this feature was added was to let users of some wiki (not sure which) more easily save work-in-progress code. I've never had to use this checkbox, and as far as I know, no other Lua scripter here has either. Every time I've seen it used here, it was someone who didn't understand Lua screwing something up. Since it's easy enough to save WIP code by simply commenting it out, I propose that we disable that checkbox here. Are there any objections? [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 21:12, 8 September 2014 (UTC) |
|||
:Yes I object. Didn't even know it existed, but I could have used it many times, e.g., when I wanted to save the page for the night, & more tomorrow. If commenting out for a single line would solve it, that would be great but that is not to be expected. Are there any damages known from saving bad code modules? -[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 20:41, 27 September 2014 (UTC) |
|||
::Yes, there's damage. Clueless users have a way of finding modules with a good number of transclusions (but not enough to protect) and breaking them. Also, I talked to Tim about this, and he suggested that rather than even make it a config option, to just remove it altogether. (And the fact that you didn't know it existed shows how useful it is to legitimate users.) By the way, if you have multiple lines in progress, putting --[=[ at the beginning of your code and ]=] at the end will make a multiline comment and comment it all out. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 20:44, 27 September 2014 (UTC) |
|||
::''(And the fact that you didn't know it existed shows how useful it is to legitimate users.)'' Bull shit. It caused ''me'' damage. And for logic, I wouldn't trust you programming for me. |
|||
::Who's Tim? Anyway, if Holy Tim says so, why did you ask it here in the first place? You already decided the outcome. -[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 20:52, 27 September 2014 (UTC) |
|||
:::Tim is {{noping|Tim Starling}}. I asked here in the first place because my original idea was to make having the checkbox be a config option, which we'd turn off here, but if we remove it altogether from the software, then it's not a config change anymore and doesn't need local consensus anymore. Also, I fail to see how a feature that you didn't know about, and only does anything if you know about it, caused damage to you, and why the fact that something caused damage to you is a reason to keep it. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 21:50, 27 September 2014 (UTC) |
|||
:While serious coders should not generally check the box, removing it wouldn't prevent anyone from damaging modules by causing a runtime error. --<span style="font-variant:small-caps">[[User:Ricordisamoa|<span style="color:#004B70">Ricordi</span>]][[User talk:Ricordisamoa|<span style="color:#00703E">samoa</span>]]</span> 03:32, 17 October 2014 (UTC) |
|||
Please help me in creating a page Module:Sandbox/பொதுஉதவி. |
|||
== Detecting when the edit link goes to a redirect page == |
|||
[[User:பொதுஉதவி|பொதுஉதவி]] ([[User talk:பொதுஉதவி|talk]]) 05:48, 1 November 2024 (UTC) |
|||
:I've gone ahead and made the page at [[Module:Sandbox/பொதுஉதவி]]. I assume the title blacklist was the only issue? [[User:Aidan9382|Aidan9382]] <sub>([[User talk:Aidan9382|talk]])</sub> 08:33, 1 November 2024 (UTC) |
|||
== Using #invoke in mainspace, as an alternative to templates == |
|||
would it be possible to track [//en.wikipedia.org/enwiki/w/index.php?title=Template%3AInternational_volleyball&diff=628650765&oldid=628558991 this problem]? either through checking to see if 'name' matches the template name, or by checking to see if the value of 'name' is a redirect page. I am guessing that the first one isn't possible, since it requires going to a grand child ('module:navbox' → 'template:navbox' → 'template:international volleyball')? and, that checking to see if 'the value used for name is a redirect' is expensive? [[User:Frietjes|Frietjes]] ([[User talk:Frietjes|talk]]) 13:56, 9 October 2014 (UTC) |
|||
:The proper fix for that problem is to make navbox templates call [[Module:Navbox]] directly, since the name parameter is unnecessary when doing so. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 14:33, 9 October 2014 (UTC) |
|||
:{{ec}} {{ping|Frietjes}} Your first option isn't possible with the current way the templates are set up, as Scribunto can't access grandparent frames. (Note that in Lua-speak [[Module:Navbox]] is the grandchild and [[Template:International volleyball]] is the grandparent.) So we can tell that we are being called by [[Template:Navbox]], but we can't go any higher than that. However, you could do it if you used <code><nowiki>{{#invoke:Navbox|main|...}}</nowiki></code> directly on [[Template:International volleyball]], as then it would be the parent, not the grandparent. In fact, if you did that you could just get rid of the name parameter altogether, as Lua would always return the correct name. Your second option is also possible, and you're right that it is expensive. You need to make a title object for that page and then the isRedirect property of the title object will tell you whether or not it's a redirect (see the manual [[mw:Extension:Scribunto/Lua reference manual#Title objects|here]]). It's the making of the title object that is the expensive part, so you can call mw.title.new with [[mw:Extension:Scribunto/Lua reference manual#pcall|pcall]] if you have to avoid script errors (probably a good idea on [[Module:Navbox]]). — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 14:43, 9 October 2014 (UTC) |
|||
I've come across [[List of common misconceptions]], which uses <code><nowiki>{{#invoke:cite web|}}</nowiki></code> instead of using {{tl|cite web}} (and other CS1 templates) directly. Is this a good idea, or discouraged? --<span style="text-shadow:grey 0.15em 0.15em 0.1em">[[User:Yodin|Yodin]]</span><span style="text-shadow:grey 0.25em 0.25em 0.12em"><sup>[[User talk:Yodin|T]]</sup></span> 18:15, 17 November 2024 (UTC) |
|||
== Cleaning up [[:Category:Pages with script errors]] == |
|||
: It's a necessary evil when working with huge articles that would otherwise exceed the [[WP:PEIS|post-expand include size]]. Otherwise it's discouraged. [[User:Pppery|* Pppery *]] [[User talk:Pppery|<sub style="color:#800000">it has begun...</sub>]] 18:18, 17 November 2024 (UTC) |
|||
== Output unreadable with "2-ary truth table" template == |
|||
I found myself browsing [[:Category:Pages with script errors]] earlier today, and I noticed it was full of sandboxes and talk archives that are distracting from the pages that really need fixing. However, when I started clearing the category out, [[User:Anomie|Anomie]] [https://en.wikipedia.org/enwiki/w/index.php?title=User:Anomie/Sandbox6&oldid=prev&diff=629855329 pointed out] that I shouldn't just go editing other people's sandboxes. He's probably right. So, how can we find the script errors that need attention without getting distracted by test pages? Off the top of my head, I have two ideas: 1) add a new category for script errors in the main namespace only, and 2) add a category for script errors that filters pages by regex to exclude "/sandbox" and "/Archive n" etc. Do these sound like good suggestions? Or perhaps someone has a better one? — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 15:34, 16 October 2014 (UTC) |
|||
:I'd say categorize by mainspace. Subpage name patterns are more volatile, and require more maintenance thinking. ([[WP:FLOW]] will change any talkspace beyond recognition). Mainspace script errors are the only ones you want to check (cat space, wp space, ...?). -[[User:DePiep|DePiep]] ([[User talk:DePiep|talk]]) 16:05, 16 October 2014 (UTC) |
|||
{{ec}} |
|||
:I support this. But, it would seem to me that it would be beneficial to construct a category set from the top down. For example: |
|||
::Category:Lua |
|||
:::Category:Lua errors |
|||
::::Category:Lua errors in ''namespace'' |
|||
::::Category:Lua errors in ''namespace'' |
|||
::::... |
|||
::::Category:Lua errors in ''namespace'' |
|||
:::Category:Lua ... |
|||
[[File:"2-ary truth table" template produces hard to read text.png|thumb|The template uses Lua whose output is unreadable with Wikipedia's "Vector (2022)" dark mode skin.]] |
|||
:And no Category:Pages with ... titles. We all know that categories contain pages, files, and other categories. It seems pointless to me to state that in the category title. Yeah, personal peeve. |
|||
As you can see, [[Template:2-ary_truth_table]] uses Lua whose output is unreadable with Wikipedia's "Vector (2022)" dark mode skin. [[User:Chai T. Rex|Chai T. Rex]] ([[User talk:Chai T. Rex|talk]]) 07:39, 26 November 2024 (UTC) |
|||
:I'm not sure that I see much need categorize errors the User namespace, or in /sandbox, /testcases, and /archive subpages. Perhaps none of the various talk namespaces should be categorized either. Probably no need to categorize pages in Module:Sandbox. |
|||
:@[[User:Chai T. Rex|Chai T. Rex]] It already has a [[Wikipedia:TemplateStyles]] stylesheet, [[:Template:2-ary truth table/style.css]], so it's a question of editing that to include some dark mode options. Is it just the text colour in the third column that's the issue? [[User:Nthep|Nthep]] ([[User talk:Nthep|talk]]) 13:38, 26 November 2024 (UTC) |
|||
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 16:29, 16 October 2014 (UTC) |
|||
::Yes, the third column is unreadable. [[User:Chai T. Rex|Chai T. Rex]] ([[User talk:Chai T. Rex|talk]]) 21:06, 26 November 2024 (UTC) |
|||
I haven't been paying attention—what magic is putting pages in the category? I agree with Trappist's remarks about there being no need for "Pages with" and no need to have a sandboxes et al in a tracking category. I frequently patrol [[:Category:Convert error categories]] and it's much better now that the convert module only outputs a tracking category for articles—there were too many false alarms even on template pages. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 00:37, 17 October 2014 (UTC) |
|||
:::If there is no further help here, ask at [[WP:VPT]] what is needed in that css page. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 01:32, 27 November 2024 (UTC) |
|||
:I wouldn't like to see this category split up. I especially find it useful to see errors in sandboxes, talk pages, etc., as that allows me to spot errors in modules before they become a big problem. Note that it's already possible to filter by namespace if you want. For example, [https://en.wikipedia.org/enwiki/w/api.php?action=query&list=categorymembers&cmtitle=Category%3APages%20with%20script%20errors&cmprop=title&cmlimit=500&cmnamespace=0] will show you just articles that have errors. Also, to help clean out the category, I often look at [https://en.wikipedia.org/enwiki/w/api.php?action=query&list=categorymembers&cmtitle=Category%3APages%20with%20script%20errors&cmprop=title|timestamp&cmlimit=500&cmsort=timestamp&cmdir=desc] which shows me the newest errors first. [[User:Jackmcbarn|Jackmcbarn]] ([[User talk:Jackmcbarn|talk]]) 03:23, 17 October 2014 (UTC) |
|||
:Fixed. [[User:Izno|Izno]] ([[User talk:Izno|talk]]) 02:23, 27 November 2024 (UTC) |
Latest revision as of 02:23, 27 November 2024
To help centralize discussions and keep related topics together, all Wikipedia:Lua subpages' talk pages and Help talk:Lua redirect here. |
The contents of the Wikipedia:Lua/Requests page were merged into Wikipedia talk:Lua on 5 February 2016. For the contribution history and old versions of the redirected page, please see its history. |
Wikipedia:Lua/To do was nominated for deletion on 21 May 2015. The result of the discussion was keep. |
This page has archives. Sections older than 90 days may be automatically archived by ClueBot III when more than 1 section is present. |
Legislationuk / Legislationlistuk
[edit]Module:Legislationuk is used by Template:Legislationuk is used by Template:Legislationlistuk List of acts of the Parliament of Northern Ireland does not fit into the module there are a couple aspects that I am not sure on how too change
The main thing i am struggling with is that the the regnal citations for uk acts last happened in 1962, so that's how it's been set up but the regnal citation for NI acts last happened in 1942. When I say "regnal citation" I mean, "10 & 11 Geo. 5. No. 1" or "14 Geo. 6. c. 1" or "13 & 14 Geo. 5. c. 7 (N.I.)".
The module uses data from Module:Legislationuk/data.
The citation happens at line 124, I think.
The pseudocode for the idea I am trying to implement is something like changing ``year > 1962`` to ``year > 1962 or (year > 1942 and jurisdiction = "northern ireland")``. DotCoder (talk) 00:57, 20 September 2024 (UTC)
- Mainly I just don't know how to adjust the module in the correct way to apply the citation system it uses for the NI acts properly. DotCoder (talk) 00:59, 20 September 2024 (UTC)
- Sorry, I'm not going anywhere near that mess. The author(s) couldn't be bothered to document the code (shame. shame. shame.), couldn't be bothered to use meaningful variable names, couldn't be bothered to organize all of that text in a data module.
- —Trappist the monk (talk) 14:40, 20 September 2024 (UTC)
- If it were documented, I wouldn't be asking for help. DotCoder (talk) 16:01, 20 September 2024 (UTC)
Colours for dark mode
[edit]A module sets colours for table headings by using colour names such as 'white', 'black' or hex values for text, background and cell border. This is fine for normal skins but how should it be coded to say "use the inverse colour in dark mode"? Dark mode is picking up the names and using those as absolute, where I think what I want it to say is "unless colour is specified use skin defaults for text and background" (the default for border is 'none' so that's not a problem). Nthep (talk) 15:47, 28 October 2024 (UTC)
- Isn't styling something that could be / should be done with template styles css?
- —Trappist the monk (talk) 16:17, 28 October 2024 (UTC)
- if i understood template styles, quite possibly. Nthep (talk) 16:29, 28 October 2024 (UTC)
- This probably should have been asked on WP:VPT since it has nothing to do with modules.
- mw:Recommendations for night mode compatibility on Wikimedia wikis are the official recommendations from WMF about how to deal with dark mode consideration. The relevant section is this one.
- You can probably be assisted further by providing a specific template/module of interest where you are trying to be dark-mode conscious. Izno (talk) 17:59, 28 October 2024 (UTC)
- And I gather this is about Module:Rugby league match squad. While you can do something of the "if this isn't defined, use the basic colors", you still need to cover your bases when it is defined. Basically you have these options in that case:
- Remove custom color support with its obvious downside. Branding is not that important, and that's almost exclusively the reason that a module like this uses color.
- Apply hue-rotate using a TemplateStyles sheet. This will result in the branding color being incorrect but the table will be dark rather than light.
- Forcibly override any colors inserted using TemplateStyles and
!important
while in dark mode. Anything using !important is usually considered to be technical debt, but at least your table is dark. - Live with light mode colors for both light and dark. Which preserves the branding information but makes someone using dark mode have to put goggles on. :)
- That's it. That's the story. You won't get everything you want all in one nice package. :( Izno (talk) 18:08, 28 October 2024 (UTC)
- @Izno thanks. I'd go for #1 but as I seem to be in a minority about colours among rugby editors, I can see it being reverted. I'll see what I can work out about template styles (have to say that what there is on the subject here and on media wiki isn't very helpful) and look at #3. Nthep (talk) 09:03, 29 October 2024 (UTC)
- @Izno Thanks again. I managed to adapt Module:Rugby league match squad/sandbox and it's calling template to use TemplateStyles ({{Rugby league match squad/sandbox/styles.css}} which seems to work ok on my sandbox [1].
- I'm conscious that the module isn't the greatest piece of coding and is at serious risk of becoming an unitelligible mish-mash of code and styling. I see that TemplateStyles can be called from a module using
frame:extensionTag
(mw:Help:TemplateStyles#How_can_Lua_modules_interact_with_styles?) and my thought is could all the styling could all be pulled out into TemplateStyles usingfunction p.templateStyle( frame, src )
? Nthep (talk) 21:23, 5 November 2024 (UTC)- You can do something like this at the very end of
main()
:return table.concat ({ frame:extensionTag ('templatestyles', '', {src='Rugby league match squad/sandbox/styles.css'}), return_t });
- —Trappist the monk (talk) 22:25, 5 November 2024 (UTC)
- Yes, I would recommend placing the styles all in the sheet, at least those which can be. The above is the function call version, barring that I moved the TemplateStyles page just now. The object call version of it looks like (which I prefer since it names the arguments to
frame:extensionTag { name = 'templatestyles', args = {src='Module:Rugby league match squad/sandbox/styles.css'}}
extensionTag
). I normally just concatenate it like your general string, but of course you may need tostring the return item depending on what you're concatenating e.g.Izno (talk) 22:45, 5 November 2024 (UTC)local templatestyles = above_bit return templatestyles .. return_t
- Thank you both for the replies, I will have a mess around and see where I get to. Doubtless I will be back with more questions. Nthep (talk) 10:52, 6 November 2024 (UTC)
- You can do something like this at the very end of
- And I gather this is about Module:Rugby league match squad. While you can do something of the "if this isn't defined, use the basic colors", you still need to cover your bases when it is defined. Basically you have these options in that case:
Request
[edit]Please help me in creating a page Module:Sandbox/பொதுஉதவி. பொதுஉதவி (talk) 05:48, 1 November 2024 (UTC)
- I've gone ahead and made the page at Module:Sandbox/பொதுஉதவி. I assume the title blacklist was the only issue? Aidan9382 (talk) 08:33, 1 November 2024 (UTC)
Using #invoke in mainspace, as an alternative to templates
[edit]I've come across List of common misconceptions, which uses {{#invoke:cite web|}}
instead of using {{cite web}} (and other CS1 templates) directly. Is this a good idea, or discouraged? --YodinT 18:15, 17 November 2024 (UTC)
- It's a necessary evil when working with huge articles that would otherwise exceed the post-expand include size. Otherwise it's discouraged. * Pppery * it has begun... 18:18, 17 November 2024 (UTC)
Output unreadable with "2-ary truth table" template
[edit]As you can see, Template:2-ary_truth_table uses Lua whose output is unreadable with Wikipedia's "Vector (2022)" dark mode skin. Chai T. Rex (talk) 07:39, 26 November 2024 (UTC)
- @Chai T. Rex It already has a Wikipedia:TemplateStyles stylesheet, Template:2-ary truth table/style.css, so it's a question of editing that to include some dark mode options. Is it just the text colour in the third column that's the issue? Nthep (talk) 13:38, 26 November 2024 (UTC)
- Yes, the third column is unreadable. Chai T. Rex (talk) 21:06, 26 November 2024 (UTC)
- If there is no further help here, ask at WP:VPT what is needed in that css page. Johnuniq (talk) 01:32, 27 November 2024 (UTC)
- Yes, the third column is unreadable. Chai T. Rex (talk) 21:06, 26 November 2024 (UTC)
- Fixed. Izno (talk) 02:23, 27 November 2024 (UTC)