Difference between revisions of "Module:Distinguish"

From blackwiki
Jump to navigation Jump to search
blackwiki>Galobtter
(fixed with text and selfref)
test>Shirayuki
(prepare for translation)
Line 1: Line 1:
local mHatnote = require('Module:Hatnote')
+
<noinclude>
local mHatlist = require('Module:Hatnote list')
+
<languages/>
local mArguments --initialize lazily
+
</noinclude>{{#switch:<translate></translate>
local mTableTools --initialize lazily
+
| =
local libraryUtil = require('libraryUtil')
+
{{Hatnote|1=<translate>Not to be confused with <tvar|1>[[:{{{1}}}]]</></translate>{{
local checkType = libraryUtil.checkType
+
    #if: {{{3|}}}{{{4|}}}
local p = {}
+
    | , [[:{{{2}}}]], {{
 
+
      #if: {{{4|}}}
function p.distinguish(frame)
+
      | [[:{{{3}}}]], or [[:{{{4}}}]]
mArguments = require('Module:Arguments')
+
      | or [[:{{{3}}}]]
mTableTools = require('Module:TableTools')
+
    }}
local args = mArguments.getArgs(frame)
+
    | {{
local selfref = args.selfref
+
      #if: {{{2|}}}
local text = args.text
+
      | &nbsp;or [[:{{{2}}}]]
args = mTableTools.compressSparseArray(args)
+
    }}
return p._distinguish(args, text, selfref)
+
  }}.}}
end
+
| #default=
 
+
  {{#invoke:Template translation|renderTranslatedTemplate|template=Template:Distinguish|noshift=1}}
function p._distinguish(args, text, selfref)
+
}}<noinclude><!-- splitting these lines causes {{Documentation}} template to terminate green shading when Distinguish is used in /doc pages. -->
checkType("_distinguish", 1, args, 'table')
+
{{Documentation}}
if #args == 0 and not text then return '' end
+
<!-- Add categories to the /doc subpage and interwikis to Wikidata, not here! -->
local text = string.format(
+
</noinclude>
'Not to be confused with %s.',
 
text or mHatlist.orList(args, true)
 
)
 
hnOptions = {selfref = selfref}
 
return mHatnote._hatnote(text, hnOptions)
 
end
 
 
 
return p
 

Revision as of 10:45, 12 December 2018


50px Module documentation[view] [edit] [history] [purge]

Implements {{distinguish}}.