Module talk:term etymology
@Erutuon, I'm trying to write a module to grab the etymology of a term, based on {{Module:descendants tree}}, but it doesn't seem to be working. Could you have a look at what I'm doing wrong? Much obliged. --Victar (talk) 18:24, 18 May 2017 (UTC)
I think you needed to use match rather than find: find returns the first index of the content as its first value, while match returns the content. I changed the regex as well because I didn't understand it. You can change it back if you like. — Eru·tuon 18:35, 18 May 2017 (UTC)
@Erutuon: Ah, thanks! That would have taken me forever to figure out. How can I get the rendered content instead of the raw code? --Victar (talk) 18:40, 18 May 2017 (UTC)
@Victar: I think you use the frame:preprocess(text) function. You'll have to use mw.getCurrentFrame to return the current frame object first. — Eru·tuon 18:44, 18 May 2017 (UTC)
@Erutuon:, again, you just saved me at least 30 mins. =) --Victar (talk) 18:51, 18 May 2017 (UTC)
Christ, why is it so difficult to make the first character in a string lower case?! My PHP roots are failing me. --Victar (talk) 19:27, 18 May 2017 (UTC)
You can use mw.ustring.gsub to do this... though there's also a mw.language:lcfirst that I haven't used yet. — Eru·tuon 19:37, 18 May 2017 (UTC)
Weird. I guess Lua and I just don't sit eye to eye yet. --Victar (talk) 20:01, 18 May 2017 (UTC)
@Erutuon, on another note, what do you think of the concept of nesting etymologies? --Victar (talk) 18:51, 18 May 2017 (UTC)
@Victar: I don't know. What do you mean? — Eru·tuon 18:56, 18 May 2017 (UTC)
@Erutuon: I'll put together an example and show you. --Victar (talk) 19:01, 18 May 2017 (UTC)
@Erutuon: Have a look at this, albeit dirty, example (ignore the template loop error). --Victar (talk) 20:01, 18 May 2017 (UTC)
@Victar: Ahh. It's kind of cool, but not sure what I think of it. (The template loop error can be fixed in the same way as in {{desctree}}.) It puts one etymology at the mercy of another, and it might not work when the etymology is oddly formatted or complicated. Some people might object to automatically adding a full derivational chain to every entry, no matter how it's done. Actually, one problem is that the first language code in the transcluded etymology is not changed, so apple will display as a Middle English word derived from Old English, an Old English word derived from Proto-Germanic, etc. That could be fixed, I suppose. One would also have to make it fix the types of derivation (inheritance, borrowing). — Eru·tuon 21:35, 18 May 2017 (UTC)
@Erutuon: Yeah, it's all sorts of buggy and has a long ways to go. I think though it's the direction things should move, if we want to cut down duplication and make Wiktionary accurate and consistent. It's really pretty godawful how so many parent and child entries have conflicting etymologies. I'm not following. Do you mean to say that you think we'll have looping issues from {{der}}, {{bor}}, etc as well? I can also see it possibly being integrated into such templates, as |etyl=1. --Victar (talk) 02:17, 19 May 2017 (UTC)
@Victar: No, it's not about template looping errors. It's about the language codes inside the templates and the etymological categories. If you transclude {{bor|fr|la|word}} from a French entry to an English one, then the English entry will have the category of "French word borrowed from Latin", rather than the correct category of "English word derived from Latin". — Eru·tuon 02:26, 19 May 2017 (UTC)
@Erutuon: I'm not seeing the problem, ex. User:Victar/duvet. I tried fixing the looping issue, but no luck. --Victar (talk) 03:27, 19 May 2017 (UTC)
@Victar: That's because the categories aren't added unless you're in the main or Reconstruction namespace. — Eru·tuon 03:34, 19 May 2017 (UTC)
@Erutuon: OH, OK, I understand now. --Victar (talk) 03:46, 19 May 2017 (UTC)
I thought etymology = mw.ustring.gsub(etymology, "{{termetyl|", "{{#invoke:User:Victar/term etymology/templates|show|") would fix the looping issue, but no such luck. --Victar (talk) 04:08, 19 May 2017 (UTC)
Me too. It worked for Module:descendants tree. I'll look at it at some point and see if I can figure out why it isn't working here. — Eru·tuon 04:50, 19 May 2017 (UTC)
Cool, thanks. If that gets fixed, I can present it to everyone and see what the hive can come up with. --Victar (talk) 04:59, 19 May 2017 (UTC)
@CodeCat, this module is based on your code. Any idea what's causing the loop? --Victar (talk) 04:56, 20 May 2017 (UTC)
@Erutuon: Doh! It's always the little things that drive you crazy! --Victar (talk) 01:30, 23 May 2017 (UTC)