Jump to content

Module talk:Val

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Moroboshi (talk | contribs) at 12:49, 13 June 2019 (Localisation: r). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Error in Basque Wikipedia

I have just copied this module and the /units module and I get this error:

Luanda errorea in Modulu:Val at line 267:attempt to call local 'lookup' (a nil value).

You can see live at: eu:Protoi

Well, solved! It called to Module:...." and it should be Modulu:...." as in basque language Wikipedia. -Theklan (talk) 20:17, 13 October 2015 (UTC)[reply]
@Theklan: No, that's not it—there must have been some other issue, perhaps the fact that the page was displayed before all the modules existed and you saw a cached copy of the page that had the error. The system software (MediaWiki) understands a generic name for each namespace as well as the local name. That means "Module:" works on all WMF projects. Here are two examples to demonstrate:
Further confirmation is that if you search Module:Convert for "Module:" you will see that it requires eu:Module:Convert/data (and more)—convert is very complex and it is not as easy to see as in eu:Module:Val, but it is there. If you undo your edit to Module:Val you will see that it still works. Johnuniq (talk) 01:55, 14 October 2015 (UTC)[reply]

Replace warnings with errors

I plan to remove all warnings and replace them with errors as discussed here unless someone can provide a good reason not to. In short: these warnings are often overlooked by editors, which cause the pages in which they are introduced to contain incorrect information until somebody notices and fixes it. Over the past few weeks this has happened about once every two weeks and it can take up to a week for somebody (other than me) to notice and fix it. By replacing these hard-to-notice warnings with clearly visible errors, I expect editors to detect and fix their mistakes themselves almost immediately and prevent Wikipedia from having incorrect information up to half the time. Unfortunately, I have little time at the moment and no working knowledge of LUA, so I cannot commit to a date for this change at this point. If you are able to make this change, I would appreciate if you would go ahead and do so at your earliest convenience. SkyLined (talk) 11:06, 14 February 2018 (UTC)[reply]

I made the change to the module so it will now always show errors. See my new comment at Template talk:Val#Warnings. Johnuniq (talk) 00:24, 15 February 2018 (UTC)[reply]
Thank you! SkyLined (talk) 07:58, 15 February 2018 (UTC)[reply]

Unicode Thin-space

There is a discussion at the Template:val talk page about the width of the space between digit groups. The module currently uses 1/4em but it seems most external sources suggest using 1/5 or 1/6em. I support this change for that reason. I was looking at how I might implement it when I noticed that the module currently uses an empty <span> element with a 0.25em width to add the spaces. This seems overly complex and the code does not provide a reason for this. If I am correct and there is no good reason, I suggest we replace this <span> element with a Unicode &thisp;. SkyLined (talk) 08:16, 7 September 2018 (UTC)[reply]

I replied at Template talk:Val#Thin space—that's the place to discuss what should happen. Johnuniq (talk) 09:45, 7 September 2018 (UTC)[reply]

Localisation

Hello, I would like to importo this module to it.wiki, but currently there are not localization options like for Module:Convert. I could try to move error message and some formatting options (like the decimal separator) to an external module (Module:Val/locale). Do you think this could be useful or they are reasons (performance Ithaquabe?) not to do this?Moroboshi (talk) 07:53, 3 June 2019 (UTC)[reply]

Hi, we talked two years ago about convert. I never got around to providing l10n for val. I like simple stuff—see what I did to Module:Age on 31 March 2019. That was in response to a request I think at my talk which ended up at bnwiki. The point is that there is very little to localize and I don't really want an extra module to fuss with here. However, give it a go if you like. I'm not sure that "locale" is the right name. I temporarily forget what some modules use here, perhaps l10n? Johnuniq (talk) 09:37, 3 June 2019 (UTC)[reply]
I just remembered a related issue for dewiki, see Template talk:Val/Archive 6#Comma as decimal separator. I found a local file on my computer where I apparently started work on localization but probably stopped when there was no feedback. I uploaded the file (patched with some recent changes to the main module) to the sandbox, see permalink at 10:34, 3 June 2019. That is not tested. It was to handle numdot + numsep. Perhaps I abandoned it when I realized what a mess converting the wikitext would be. In the discussion at the archive link I pointed out that the example given used an en number for val's input (2.44) but they wanted a de number for the output (2,44). That would quickly cause immense confusion. Johnuniq (talk) 10:43, 3 June 2019 (UTC)[reply]
Hi, thankx. I will look into it. I prefer an external module because is simpler to keep files synced across different wiki, but moving all the messages and localisation options to the top of the file could be a also be a solution.--Moroboshi (talk) 10:54, 3 June 2019 (UTC)[reply]
Hi. I read the discussion Template_talk:Val/Archive_6#Comma_as_decimal_separator. Currently on it.wiki numbers are formatted directly or indirectly using the magic word formatnum, so the expected input is a number with dot (".") as decimal separator and no group separator. The outuput is a number with nobreaking space ("&amp;"") as group separator and comma (",") as decimal separator. For consistency with the convert module I would like that comma could also be used in input as decimal separator in alternative to dot.
I have uploaded in the Module:Val/sandbox a test version with all the error messages listed in a table at the top of the file. It pass all test in Template talk:Val/testcases except for 27 cases, but the previous version in sandbox was failing them too. Ithaquabe the expected result should be corrected in the table of test ?
I have also added a test on row 133-135 if numdot ~= '.' then arg = arg:gsub(numdot, '.') end to replace the locale numdot with "." if different from dot. --Moroboshi (talk) 11:40, 6 June 2019 (UTC)[reply]
Thanks, that's great work, and you have thoughtfully used the same style that I would. I made a couple of minor changes in Module:Val/sandbox. One strange thing is that something changed "may" to "Ithaqua" in your edits both here and in the module. There is no benefit from using mw.ustring.format rather than plain string.format with %s.
I updated the testcases to show what the current {{val}} does and now Template talk:Val/testcases shows only two differences from the sandbox. They are due to use of &quot; in the sandbox.
I assume the messages used &quot; instead of plain " because valerror replaces all quotes in warnings with &quot;. I think it would be better to use the clear " in the messages and let valerr do what it needs to. There is no problem with overhead because valerror is only called if an error occurs, and that is rare. Further, if an error occurs, additional overhead is immaterial, and would be minuscule.
I wouldn't be surprised if further work is needed somewhere because val can output some strange wikitext. Please let me know how you get on at itwiki. I will update the main module here when you have completed your tests. Johnuniq (talk) 08:15, 7 June 2019 (UTC)[reply]
May->Itaqua was caused by a silly addon for Chrome that replace name of politician with old gods from Lovecraft mythos (in this case "(Theresa) May" -> Itaqua). Normally I use Firefox and I have forgot about the addon.--Moroboshi (talk) 11:02, 7 June 2019 (UTC)[reply]
I'm happy with the translation table at the top of the module, but we mentioned a possible submodule above. If one were used, the convention appears to be /i18n here. Try editing Angola and look in "Pages transcluded onto the current version of this page" at the bottom for i18n. That shows Module:Side box/i18n (does not exist) and Module:Wikidata/i18n. Johnuniq (talk) 23:55, 7 June 2019 (UTC)[reply]
Hello. I'm testing the localization on it.wiki and preparing for the conversions of our old template. Currently I'm translating Template:Val/units and I have a question. Why some units is repeated from Convert, like lbf or year or all the SI table for second or hertz ?Moroboshi (talk) 12:49, 13 June 2019 (UTC)[reply]