Module talk:Convert: Difference between revisions

Content deleted Content added
(46 intermediate revisions by 12 users not shown)
Line 1:
{{notice|heading=<big>Please use [[Template talk:Convert]] to discuss units or any other feature related to {{tl|convert}}.</big>|<big>This page is for discussion about the internal operation of the modules, or their use on other Wikipedias.</big>}}
{{archives|search=yes|prefixsearchprefix=Module talk:Convert/Archive}}
{{User:ClueBot III/ArchiveThis
|archiveprefix=Module talk:Convert/Archive
|format= %%i
|age=720
<!-- |index=yes -->
<!-- |archivebox=yes -->
|box-advert=yes
|minkeepthreads=3
|maxarchsize=100000
}}
{{archives|search=yes|prefix=Module talk:Convert/Archive}}
{{Lua sidebar}}
== Fully-protected edit request on 10 February 2020 ==
{{edit fully-protected|Module:Convert/testcases|answered=yes}}
Change content model to Wikitext and redirect to [[Template:Convert/testcases#Sandbox_testcases]] (the current page just says "see this other page", a purpose which would be better served by a redirect). [[User:Pppery|* Pppery *]] [[User talk:Pppery|<sub style="color:#800000">it has begun...</sub>]] 20:46, 10 February 2020 (UTC)
:Done, thanks. [[Module:Convert/testcases]] changed. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 00:35, 11 February 2020 (UTC)
 
== Error on Tewiki for a testcase ==
== Positional parameters ==
 
While most [[Te:మూస:Convert|test cases on Tewiki]] are successful, {convert|2|and|5|km|mi|sigfig=3|abbr=off}} gives → '''Lua error in మాడ్యూల్:Convert at line 1850: attempt to index local 'en_value' (a nil value).''' Need help to fix this. [[User:Arjunaraoc|Arjunaraoc]] ([[User talk:Arjunaraoc|talk]]) 04:38, 17 August 2022 (UTC)
It would be good that ths module template can use positional parameters (as <nowiki>{{{1}}}</nowiki>) from another warpping template. --[[User:BoldLuis|BoldLuis]] ([[User talk:BoldLuis|talk]]) 18:52, 8 May 2020 (UTC)
:{{ping|Arjunaraoc}} The reason is that you have the most recent [[Module:Convert]] but an old [[Module:Convert/text]]. Several other things would also fail, for example fractions. Try this at tewiki (it won't work):
:*<code><nowiki>{{convert|1+2/3|ft|in}}</nowiki></code> → {{convert|1+2/3|ft|in}}
:I'll do some editing possibly in a few hours or possibly in a day or two. Wait for me to contact you again before proceeding. Feel free to remind me if 48 hours passes and it looks like I've forgotten. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 05:32, 17 August 2022 (UTC)
:{{ping|Arjunaraoc}} I was able to update [[:te:Module:Convert/text]] sooner than expected. That should fix errors due to inconsistency due to differing versions. For your information, I put some notes at [[:te:User:Johnuniq/translate]] in 2015. You might like to review that and let me know if anything is wanted. For example, I was told that <code><nowiki>{{convert|1234567890|m|m}}</nowiki></code> should display 1,23,45,67,890 for the input number. If that is wanted, I have to add more options to Module:Convert/text. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 07:52, 17 August 2022 (UTC)
::@[[User:Johnuniq|Johnuniq]], Thanks for your quick action. The errors have disappeared. I have reviewed the past discussion notes. Many of the usecases are covered. In Tewiki, we use International and Indian number punctuation depending on the units (Ex:million (International), lakhs (Indian, equivalent to 1/10 of million), in articles. So unless we have a way of specifying that, we may not be able to use that. [[User:Arjunaraoc|Arjunaraoc]] ([[User talk:Arjunaraoc|talk]]) 12:36, 22 August 2022 (UTC)
:::There is no option to sometimes use one numeric style and sometimes another so you might have to put up with how it is. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 08:51, 23 August 2022 (UTC)
 
== bnwiki ==
 
Hi, We didn't update bnwiki's [https://bn.wikipedia.org/w/index.php?title=%E0%A6%AE%E0%A6%A1%E0%A6%BF%E0%A6%89%E0%A6%B2:Convert&action=history Module:Convert since 2014]. Can i update it without updating [[:bn:Module:Convert/data]], [[:bn:Module:Convert/text]]? Will it break anything? [[User:আফতাবুজ্জামান|আফতাবুজ্জামান]] ([[User talk:আফতাবুজ্জামান|talk]]) 19:15, 17 December 2023 (UTC)
:@[[User:আফতাবুজ্জামান|আফতাবুজ্জামান]]: Convert and Convert/text must be updated together. The above section describes a problem due to use of a new Convert with an old Convert/text. Convert/data would generally not be a problem and would not need to be updated. I have prepared a new Convert/text for bnwiki but have no idea where to save it. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 03:56, 18 December 2023 (UTC)
::I worked out the ___location of the bnwiki module sandbox and created:
::*[[:bn:Module:খেলাঘর/Johnuniq/Convert]] • Copy from [[Module:Convert]] (I used the wrong edit summary: the comment fix is in the next module).
::*[[:bn:Module:খেলাঘর/Johnuniq/Convert/text]] • Copy from [[Module:Convert/text]] and then edited with the bnwiki translations.
::I think this will work but there are some very significant changes and it would take hours of examination to be confident about that. You might have to try it and see what happens. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 05:31, 18 December 2023 (UTC)
:::In Convert/text, see the two TODO comments that I left for your attention. You will need to also fix the cvt_xxx messages under <code>all_messages</code>. That is because the old convert used <code>%s</code> to identify where substituted parameters need to go, while the new convert uses <code>$1</code> for the first parameter, <code>$2</code> for the second, etc. That should be better but it means every <code>%s</code> needs to be replaced. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 05:47, 18 December 2023 (UTC)
::::@[[User:Johnuniq|Johnuniq]], <nowiki>{{convert|12|cm|disp=or}}</nowiki> is giving "12 centimetres '''('''4.7 inches''')'''" instead of "12 centimetres '''or''' 4.7 inches". Other than that, everything is working as before. Thank you. [[User:আফতাবুজ্জামান|আফতাবুজ্জামান]] ([[User talk:আফতাবুজ্জামান|talk]]) 18:33, 18 December 2023 (UTC)
:::::@[[User:আফতাবুজ্জামান|আফতাবুজ্জামান]]: Try my most recent edit at bnwiki. I wondered why "or" was missing from that table while comparing the enwiki/bnwiki versions. You can change the text on the right-hand side but "or" on the left-hand side must be unchanged. If that doesn't work, you would need to set up sandbox modules and a template that I can experiment with and add links to them maybe on my bnwiki talk so I can find them in the future. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 22:30, 18 December 2023 (UTC)
::::::@[[User:Johnuniq|Johnuniq]], Thanks. [[User:আফতাবুজ্জামান|আফতাবুজ্জামান]] ([[User talk:আফতাবুজ্জামান|talk]]) 22:14, 19 December 2023 (UTC)
 
==Discussion at [[:Wikipedia:Village pump (technical)#Let's make Template:convert go away.|Wikipedia:Village pump (technical) §&nbsp;Let's make Template:convert go away.]]==
[[File:Symbol watching blue lashes high contrast.svg|25px|link=|alt=]]&nbsp;You are invited to join the discussion at [[:Wikipedia:Village pump (technical)#Let's make Template:convert go away.|Wikipedia:Village pump (technical) §&nbsp;Let's make Template:convert go away.]]. –[[User:Novem Linguae|<span style="color:blue">'''Novem Linguae'''</span>]] <small>([[User talk:Novem Linguae|talk]])</small> 07:37, 15 January 2024 (UTC)<!-- [[Template:Please see]] -->
 
== Doubled SI prefix in singular form with varname ==
 
Now I am working on the Ukranian localisation of Module:Convert and I am faced with the bug of doubled SI prefix that appears if parameter varname is used in translation_table. The module uses the singular form of a unit. If the unit uses a plural or declensed singular form defined in parameter varname, then the SI prefix shows as normal. I tried to delete all the modifications that I have done to the module in the Ukranian wiki, and it seems that the bug also appears on a clean version of the English module. Also, it affects only units that have a specified varname, and units that don't work as normal.
For example, unit Mbit shows as megamegabit ({{lang|uk|мегемегабіт}}), and Mm2 shows as megasquare megametre ({{lang|uk|мегаквадратний мегаметр}}). [[User:Repakr|Repakr]] ([[User talk:Repakr|talk]]) 08:42, 14 September 2024 (UTC)
:{{ping|Repakr}} Are you working with the [[:uk:Мodule:Convert]] set of modules or the sandbox modules such as [[:uk:Мodule:Convert/пісочниця]]? Is there a test page showing the problem? Preferably that would be in a sandbox somewhere with almost nothing else so I can easily see what modules are being used and can experiment. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 08:59, 14 September 2024 (UTC)
::@[[User:Johnuniq|Johnuniq]]. I am currently working with the sandbox modules. I haven't created test case for template Convert yet, but there is section in my sandbox: [[uk:Користувач:Repakr/Чернетка#Тестування convert]], where I tested some feature. [[User:Repakr|Repakr]] ([[User talk:Repakr|talk]]) 09:14, 14 September 2024 (UTC)
:::{{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)