Module talk:script utilities

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Text direction/RTL and Common.css[edit]

@Erutuon The assumption that the text direction is always specified via CSS is not entirely correct – the mobile site uses MediaWiki:Mobile.css instead of MediaWiki:Common.css. Also see the discussion at Template_talk:ux. – Jberkel (talk) 15:29, 21 February 2017 (UTC)[reply]

@Jberkel: Ah, thank you for letting me know. I wonder if there is a way for the module to determine whether the mobile version of the page is being viewed, and to add text direction markers in that case. — Eru·tuon 19:44, 21 February 2017 (UTC)[reply]
On second thought, I don't think the source code can differ between the ordinary and the mobile site, so that idea would not be possible. — Eru·tuon 19:55, 21 February 2017 (UTC)[reply]
Problems in the CSS should be fixed in the CSS. --WikiTiki89 20:34, 21 February 2017 (UTC)[reply]
@Erutuon is the RTL parameter you added still used somewhere? I'm currently trying to clean up some of the modules and would like to remove it unless it is absolutely necessary. – Jberkel (talk) 23:32, 21 February 2017 (UTC)[reply]
@Jberkel: Not that I know of. Go ahead and remove it; if it's needed, it can be restored from the edit history. — Eru·tuon 23:36, 21 February 2017 (UTC)[reply]

Ruby for Korean[edit]

@Erutuon, Surjection, Tibidibi, LoutK I am thinking of changing the Korean hyphen section to the following:

	-- Hack Korean script text to remove hyphens.
	-- This should be handled in a more general fashion, but needs to
	-- be efficient by not doing anything if no hyphens are present, and currently this is the only
	-- language needing such processing.
	-- 20220221: Also convert 漢字(한자) to ruby, instead of needing [[Template:Ruby]].
	if sc:getCode() == "Kore" and text:find("%-") or text:find("[()]") then
		text = require("Module:munge_text")(text, function(txt)
			-- Hani/Hang regex is a reasonable subset of Hani/Hang from [[Module:scripts/data]],
			-- last checked on 20220221
			txt = txt:gsub("%-", "")
			txt = mw.ustring.gsub(txt, "([一-鿿㐀-䶿𠀀-𮯯𰀀-𱍏]+)%(([가-힣ᄀ-ᇿꥠ-ꥼힰ-ퟻ]+)%)", "<ruby>%1<rp>(</rp><rt>%2</rt><rp>)</rp></ruby>")
			return txt
		end)
	end

After a similar change to Module:languages/data2, this would produce links like 訓民正音(훈민정음) (hunminjeongeum).

Hopefully this will make text like 又#Korean less tiresome to format.

Will this introduce unnecessary strain?

Fish bowl (talk) 06:50, 22 February 2022 (UTC)[reply]

Probably, but who knows. I don't like the existing Kore code being here either, because it's a terrible hack which probably wastes a ton of resources, causes things like this where people want to expand it (and before long also apply something similar to other languages) and should be handled on a higher level than this. — SURJECTION / T / C / L / 08:56, 22 February 2022 (UTC)[reply]
Sounds good! LoutK (talk) 18:24, 22 February 2022 (UTC)[reply]

Very hesitantly implemented. .-. —Fish bowl (talk) 09:03, 20 April 2022 (UTC)[reply]