Content deleted Content added
→Call from other Lua module: Reply |
|||
(11 intermediate revisions by 5 users not shown) | |||
Line 37:
:::{{ping|Repakr}} That page has dozens of templates and I'm not going to take the time to play with it. If you post a simple test case at [[:uk:User talk:Johnuniq]] I'll have a look although it might not be for a day or two. In the test, point out what is wrong and what it should display. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 09:24, 14 September 2024 (UTC)
::::@[[User:Johnuniq|Johnuniq]], I am sorry, I didn't catch the meaning first time reading it. So, I added a test to your talk page. [[User:Repakr|Repakr]] ([[User talk:Repakr|talk]]) 09:30, 14 September 2024 (UTC)
:::::{{ping|Repakr}} I'm looking at function <code>variable_name</code> in [[:uk:Module:Convert/пісочниця]] and wondering what <code>exp_multiplier</code> is and why the function is so different from my ten-year old code. I'll have to leave it at the moment but will look again in a day or two. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 10:40, 14 September 2024 (UTC)
::::::@[[User:Johnuniq|Johnuniq]], the function is different because Ukrainian uses a different declension than Polish. Ukrainian also has three field declension (metry, metriv, metra) as Polish, but declension differs based on numbers. It works like this singular form is used if the number is 1 or its combination with tens (except 11; like 21, 31), hundreds (like 101, 121, etc.), thousands, and so on; form metry is used if the number is 2, 3, 4 or its combination with tens (except 12, 13, 14; like 22, 32), hundreds (like 102, 122, etc.), thousands and so on; metriv is used if the number is 0 or higher than 4 (it includes 11, 12, 13, 14) or its combination with tens (like 24, 35), hundreds (like 104, 125, etc.), thousands and so on. Form metra is used for both 1/2 and 1.2 fractions. So for me, it was easier to rewrite a code using a function built in MediaWiki that chose the correct form for Ukrainian.
::::::<code>exp_multiplier</code> stands for expotential multiplier and it stores the value of <code>eng_scales</code>, so the text of <code>eng_scales</code> can be also declened based on forms of numbers, like milion, miliony, milioniv, miliona.
::::::Although I did the modification, I tried without those modifications and a bug was present. [[User:Repakr|Repakr]] ([[User talk:Repakr|talk]]) 13:12, 14 September 2024 (UTC)
Testing on this problem is at [[:uk:User:Johnuniq/convert]] with discussion at [[:uk:User talk:Johnuniq/convert]]. The bug seems to have been present since the original <code>varname</code> used for certain languages was developed more than ten years ago. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 11:05, 15 September 2024 (UTC)
== Call from other Lua module ==
There currently doesn't seem to be an easy way to call this module from another Lua module. I made a small change to the sandbox code [[Special:Diff/1252830342/1303398379|here]] that works well in my tests, and if there are no objections I can implement it in the main module. <span class="nowrap">--[[User:Ahecht|Ahecht]] ([[User talk:Ahecht|<b style="color:#FFF;background:#04A;display:inline-block;padding:1px;vertical-align:middle;font:bold 50%/1 sans-serif;text-align:center">TALK<br />PAGE</b>]])</span> 19:02, 30 July 2025 (UTC)
:Doesn't the 'standard' naming style (if there is one) use an underscore-prefixed function name for functions called from an external module as a way to distinguish those functions from template-called function names? So instead of <code>do_convert</code> it would be <code>_main_convert</code>? That seems to be in keeping with [[Module:Convert]]'s use of an underscore prefix for the helper function <code>_unit</code> which is called from another module.
:—[[User:Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) 19:19, 30 July 2025 (UTC)
::@[[User:Trappist the monk|Trappist the monk]] Makes sense, I've updated the sandbox. <span class="nowrap">--[[User:Ahecht|Ahecht]] ([[User talk:Ahecht|<b style="color:#FFF;background:#04A;display:inline-block;padding:1px;vertical-align:middle;font:bold 50%/1 sans-serif;text-align:center">TALK<br />PAGE</b>]])</span> 19:23, 30 July 2025 (UTC)
:::The sandbox code looks good to me. I put a test at [[Module:Sandbox/Johnuniq/temp]] with result at [[Module talk:Sandbox/Johnuniq/temp|talk]]. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 04:25, 31 July 2025 (UTC)
::::{{done}} <span class="nowrap">--[[User:Ahecht|Ahecht]] ([[User talk:Ahecht|<b style="color:#FFF;background:#04A;display:inline-block;padding:1px;vertical-align:middle;font:bold 50%/1 sans-serif;text-align:center">TALK<br />PAGE</b>]])</span> 21:03, 31 July 2025 (UTC)
|