Monday, April 8, 2013

Wiktionary - Recent changes [en]: Module talk:links

Wiktionary - Recent changes [en]
Track the most recent changes to the wiki in this feed. // via fulltextrssfeed.com
Module talk:links
Apr 9th 2013, 01:13

Line 48: Line 48:
 

::{{temp|wlink|[[test]]}} = {{wlink|[[test]]}}, {{temp|wlink|test}} = {{wlink|test}}. --[[User:Yair rand|Yair rand]] ([[User talk:Yair rand|talk]]) 22:35, 7 April 2013 (UTC)

 

::{{temp|wlink|[[test]]}} = {{wlink|[[test]]}}, {{temp|wlink|test}} = {{wlink|test}}. --[[User:Yair rand|Yair rand]] ([[User talk:Yair rand|talk]]) 22:35, 7 April 2013 (UTC)

 

::: I think the module already does that currently. But you can try it to make sure. {{User:CodeCat/signature}} 22:48, 7 April 2013 (UTC)

 

::: I think the module already does that currently. But you can try it to make sure. {{User:CodeCat/signature}} 22:48, 7 April 2013 (UTC)

  +

::::I just checked. It does not. It should probably also be able to support {{temp|l-self}}, by the way. --[[User:Yair rand|Yair rand]] ([[User talk:Yair rand|talk]]) 01:13, 9 April 2013 (UTC)

   
 

== altForm from WT:EDIT ==

 

== altForm from WT:EDIT ==


Latest revision as of 01:13, 9 April 2013

test cases: Module talk:links/testcases

Contents

[edit] Alt text

What should language_link do with the alt-text if the main text already contains links? I presume that if given something like [[text|tēxt]], it shouldn't actually use the alt text, just add the language name. So how should it handle this? —CodeCat 21:29, 29 March 2013 (UTC)

Yeah, I made a change for that. --Z 22:47, 29 March 2013 (UTC)
Your change doesn't actually work right. Consider what it would do if text were "[[word|wōrd]] is [[this]]". —CodeCat 22:56, 29 March 2013 (UTC)
Yeah, forgot that, fixed now, I think. --Z 23:27, 29 March 2013 (UTC)

What should we do in cases like {{l|en|a [[text]]|tēxt}}? Current code will return a [[text#English|tēxt]]. I think value of alt shouldn't affect output in this case either. If we create more links, all of them will have "tēxt" as their link title. --Z 02:50, 31 March 2013 (UTC)

The alt text should only really be used if there are no links in the text. If there are, it should be ignored, so it should give a [[text#English|text]]. —CodeCat 03:51, 31 March 2013 (UTC)

[edit] Annotated link

I made this a function that doesn't receive a frame on purpose. What if another Lua function wants to make a link? It would be a bit silly if it had to call the template... —CodeCat 14:51, 30 March 2013 (UTC)

Ok, feel free to revert. I thought the function is supposed to be used only in l and term. (But we need to add another function which take frame table as argument). --Z 15:02, 30 March 2013 (UTC)
Well, my intention was that this module be used for anything related to making links. {{l}} and {{term}} aren't the only ones that make links, we also have the form-of templates (which really work like {{term}} because they also have "annotations", but with some extras), and {{head}} which could use this module. Provided that it's made in such a way that nothing is written to work only for {{l}}, at least. —CodeCat 16:32, 30 March 2013 (UTC)
But they are still different, even l and term don't work exactly the same, and the current code is more similar to term -- term is like this: <word> (<tr>, "<gloss>"), and l: <word> (<tr>) <g> ("<gloss>"). --Z 17:02, 30 March 2013 (UTC)
That's why I said it may not be a good idea to try to mimic the templates too closely. Do we actually want them to be different in that way? I think they should both work like {{term}} does, with only a single set of brackets instead of two. —CodeCat 17:16, 30 March 2013 (UTC)
Do we need community consensus to make such change? The change is minor and probably not important, but the tempate is widely used... --Z 17:23, 30 March 2013 (UTC)
I don't think so. It doesn't actually change anything that is really important, just a small cosmetic detail, which can easily be changed back (but I doubt anyone would disagree). —CodeCat 19:05, 30 March 2013 (UTC)

[edit] "main" and arguments

What is this function actually meant to do? What are the parameters for? Could it have a better name? Also, the way the parameters are assigned is just wrong; it creates global variables which should be avoided, especially in this case. A better way of doing it would be:

  local args = frame:getParent().args  local gloss = args["gloss"] or ""  

CodeCat 19:11, 30 March 2013 (UTC)

We need a function like this to make the module accessible from wiki pages. We'll change the name if we feel the need to define more functions for creating links in future, e.g. links in a format that is different from that of term and l (see Template:fa-conj for example, in which transliterations are in a new line). Regarding variables, yeah that's better, I'll change it. --Z 19:22, 30 March 2013 (UTC)
Maybe it should just be called "template_l" so that we know it's just for that template? —CodeCat 19:25, 30 March 2013 (UTC)
Ok, we may change that to main if decide to use that for term, etc. too. Regarding variables, I think the current form is better. By applying your change, all variables will be always True, because they are either a text, or an empty string, "", both of which are True. Then we can't use expressions like "(alt or text)" --Z 19:31, 30 March 2013 (UTC)
Yes, but there is an advantage too. In templates, you can insert a parameter that might be empty, and if it's empty, no text is inserted there. In Lua, if you try to insert nil into a text, you get a script error. So we will have to decide which is more convenient. In any case, the current form isn't better, it still needs to be changed because it uses global variables. —CodeCat 19:35, 30 March 2013 (UTC)
But does that that really happen? So far, the code is written in a way that before adding any variables to the output text, it checks if it's not nil. (except when both text and alt are nil, but I think raising an error is actually appropriate in this case) --Z 19:47, 30 March 2013 (UTC)

Aren't we going to support parameters for gender and number or what? --Z 17:36, 31 March 2013 (UTC)

{{l}} supports it, so I suppose we'll have to. I don't really like the idea of putting grammatical information into a template like this, but for now we should focus on making the existing template work so we can convert it. We can discuss actual changes later on. —CodeCat 18:25, 31 March 2013 (UTC)
Also for that reason, please do not add extras like automated transliterations or removal of macrons. Those are not in {{l}} so they shouldn't be in this either, not until after we have converted {{l}} and are sure that it works. —CodeCat 18:28, 31 March 2013 (UTC)
But then again, it's the best time to perform any planned changes, because we are rewriting the code. --Z 19:01, 31 March 2013 (UTC)
It would be if we could start from scratch. Unfortunately, we can't, so we have to incorporate backwards compatibility into our plans. —CodeCat 19:20, 31 March 2013 (UTC)

[edit] General linking module?

If this module is going to be used as a general module for linking, then I think it should include the functionality provided by {{wlink}}, {{wlink2}}, and {{makelink}}. Also, most or all of export.template_l should be moved into more general functions. --Yair rand (talk) 22:27, 7 April 2013 (UTC)

What extra functionality do those templates provide exactly? And the problem with moving the functionality into general functions is that currently there is a variety of parameter names for different templates. The purpose of export.template_l is to "convert" these parameters into a standard format, and then forward it to a more general function. I don't know if it does that well enough, but that is the idea. —CodeCat 22:30, 7 April 2013 (UTC)
{{wlink|[[test]]}} = test, {{wlink|test}} = test. --Yair rand (talk) 22:35, 7 April 2013 (UTC)
I think the module already does that currently. But you can try it to make sure. —CodeCat 22:48, 7 April 2013 (UTC)
I just checked. It does not. It should probably also be able to support {{l-self}}, by the way. --Yair rand (talk) 01:13, 9 April 2013 (UTC)

[edit] altForm from WT:EDIT

In prepare_title, la-utilities is imported if the language is Latin. Rather than setting up a whole bunch of unique functions for every language, perhaps we should just copy over the altForms table from WT:EDIT:

  var altForm = {                  ang: {from:"ĀāǢǣĊċĒēĠġĪīŌōŪūȲȳ", to:"AaÆæCcEeGgIiOoUuYy", strip:"\u0304\u0307"}, //macron and above dot                  ar: {strip:"\u064B\u064C\u064D\u064E\u064F\u0650\u0651\u0652"},                  fa: {strip:"\u064B\u064C\u064D\u064E\u064F\u0650\u0651\u0652"},                  ur: {strip:"\u064B\u064C\u064D\u064E\u064F\u0650\u0651\u0652"},                  chl: {from:"ÁáÉéÍíÓóÚú", to:"AaEeIiOoUu",strip:"\u0304"}, //acute accent                  he: {strip:"\u05B0\u05B1\u05B2\u05B3\u05B4\u05B5\u05B6\u05B7\u05B8\u05B9\u05BA\u05BB\u05BC\u05BD\u05BF\u05C1\u05C2"},                  hr: {from:"ȀȁÀàȂȃÁáĀāȄȅÈèȆȇÉéĒēȈȉÌìȊȋÍíĪīȌȍÒòȎȏÓóŌōȐȑȒȓŔŕȔȕÙùȖȗÚúŪū",                           to:"AaAaAaAaAaEeEeEeEeEeIiIiIiIiIiOoOoOoOoOoRrRrRrUuUuUuUuUu",                           strip:"\u030F\u0300\u0311\u0301\u0304"},                  la: {from:"ĀāĒēĪīŌōŪūȲȳ", to:"AaEeIiOoUuYy",strip:"\u0304"}, //macron                  lt: {from:"áãàéẽèìýỹñóõòúù", to:"aaaeeeiyynooouu", strip:"\u0340\u0301\u0303"},                  nci: {from:"ĀāĒēĪīŌōŪūȲȳ", to:"AaEeIiOoUu",strip:"\u0304"}, //macron                  ro: {from:"ŞŢşţ", to:"ȘȚșț"},                  ru: {strip:"\u0300\u0301"},                  uk: {strip:"\u0300\u0301"},                  be: {strip:"\u0300\u0301"},                  bg: {strip:"\u0300\u0301"},                  mk: {strip:"\u0300\u0301"},                  sh: {                          from:"ȀȁÀàȂȃÁáĀāȄȅÈèȆȇÉéĒēȈȉÌìȊȋÍíĪīȌȍÒòȎȏÓóŌōȐȑȒȓŔŕȔȕÙùȖȗÚúŪūѝӣ",                          to:  "AaAaAaAaAaEeEeEeEeEeIiIiIiIiIiOoOoOoOoOoRrRrRrUuUuUuUuUuии",                          strip:"\u030F\u0300\u0311\u0301\u0304"                  },                  sr: {                          from:"ȀȁÀàȂȃÁáĀāȄȅÈèȆȇÉéĒēȈȉÌìȊȋÍíĪīȌȍÒòȎȏÓóŌōȐȑȒȓŔŕȔȕÙùȖȗÚúŪū",                          to:"AaAaAaAaAaEeEeEeEeEeIiIiIiIiIiOoOoOoOoOoRrRrRrUuUuUuUuUu",                          strip:"\u030F\u0300\u0311\u0301\u0304"                  },                  sl: {from: "áÁàÀâÂȃȂȁȀéÉèÈêÊȇȆȅȄíÍìÌîÎȋȊȉȈóÓòÒôÔȏȎȍȌŕŔȓȒȑȐúÚùÙûÛȗȖȕȔệỆộỘẹẸọỌəł",                           to: "aAaAaAaAaAeEeEeEeEeEiIiIiIiIiIoOoOoOoOoOrRrRrRuUuUuUuUuUeEoOeEoOel",                           strip: "\u0301\u0300\u0302\u0311\u030f\u0323"},                  tr: {from:"ÂâÛû", to:"AaUu",strip:"\u0302"},                  zu: {strip_init_hyphen: 1}          };   

--Yair rand (talk) 22:37, 7 April 2013 (UTC)

Because it is a data table, it seems like it would be better suited to Module:languages. It would also be faster, because that module would only be imported once per page, while this module would be imported once per link template. —CodeCat 22:47, 7 April 2013 (UTC)

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions