Module:jv-translit

Hello, you have come here looking for the meaning of the word Module:jv-translit. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:jv-translit, but we will also tell you about its etymology, its characteristics and you will know how to say Module:jv-translit in singular and plural. Everything you need to know about the word Module:jv-translit you have here. The definition of the word Module:jv-translit will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:jv-translit, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module will transliterate Javanese language text per WT:JV TR. It is also used to transliterate Old Javanese. The module should preferably not be called directly from templates or other modules. To use it from a template, use {{xlit}}. Within a module, use Module:languages#Language:transliterate.

For testcases, see Module:jv-translit/testcases.

Functions

tr(text, lang, sc)
Transliterates a given piece of text written in the script specified by the code sc, and language specified by the code lang.
When the transliteration fails, returns nil.

local export = {}

local conv = {
	-- finals (U+A980 - U+A983):
	
	 = "m",
	 = "ng",
	 = "r",
	 = "h",
	
	-- independent vowels (U+A984 - U+A98E):
	
	 = "a",    = "ā",
	 = "i",
	 = "ĩ",
	 = "ī",
	 = "u",    = "ū",
	 = "re",   = "reu",
	 = "le",
	 = "leu",
	 = "e",
	 = "ai",
	 = "o",
	
	-- independent consonants (U+A98F - U+A9B2):
	
	 = "k",    = "ḳh",
	 = "q",
	 = "kh",
	 = "g",    = "g̣h",
	 = "gh",
	 = "ng",   = "'",
	
	 = "c",
	 = "ch",
	 = "j",    = "z",
	 = "jñ",
	 = "jh",
	 = "ny",
	
	 = "th",
	 = "țh",
	 = "dh",
	 = "ḍh",
	 = "nn",
	
	 = "t",
	 = "ț",
	 = "d",    = "dz",
	 = "ḍ",
	 = "n",
	
	 = "p",    = "f",
	 = "ph",
	 = "b",
	 = "bh",
	 = "m",
	
	 = "y",
	 = "r",
	 = "r",
	 = "l",
	 = "w",    = "v",
	 = "sh",
	 = "ss",
	 = "s",    = "sy",
	 = "h",    = "ḥ",
	
	-- cecak_telu/nukta (U+A9B3):
	
	 = "",
	
	-- dependent vowels (U+A9B4 - A9BD):
	
	 = "ā", -- tarung
	 = "eu", -- tolong
	 = "i",
	 = "ī",
	 = "u",
	 = "ū",
	 = "é",   -- or "è", depends. Javanese script doesn't differentiate, while Latin differentiate them
	 = "o",
	 = "ai",  
	 = "au",
	 = "e",
	 = "re",   = "reu",
	
	-- medials (U+A9BE - U+A9BF):
	 = "y",
	 = "r",
	
	-- pangkon/virama (U+A9C0):
	
	 = "", -- it depends. if followed by a space, it became "," compound sentence separator
	
	-- punctuation (U+A9C1 - U+A9CF):
	
	 = "", -- "(starts title)",
	 = "", -- "(ends title)",
	 = "", -- "(letter to younger age or lower rank)",
	 = "", -- "(letter to equal age or equal rank)",
	 = "", -- "(letter to older age or higher rank)",
	 = "", -- "(pada windu)",
	 = ":", -- number indicator
	 = ",", -- it depends. if preceeded by a 'pangkon', it became "." end of sentence marker
	 = ".",
	 = "\"",
	 = "¶", -- start of paragraph marker
	 = "(",
	 = ")",
	 = "<sup>2</sup>",
	
	-- digits (U+A9D0 - U+A9D9):
	
	 = "0",
	 = "1",
	 = "2",
	 = "3",
	 = "4",
	 = "5",
	 = "6",
	 = "7",
	 = "8",
	 = "9",
	
	-- ellipsis (U+A9DE - U+A9DF):
	
	 = "-",
	 = "-",
}

function export.tr(text, lang, sc)
	local CSVC = {
		initial = "(꦳?)",
		medial = "(?)",
		nucleus = "(?ꦴ?)",
		final = "(?)",
	}
	local VC = {
		nucleus = "(ꦴ?)",
		final = "(*)",
	}
	
	local number_indicator = "꧇"
	local digits = ""
	
	local initial = true
	
	text = mw.ustring.gsub(
		text,
		CSVC.initial .. CSVC.medial .. CSVC.nucleus.. CSVC.final,
		function(a, b, c, d)
			a = conv or error("Initial not recognized: " .. a)
			b = b == "" and "" or conv or error("Medial not recognized: " .. b)
			c = c == "" and "a" or conv or error("Nucleus not recognized: " .. c)
			d = d == "" and "" or conv or error("Final not recognized: " .. d)
			if initial and a == "h" then
				a = ""
			end
			initial = false
			return a .. b .. c .. d
		end
	)
	
	text = mw.ustring.gsub(
		text,
		VC.nucleus .. VC.final,
		function(a, b)
			a = conv
			b = (b == "" and "" or conv)
			initial = false
			return a .. b
		end
	)
	
	text = mw.ustring.gsub(
		text,
		number_indicator .. "(" .. digits .. "+)" .. number_indicator,
		function(a)
			a = mw.ustring.gsub(a, ".", conv)
			initial = true
			return a
		end
	)
	
	text = mw.ustring.gsub(text, ".", conv)
	
	return text
end

return export