https://de.wikipedia.org/w/index.php?action=history&feed=atom&title=Modul%3ATemplUtl%2F01 Modul:TemplUtl/01 - Versionsgeschichte 2025-06-23T03:55:52Z Versionsgeschichte dieser Seite in Wikipedia MediaWiki 1.45.0-wmf.6 https://de.wikipedia.org/w/index.php?title=Modul:TemplUtl/01&diff=198308168&oldid=prev PerfektesChaos: 2019-12-03 2020-03-31T11:43:43Z <p>2019-12-03</p> <p><b>Neue Seite</b></p><div>local TemplUtl = { suite = &quot;TemplUtl&quot;,<br /> serial = &quot;2019-12-03&quot;,<br /> sub = &quot;01&quot;,<br /> commons = &quot;i18n/01&quot;,<br /> main = 52364930 }<br /> --[=[<br /> Auxilary table generation,<br /> showing strings for boolean values in all known languages.<br /> ]=]<br /> local Failsafe = TemplUtl<br /> <br /> <br /> <br /> local fetch = function ()<br /> -- Retrieve specifications from commons:Data:****.tab<br /> -- Postcondition:<br /> -- Returns<br /> -- 1. table, sequence, with data<br /> -- 2. table, with maximum colspan, as number<br /> local storage = string.format( &quot;%s.tab&quot;, TemplUtl.commons )<br /> local lucky, data = pcall( mw.ext.data.get, storage, &quot;_&quot; )<br /> local r1 = { }<br /> local r2 = { [false] = 0,<br /> [true] = 0 }<br /> if type( data ) == &quot;table&quot; and<br /> type( data.data ) == &quot;table&quot; then<br /> local o = { }<br /> local t = { }<br /> local e, l, s, w<br /> data = data.data<br /> for i = 1, #data do<br /> e = data[ i ]<br /> if type( e ) == &quot;table&quot; and<br /> type( e[ 1 ] ) == &quot;boolean&quot; and<br /> type( e[ 2 ] ) == &quot;table&quot; then<br /> l = e[ 1 ]<br /> e = e[ 2 ]<br /> for k, v in pairs( e ) do<br /> if type( k ) == &quot;string&quot; and<br /> type( v ) == &quot;string&quot; then<br /> w = mw.text.split( v, &quot;|&quot; )<br /> if #w &gt; r2[ l ] then<br /> r2[ l ] = #w<br /> end<br /> table.insert( o, k )<br /> if not t[ k ] then<br /> t[ k ] = { }<br /> end<br /> t[ k ][ l ] = w<br /> end<br /> end -- for k, v<br /> else<br /> break -- for i<br /> end<br /> end -- for i<br /> table.sort( o )<br /> for i = 1, #o do<br /> s = o[ i ]<br /> e = t[ s ]<br /> if e then<br /> w = { s = s }<br /> if type( e[ false ] ) == &quot;table&quot; then<br /> w[ false ] = e[ false ]<br /> end<br /> if type( e[ true ] ) == &quot;table&quot; then<br /> w[ true ] = e[ true ]<br /> end<br /> table.insert( r1, w )<br /> t[ s ] = false<br /> end<br /> end -- for i<br /> end<br /> return r1, r2<br /> end -- fetch()<br /> <br /> <br /> <br /> local fiat = function ( apply, align, at, around )<br /> -- Create table row<br /> -- Precondition:<br /> -- apply -- table, with data<br /> -- align -- table, with maximum colspan<br /> -- at -- string, with project language code<br /> -- around -- string, with wrapping scripting direction<br /> -- Postcondition:<br /> -- Returns mw.html.TR object<br /> local r = mw.html.create( &quot;tr&quot; )<br /> local e = mw.html.create( &quot;code&quot; )<br /> :attr( &quot;lang&quot;, &quot;zxx&quot; )<br /> :wikitext( apply.s )<br /> local scripting<br /> local fk = function ( a, attr )<br /> local td = mw.html.create( &quot;td&quot; )<br /> :attr( &quot;lang&quot;, a )<br /> if attr and attr ~= around then<br /> td:attr( &quot;dir&quot;, attr )<br /> end<br /> td:wikitext( mw.language.fetchLanguageName( apply.s,<br /> a ) )<br /> return td<br /> end -- fk()<br /> local fv = function ( a )<br /> local v = apply[ a ]<br /> r:newline()<br /> if v then<br /> local k = align[ a ] - #v<br /> for i = 1, #v do<br /> e = mw.html.create( &quot;td&quot; )<br /> :attr( &quot;lang&quot;, apply.s )<br /> :wikitext( v[ i ] )<br /> if scripting ~= around then<br /> e:attr( &quot;dir&quot;, scripting )<br /> end<br /> r:node( e )<br /> end -- for i<br /> if k &gt; 0 then<br /> e = mw.html.create( &quot;td&quot; )<br /> if k &gt; 1 then<br /> e:attr( &quot;colspan&quot;, tostring( k ) )<br /> end<br /> r:node( e )<br /> end<br /> else<br /> r:node( mw.html.create( &quot;td&quot; )<br /> :attr( &quot;colspan&quot;,<br /> tostring( align[ a ] ) ) )<br /> end<br /> end -- fv()<br /> if mw.language.new( apply.s ):isRTL() then<br /> scripting = &quot;rtl&quot;<br /> else<br /> scripting = &quot;ltr&quot;<br /> end<br /> if around == &quot;rtl&quot; then<br /> e:attr( &quot;dir&quot;, &quot;ltr&quot; )<br /> end<br /> r:newline()<br /> :node( mw.html.create( &quot;td&quot; )<br /> :node( e ) )<br /> :newline()<br /> :node( fk( &quot;en&quot;, &quot;ltr&quot; ) )<br /> :newline()<br /> :node( fk( apply.s, scripting ) )<br /> if at ~= &quot;en&quot; then<br /> r:newline()<br /> :node( fk( at ) )<br /> end<br /> fv( false )<br /> fv( true )<br /> return r<br /> end -- fiat()<br /> <br /> <br /> <br /> TemplUtl.f = function ( alien )<br /> -- Create table<br /> -- Precondition:<br /> -- alien -- string, with language code, or not<br /> -- Postcondition:<br /> -- Returns string with entire HTML table<br /> local tbl = mw.html.create( &quot;table&quot; )<br /> :addClass( &quot;wikitable sortable&quot; )<br /> :addClass( &quot;TemplUtl-table-01&quot; )<br /> local tr = mw.html.create( &quot;tr&quot; )<br /> local rows, cols = fetch()<br /> local scripting, slang, speak<br /> if type( alien ) == &quot;string&quot; and<br /> mw.language.isSupportedLanguage( alien ) then<br /> slang = mw.text.trim( alien )<br /> else<br /> local sub = mw.title.getCurrentTitle().subpageText<br /> if sub:find( &quot;%l%l%l?%-?%a?%a?%a?%a?$&quot; ) and<br /> mw.language.isSupportedLanguage( sub ) then<br /> slang = sub<br /> end<br /> if not slang then<br /> slang = mw.language.getContentLanguage():getCode()<br /> end<br /> end<br /> slang = slang:lower()<br /> speak = mw.language.fetchLanguageName( slang )<br /> tbl:attr( &quot;lang&quot;, slang )<br /> if mw.language.new( slang ):isRTL() then<br /> scripting = &quot;rtl&quot;<br /> else<br /> scripting = &quot;ltr&quot;<br /> end<br /> tbl:attr( &quot;dir&quot;, scripting )<br /> tr:newline()<br /> :node( mw.html.create( &quot;th&quot; )<br /> :wikitext( &quot;ISO&amp;nbsp;639 / BCP47&quot; ) )<br /> :newline()<br /> :node( mw.html.create( &quot;th&quot; )<br /> :wikitext( &quot;English&quot; ) )<br /> :newline()<br /> :node( mw.html.create( &quot;th&quot; )<br /> :wikitext( &quot;*&quot; ) )<br /> :newline()<br /> if slang ~=&quot;en&quot; then<br /> tr:node( mw.html.create( &quot;th&quot; )<br /> :attr( &quot;lang&quot;, slang )<br /> :wikitext( speak ) )<br /> :newline()<br /> end<br /> tr:node( mw.html.create( &quot;th&quot; )<br /> :attr( &quot;colspan&quot;, tostring( cols[ false ] ) )<br /> :wikitext( &quot;0&quot; ) )<br /> :newline()<br /> :node( mw.html.create( &quot;th&quot; )<br /> :attr( &quot;colspan&quot;, tostring( cols[ true ] ) )<br /> :wikitext( &quot;1&quot; ) )<br /> tbl:newline()<br /> -- :node( mw.html.create( &quot;thead&quot; )<br /> :node( tr )<br /> -- )<br /> for i = 1, #rows do<br /> tbl:newline()<br /> :node( fiat( rows[ i ], cols, slang, scripting ) )<br /> end -- for i<br /> return tostring( tbl:newline() )<br /> end -- TemplUtl.f()<br /> <br /> <br /> <br /> -- Export<br /> local p = { }<br /> <br /> function p.f( frame )<br /> return TemplUtl.f( frame.args.lang )<br /> end -- p.f<br /> <br /> return p</div> PerfektesChaos