Content deleted Content added
m Archiving 3 discussions |
→Protected edit request on 21 September 2023: new section |
||
Line 42:
::: This isn't quite what you were asking, but related enough you might be interested in it: {{tl|Conditional heading}}. [[User:Mathglot|Mathglot]] ([[User talk:Mathglot|talk]]) 04:50, 12 July 2023 (UTC)
::::Thanks, @[[User:Mathglot|Mathglot]]. I want to remove the headings rather than to promote or demote them, so it's not what I need in this case. But it's good to know about this, for future refrence. [[User:BrownHairedGirl|<span style="font-variant:small-caps"><span style="color:#663200;">Brown</span>HairedGirl</span>]] <small>[[User talk:BrownHairedGirl|(talk)]] • ([[Special:Contributions/BrownHairedGirl|contribs]])</small> 23:11, 12 July 2023 (UTC)
== Protected edit request on 21 September 2023 ==
{{edit fully-protected|Module:String|answered=no}}
On Latin Wikipedia I have created a tiny module [[:la:Module:Translitteratio|Module:Translitteratio]], which contains a single function named <code>abecedaria</code>. The function accepts three parameters and works exactly like the <code>[https://www.gnu.org/software/m4/manual/html_node/Translit.html translit]</code> M4 macro (but with the order of arguments changed to chars, replacement, string).
'''Manuscript:'''
<syntaxhighlight lang="wikitext" inline>{{#invoke:translitteratio|abecedaria|aeiou|äëì|Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam mollis, metus ac volutpat auctor, sem ligula interdum nulla, ac pellentesque nibh erat sed nisi. Integer nec auctor orci. Quisque nibh metus, viverra et viverra nec, laoreet in mi. Integer aliquet, mauris vitae tristique fringilla, ante odio ultrices quam, et fermentum orci purus nec lorem. Integer quis vehicula arcu, et laoreet enim. Nulla euismod neque velit, eget iaculis massa tempor ut. Nulla convallis maximus neque et porttitor. In nunc eros, convallis id posuere ac, egestas et arcu. Aenean faucibus sollicitudin ipsum, in condimentum mauris maximus in. Etiam facilisis eros vel tortor tincidunt iaculis. Vestibulum lorem lectus, posuere sed enim in, varius pharetra lorem. Morbi nisl lacus, eleifend ut urna vitae, interdum consequat ipsum. Cras ut imperdiet ante. Sed quis luctus purus, quis porta erat. Ut gravida gravida augue a euismod.}}</syntaxhighlight>
'''Effect:'''
: Lrëm ìpsm dlr sìt ämët, cnsëctëtr ädìpìscìng ëlìt. Näm mllìs, mëts äc vltpät äctr, sëm lìglä ìntërdm nllä, äc pëllëntësqë nìbh ërät sëd nìsì. Intëgër nëc äctr rcì. Qìsqë nìbh mëts, vìvërrä ët vìvërrä nëc, lärëët ìn mì. Intëgër älìqët, märìs vìtäë trìstìqë frìngìllä, äntë dì ltrìcës qäm, ët fërmëntm rcì prs nëc lrëm. Intëgër qìs vëhìclä ärc, ët lärëët ënìm. Nllä ëìsmd nëqë vëlìt, ëgët ìäclìs mässä tëmpr t. Nllä cnvällìs mäxìms nëqë ët prttìtr. In nnc ërs, cnvällìs ìd psërë äc, ëgëstäs ët ärc. Aënëän fäcìbs sllìcìtdìn ìpsm, ìn cndìmëntm märìs mäxìms ìn. Etìäm fäcìlìsìs ërs vël trtr tìncìdnt ìäclìs. Vëstìblm lrëm lëcts, psërë sëd ënìm ìn, värìs phärëträ lrëm. Mrbì nìsl läcs, ëlëìfënd t rnä vìtäë, ìntërdm cnsëqät ìpsm. Cräs t ìmpërdìët äntë. Sëd qìs lcts prs, qìs prtä ërät. Ut grävìdä grävìdä ägë ä ëìsmd.
This module allowed to write the {{[[:la:Formula:Sine notis diacriticis|la:Sine notis diacriticis]]}} template, which transforms vowels with various accents into simple vowels.
I think that Module:String would benefit from this function, with its name changed from <code>abecedaria</code> to <code>translit</code>.
Translated into English, the code to add to this module would be:
<syntaxhighlight lang="lua">str.translit = function( frame )
local args = frame.args
if args[1] == nil or args[1] == '' or args[3] == nil or args[3] == '' then
return ''
end
local npairs
local text = mw.text.split(args[3], '', true)
local removenda = mw.text.split(args[1], '', true)
local substituenda
if args[2] ~= nil then
substituenda = mw.text.split(args[2], '', true)
else
substituenda = {}
end
if #removenda > #substituenda then
npairs = #substituenda
else
npairs = #removenda
end
for idx1 = 1, npairs do
for idx2 = 1, #text do
if text[idx2] == removenda[idx1] then
text[idx2] = substituenda[idx1]
end
end
end
for idx1 = npairs + 1, #removenda do
for idx2 = 1, #text do
if text[idx2] == removenda[idx1] then
table.remove(text, idx2)
end
end
end
return table.concat(text)
end
return str</syntaxhighlight> [[User:Grufo|Grufo]] ([[User talk:Grufo|talk]]) 17:40, 21 September 2023 (UTC)
|