Help with pronunciation modules
"к" is the third letter from the start. The mw.ustring.gsub(text, '..', tt)
line takes successive pairs of characters and substitutes them according to the mapping; here, they are "аж", "ак", and "ьа". Since "кь" is on an odd position, it is not matched. I vaguely remember some other module being bitten by the same problem before.
My solution cheats a bit; it just restricts the pattern to pairs which start with consonants that have entries in the table. If you ever need to process overlapping pairs, or ones with some other consonant letters, it will no longer work.
Some languages are written in multiple scripts. Assume we have an automatic transliteration module for each script. Is there a way to make, for example, Ossetian to be transliterated with Module:os-translit when written in Cyrl and with Module:Geor-translit, when written in Geor? I understand that I can copy the content of the latter into the former, but that would lead to duplication and dis-synchronization over time.
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?
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.
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.
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
).
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".
Module:Cyrs-Glag-translit does something like that, but I happen to dislike that approach. (It does work, though.)