Help with pronunciation modules

Fragment of a discussion from User talk:Kephir
Jump to navigation Jump to search

That is what require is for. Just check whether the script is "Geor", and if so then return require("Module:Geor-translit").tr(text, lang, sc). Is that something you are actually trying to do?

Keφr09:55, 5 July 2015

Yes, I am trying to do it. I would like to start with Kipchak (Module:qwm-translit), which can be written in Latin and Armenian. How would the code look like if I want to skip transliteration if it's Latn, and forward to Module:Armn-translit, if it's Armn. There are many more languages in the pipeline.

Vahag (talk)11:03, 5 July 2015
function export.tr(text, lang, sc)
	if sc == "Latn" then
		return nil
	elseif sc == "Armn" then
		return require("Module:Armn-translit").tr(text, lang, sc)
	else
		error("Huệ nương!")
	end
end

It is that easy.

Keφr11:25, 5 July 2015

Thanks. What am I doing wrong? Remember, you are dealing with a module illiterate.

Vahag (talk)12:06, 5 July 2015

Forgot to return export at the end of the module.

And actually, it turns out you could have just plugged Module:Armn-translit directly as the module for qwm. Module:links already skips transliteration when the script is of the Latin family (Latn, xx-Latn or Latinx).

Keφr12:13, 5 July 2015

Thanks again. But let's keep Module:qwm-translit for a case where we have an entry in the Arabic script, but no manual transliteration. On a related note, can Module:Geor-translit change behaviour based on language? Namely, if lang=sva then ["ჳ"]="w", in all other cases ["ჳ"]="wi".

Vahag (talk)13:39, 5 July 2015

Module:Cyrs-Glag-translit does something like that, but I happen to dislike that approach. (It does work, though.)

Keφr15:20, 5 July 2015

Looks complicated. I'll probably create a separate module for Svan.

Vahag (talk)16:56, 5 July 2015