Modulo:Sinogramma

Da Wikizionario, il dizionario a contenuto aperto.

Questo modulo contiene il codice del Template:Sinogramma, di cui interpreta i parametri restituendo come output la descrizione e le categorie dei caratteri cinesi.


local p = {}
function p.sinogramma(frame)

-- variabili richiamate nel template
    tipo = frame.args["tipo"]
    zhset = frame.args["zh-set"]
    zhvariante = frame.args["zh-variante"]
    jagrado = frame.args["ja-grado"]
    kohangul = frame.args["ko-hangul"]
    tratti = frame.args["tratti"]
    radicale = frame.args["radicale"]
    varianterad = frame.args["varianterad"] or ""
    trattirad = frame.args["trattirad"]
    significato = frame.args["significato"]
    jaon = frame.args["ja-on"]
    jakun = frame.args["ja-kun"]
    jaaltro = frame.args["ja-altro"] or ""
    zhpinyin = frame.args["zh-pinyin"]
    compostilink = frame.args["compostilink"] or ""

-- variabili interne al modulo
   carattere = ""
   hanziset = ""
   grado = ""
   definizione = ""
   numerotratti = ""
   zhcattratti = ""
   rad = ""
   trattiradcat = ""
   radicaledescr = ""
   zhcatrad = ""
   descrizione = ""
   significati = ""
   pronuncia = ""
   composti = ""
   composticat = ""
   composticatlink = ""
   
   -- lista dei radicali; inserendo come parametro un numero da 1 a 214 restituisce il radicale corrispondente, altrimenti genera un messaggio di errore
	if radicale == "1" then
		rad = "一"
	elseif radicale == "2" then
		rad = "丨"
	elseif radicale == "3" then
		rad = "丶"
	elseif radicale == "4" then
		rad = "丿"
	elseif radicale == "5" then
		rad = "乙"
	elseif radicale == "6" then
		rad = "亅"
	elseif radicale == "7" then
		rad = "二"
	elseif radicale == "8" then
		rad = "亠"
	elseif radicale == "9" then
		rad = "人"
	elseif radicale == "10" then
		rad = "儿"
	elseif radicale == "11" then
		rad = "入"
	elseif radicale == "12" then
		rad = "八"
	elseif radicale == "13" then
		rad = "冂"
	elseif radicale == "14" then
		rad = "冖"
	elseif radicale == "15" then
		rad = "冫"
	elseif radicale == "16" then
		rad = "几"
	elseif radicale == "17" then
		rad = "凵"
	elseif radicale == "18" then
		rad = "刀"
	elseif radicale == "19" then
		rad = "力"
	elseif radicale == "20" then
		rad = "勹"
	elseif radicale == "21" then
		rad = "匕"
	elseif radicale == "22" then
		rad = "匚"
	elseif radicale == "23" then
		rad = "匸"
	elseif radicale == "24" then
		rad = "十"
	elseif radicale == "25" then
		rad = "卜"
	elseif radicale == "26" then
		rad = "卩"
	elseif radicale == "27" then
		rad = "厂"
	elseif radicale == "28" then
		rad = "厶"
	elseif radicale == "29" then
		rad = "又"
	elseif radicale == "30" then
		rad = "口"
	elseif radicale == "31" then
		rad = "囗"
	elseif radicale == "32" then
		rad = "土"
	elseif radicale == "33" then
		rad = "士"
	elseif radicale == "34" then
		rad = "夂"
	elseif radicale == "35" then
		rad = "夊"
	elseif radicale == "36" then
		rad = "夕"
	elseif radicale == "37" then
		rad = "大"
	elseif radicale == "38" then
		rad = "女"
	elseif radicale == "39" then
		rad = "子"
	elseif radicale == "40" then
		rad = "宀"
	elseif radicale == "41" then
		rad = "寸"
	elseif radicale == "42" then
		rad = "小"
	elseif radicale == "43" then
		rad = "尢"
	elseif radicale == "44" then
		rad= "尸"
	elseif radicale == "45" then
		rad = "屮"
	elseif radicale == "46" then
		rad = "山"
	elseif radicale == "47" then
		rad = "巛"
	elseif radicale == "48" then
		rad = "工"
	elseif radicale == "49" then
		rad = "己"
	elseif radicale == "50" then
		rad = "巾"
	elseif radicale == "51" then
		rad = "干"
	elseif radicale == "52" then
		rad = "幺"
	elseif radicale == "53" then
		rad = "广"
	elseif radicale == "54" then
		rad = "廴"
	elseif radicale == "55" then
		rad = "廾"
	elseif radicale == "56" then
		rad = "弋"
	elseif radicale == "57" then
		rad = "弓"
	elseif radicale == "58" then
		rad = "彐"
	elseif radicale == "59" then
		rad = "彡"
	elseif radicale == "60" then
		rad = "彳"
	elseif radicale == "61" then
		rad ="心"
	elseif radicale == "62" then
		rad = "戈"
	elseif radicale == "63" then
		rad = "戶"
	elseif radicale == "64" then
		rad = "手"
	elseif radicale == "65" then
		rad = "支"
	elseif radicale == "66" then
		rad = "攴"
	elseif radicale == "67" then
		rad = "文"
	elseif radicale == "68" then
		rad = "斗"
	elseif radicale == "69" then
		rad = "斤"
	elseif radicale == "70" then
		rad = "方"
	elseif radicale == "71" then
		rad = "无"
	elseif radicale == "72" then
		rad = "日"
	elseif radicale == "73" then
		rad = "曰"
	elseif radicale == "74" then
		rad = "月"
	elseif radicale == "75" then
		rad = "木"
	elseif radicale == "76" then
		rad = "欠"
	elseif radicale == "77" then
		rad = "止"
	elseif radicale == "78" then
		rad = "歹"
	elseif radicale == "79" then
		rad = "殳"
	elseif radicale == "80" then
		rad = "毋"
	elseif radicale == "81" then
		rad = "比"
	elseif radicale == "82" then
		rad = "毛"
	elseif radicale == "83" then
		rad = "氏"
	elseif radicale == "84" then
		rad = "气"
	elseif radicale == "85" then
		rad = "水"
	elseif radicale == "86" then
		rad = "火"
	elseif radicale == "87" then
		rad = "爪"
	elseif radicale == "88" then
		rad = "父"
	elseif radicale == "89" then
		rad = "爻"
	elseif radicale == "90" then
		rad = "爿"
	elseif radicale == "91" then
		rad = "片"
	elseif radicale == "92" then
		rad = "牙"
	elseif radicale == "93" then
		rad = "牛"
	elseif radicale == "94" then
		rad = "犬"
	elseif radicale == "95" then
		rad = "玄"
	elseif radicale == "96" then
		rad = "玉"
	elseif radicale == "97" then
		rad = "瓜"
	elseif radicale == "98" then
		rad = "瓦"
	elseif radicale == "99" then
		rad = "甘"
	elseif radicale == "100" then
		rad = "生"
	elseif radicale == "101" then
		rad = "用"
	elseif radicale == "102" then
		rad = "田"
	elseif radicale == "103" then
		rad = "疋"
	elseif radicale == "104" then
		rad = "疒"
	elseif radicale == "105" then
		rad = "癶"
	elseif radicale == "106" then
		rad = "白"
	elseif radicale == "107" then
		rad = "皮"
	elseif radicale == "108" then
		rad = "皿"
	elseif radicale == "109" then
		rad = "目"
	elseif radicale == "110" then
		rad = "矛"
	elseif radicale == "111" then
		rad = "矢"
	elseif radicale == "112" then
		rad = "石"
	elseif radicale == "113" then
		rad = "示"
	elseif radicale == "114" then
		rad = "禸"
	elseif radicale == "115" then
		rad = "禾"
	elseif radicale == "116" then 
		rad = "穴"
	elseif radicale == "117" then
		rad = "立"
	elseif radicale == "118" then
		rad = "竹"
	elseif radicale == "119" then
		rad = "米"
	elseif radicale == "120" then
		rad = "糸"
	elseif radicale == "121" then
		rad = "缶"
	elseif radicale == "122" then
		rad = "网"
	elseif radicale == "123" then
		rad = "羊"
	elseif radicale == "124" then
		rad = "羽"
	elseif radicale == "125" then
		rad = "老"
	elseif radicale == "126" then
		rad = "而"
	elseif radicale == "127" then
		rad = "耒"
	elseif radicale == "128" then
		rad = "耳"
	elseif radicale == "129" then
		rad = "聿"
	elseif radicale == "130" then
		rad = "肉"
	elseif radicale == "131" then
		rad = "臣"
	elseif radicale == "132" then
		rad = "自"
	elseif radicale == "133" then
		rad = "至"
	elseif radicale == "134" then
		rad = "臼"
	elseif radicale == "135" then
		rad = "舌"
	elseif radicale == "136" then
		rad = "舛"
	elseif radicale == "137" then
		rad = "舟"
	elseif radicale == "138" then
		rad = "艮"
	elseif radicale == "139" then
		rad = "色"
	elseif radicale == "140" then
		rad = "艸"
	elseif radicale == "141" then
		rad = "虍"
	elseif radicale == "142" then
		rad = "虫"
	elseif radicale == "143" then
		rad = "血"
	elseif radicale == "144" then
		rad = "行"
	elseif radicale == "145" then
		rad = "衣"
	elseif radicale == "146" then
		rad = "西"
	elseif radicale == "147" then
		rad = "見"
	elseif radicale == "148" then
		rad = "角"
	elseif radicale == "149" then
		rad = "言"
	elseif radicale == "150" then
		rad = "谷"
	elseif radicale == "151" then
		rad = "豆"
	elseif radicale == "152" then
		rad = "豕"
	elseif radicale == "153" then
		rad = "豸"
	elseif radicale == "154" then
		rad = "貝"
	elseif radicale == "155" then
		rad = "赤"
	elseif radicale == "156" then
		rad = "走"
	elseif radicale == "157" then
		rad = "足"
	elseif radicale == "158" then
		rad = "身"
	elseif radicale == "159" then
		rad = "車"
	elseif radicale == "160" then
		rad = "辛"
	elseif radicale == "161" then
		rad = "辰"
	elseif radicale == "162" then
		rad = "辵"
	elseif radicale == "163" then
		rad = "邑"
	elseif radicale == "164" then
		rad = "酉"
	elseif radicale == "165" then
		rad = "釆"
	elseif radicale == "166" then
		rad = "里"
	elseif radicale == "167" then
		rad = "金"
	elseif radicale == "168" then
		rad = "長"
	elseif radicale == "169" then
		rad = "門"
	elseif radicale == "170" then
		rad = "阜"
	elseif radicale == "171" then
		rad = "隶"
	elseif radicale == "172" then
		rad = "隹"
	elseif radicale == "173" then
		rad = "雨"
	elseif radicale == "174" then
		rad = "青"
	elseif radicale == "175" then
		rad = "非"
	elseif radicale == "176" then
		rad = "面"
	elseif radicale == "177" then
		rad = "革"
	elseif radicale == "178" then
		rad = "韋"
	elseif radicale == "179" then
		rad = "韭"
	elseif radicale == "180" then
		rad = "音"
	elseif radicale == "181" then
		rad = "頁"
	elseif radicale == "182" then
		rad = "風"
	elseif radicale == "183" then
		rad = "飛"
	elseif radicale == "184" then
		rad = "食"
	elseif radicale == "185" then
		rad = "首"
	elseif radicale == "186" then
		rad = "香"
	elseif radicale == "187" then
		rad = "馬"
	elseif radicale == "188" then
		rad = "骨"
	elseif radicale == "189" then
		rad = "高"
	elseif radicale == "190" then
		rad = "髟"
	elseif radicale == "191" then
		rad = "鬥"
	elseif radicale == "192" then
		rad = "鬯" 
	elseif radicale == "193" then
		rad = "鬲"
	elseif radicale == "194" then
		rad = "鬼"
	elseif radicale == "195" then
		rad = "魚"
	elseif radicale == "196" then
		rad = "鳥"
	elseif radicale == "197" then
		rad = "鹵"
	elseif radicale == "198" then
		rad = "鹿"
	elseif radicale == "199" then
		rad = "麥"
	elseif radicale == "200" then
		rad = "麻"
	elseif radicale == "201" then
		rad = "黃"
	elseif radicale == "202" then
		rad = "黍"
	elseif radicale == "203" then
		rad = "黑"
	elseif radicale == "204" then
		rad = "黹"
	elseif radicale == "205" then
		rad = "黽"
	elseif radicale == "206" then
		rad = "鼎"
	elseif radicale == "207" then
		rad = "鼓"
	elseif radicale == "208" then
		rad = "鼠"
	elseif radicale == "209" then
		rad = "鼻"
	elseif radicale == "210" then
		rad = "齊"
	elseif radicale == "211" then
		rad = "齒"
	elseif radicale == "212" then
		rad = "龍"
	elseif radicale == "213" then
		rad = "龜"
	elseif radicale == "214" then
		rad = "龠"
	else error("radicale non riconosciuto! Inserisci solo il *numero* (da 1 a 214) corrispondente al radicale; trovi la lista in Appendice:Caratteri cinesi/Radicali")
end
   
-- parametro "carattere", traduce il parametro "tipo" del template restituisce la definizione corrispondente ("Hanzi", "Kanji" e "Hanja"), se il parametro non è riconosciuto genera un messaggio di errore
    if tipo == "hanzi" then
   	    carattere = "Hanzi" 
   	elseif tipo == "kanji" then
   		carattere = "Kanji"
    elseif tipo == "hanja" then
    	carattere = "Hanja"
    else error("parametro '".. tipo.. "' non riconosciuto; i valori ammessi per il parametro 'tipo' sono 'hanzi', 'kanji' o 'hanja'") 
end

-- i parametri successivi sono incorporati nel parametro "definizione"; vedi sotto
-- parametro "hanziset", traduce il parametro "zh-set" del template; accetta come valori "zh-tc", "zh-sc" o "zh-tcsc" e restituisce la variabile corrispondente; necessita che il parametro "tipo=" sia "hanzi", altrimenti la variabile esce vuota
    if tipo == "hanzi" and zhset == "zh-sc" then
    	hanziset = " ".. p.wiki("cinese semplificato|semplificato").. " (tradizionale: ".. p.wiki(zhvariante).. ")".. p.cat(carattere.. " semplificati".. "|".. rad)
    elseif tipo == "hanzi" and zhset == "zh-tc" then
    	hanziset = " ".. p.wiki("cinese tradizionale|tradizionale").. " (semplificato: ".. p.wiki(zhvariante).. ")".. p.cat(carattere.. " tradizionali".. "|".. rad)
    elseif tipo == "hanzi" and zhset == "zh-tcsc" then
    	hanziset = " ".. p.wiki("cinese tradizionale|tradizionale").. " e ".. p.wiki("cinese semplificato|semplificato").. p.cat(carattere.. " tradizionali".. "|".. rad).. p.cat(carattere.. " semplificati".. "|".. rad)
    else
    	hanziset = ""
    end

-- parametro "grado", traduce il parametro "ja-grado" del template;
    if tipo == "kanji" and (jagrado == "1" or jagrado == "2" or jagrado == "3" or jagrado == "4" or jagrado == "5" or jagrado == "6") then
    	grado = " base (''[[:w:Gakunenbetsu kanji haitōhyō|Kyōiku kanji]]'') di grado ".. jagrado.. p.cat("Kyōiku kanji di grado ".. jagrado.. "|".. rad)
    elseif tipo == "kanji" and (jagrado == "7") then
    	grado = " comune (''[[:w:Jōyō kanji|Jōyō kanji]]'')".. p.cat("Jōyō kanji".. "|".. rad)
    elseif tipo == "kanji" and (jagrado == "8") then
    	grado = " utilizzato nei nomi propri (''[[:w:Jinmeiyō kanji|Jinmeiyō kanji]]'')".. p.cat("Jinmeiyō kanji".. "|".. rad)
    elseif tipo == "kanji" and (jagrado == "9") then
    	grado = " non comune (''[[:w:Hyōgaiji|Hyōgai kanji]]'')".. p.cat("Hyōgai kanji".. "|".. rad)
    else
    	grado = ""
end
-- parametro "hangul", traduce il parametro "ko-hangul" del template;
    if tipo == "hanja" then
    	hangul = ", [[:w:Hangul|hangul]]: ".. p.wiki(kohangul)
    else
    	hangul = ""
end
-- fine dei incorporati in "definizione"

-- stringa "definizione"; incorpora i parametri precedenti "hanziset", "grado" e "hangul"
    if tipo == "hanzi" then
    	definizione = hanziset
    elseif tipo == "kanji" then
    	definizione = grado
    elseif tipo == "hanja" then
    	definizione = hangul
    else
    	definizione = ""
end

-- parametro "numerotratti", traduce il parametro "tratti" del template"
    if tratti == "1" then
    	-- ulteriore categoria per gli hanzi tradizionali/semplificati
    	if tipo == "hanzi" and zhset == "zh-sc" then zhcattratti = p.cat(carattere.. " semplificati composti da 01 tratto".. "|".. rad) elseif tipo == "hanzi" and zhset == "zh-tc" then zhcattratti = p.cat(carattere.. " tradizionali composti da 01 tratto".. "|".. rad) elseif tipo == "hanzi" and zhset == "zh-tcsc" then zhcattratti = p.cat(carattere.. " tradizionali composti da 01 tratto".. "|".. rad).. p.cat(carattere.. " semplificati composti da 01 tratto".. "|".. rad) else zhcattratti = "" end
        numerotratti = "1 tratto".. p.cat(carattere.. " composti da 01 tratto".. "|".. rad).. zhcattratti
    elseif tonumber(tratti) > 1 and tonumber(tratti) < 10 then 
    	-- ulteriore categoria per gli hanzi tradizionali/semplificati
    	if tipo == "hanzi" and zhset == "zh-sc" then zhcattratti = p.cat(carattere.. " semplificati composti da 0".. tratti.. " tratti".. "|".. rad) elseif tipo == "hanzi" and zhset == "zh-tc" then zhcattratti = p.cat(carattere.. " tradizionali composti da 0".. tratti.. " tratti".. "|".. rad) elseif tipo == "hanzi" and zhset == "zh-tcsc" then zhcattratti = p.cat(carattere.. " tradizionali composti da 0".. tratti.. " tratti".. "|".. rad).. p.cat(carattere.. " semplificati composti da 0".. tratti.. " tratti".. "|".. rad) else zhcattratti = "" end
       	numerotratti = tratti.. " tratti".. p.cat(carattere.. " composti da 0".. tratti.. " tratti".. "|".. rad).. zhcattratti
    elseif tonumber(tratti) > 9 then
    	-- ulteriore categoria per gli hanzi tradizionali/semplificati
    	if tipo == "hanzi" and zhset == "zh-sc" then zhcattratti = p.cat(carattere.. " semplificati composti da ".. tratti.. " tratti".. "|".. rad) elseif tipo == "hanzi" and zhset == "zh-tc" then zhcattratti = p.cat(carattere.. " tradizionali composti da ".. tratti.. " tratti".. "|".. rad) elseif tipo == "hanzi" and zhset == "zh-tcsc" then zhcattratti = p.cat(carattere.. " tradizionali composti da ".. tratti.. " tratti".. "|".. rad).. p.cat(carattere.. " semplificati composti da ".. tratti.. " tratti".. "|".. rad) else zhcattratti = "" end
        numerotratti = tratti.. " tratti".. p.cat(carattere.. " composti da ".. tratti.. " tratti".. "|".. rad).. zhcattratti
end

--stringa "trattiradcat"; ordina i lemmi nelle categorie dei radicali, evitando l'accavallamento di unità è decine (ad es. che '1' e '10' siano entrambi elencati sotto '1') sfruttando dei simboli unicode per i numeri oltre 9 - DIFFICILMENTE E' UNA PRATICA ACCETTABILE MA NON VEDO SOLUZIONI ALTERNATIVE)
	if tonumber(trattirad) < 10 then trattiradcat = frame.args["trattirad"]
	elseif trattirad == "10" then trattiradcat = "⑩" elseif trattirad == "11" then trattiradcat = "⑪" elseif trattirad  == "12" then trattiradcat = "⑫" elseif trattirad  == "13" then trattiradcat = "⑬" elseif trattirad  == "14" then trattiradcat = "⑭" elseif trattirad  == "15" then trattiradcat = "⑮" elseif trattirad  == "16" then trattiradcat = "⑯" elseif trattirad  == "17" then trattiradcat = "⑰" elseif trattirad  == "18" then trattiradcat = "⑱" elseif trattirad  == "19" then trattiradcat = "⑲" 
	elseif trattirad == "20" then trattiradcat = "⑳" elseif trattirad == "21" then trattiradcat = "㉑" elseif trattirad  == "22" then trattiradcat = "㉒" elseif trattirad  == "23" then trattiradcat = "㉓" elseif trattirad  == "24" then trattiradcat = "㉔" elseif trattirad  == "25" then trattiradcat = "㉕" elseif trattirad  == "26" then trattiradcat = "㉖" elseif trattirad  == "27" then trattiradcat = "㉗" elseif trattirad  == "28" then trattiradcat = "㉘" elseif trattirad  == "29" then trattiradcat = "㉙"
	elseif trattirad  == "30" then trattiradcat = "㉚" --non dovrebbe ragionevolmente esistere caratteri con più di 30 tratti oltre il radicale, già 20 mi sembrano tanti...
end
-- stringa "radicaledescr", genera il testo di output utilizzando i parametri "rad" e "trattirad" e in base all'esistenza o meno del parametro "varianterad"
    if varianterad ~= "" then
        radicaledescr = ", [[Appendice:Caratteri cinesi/Radicali|radicale]] ".. radicale.. " (".. p.wiki(rad).. ", nella variante ".. p.wiki(varianterad).. ")+".. trattirad.. p.cat(carattere.. " di radicale ".. radicale.. " ".. rad.. "|".. trattiradcat)
    elseif varianterad == "" or varianterad == false then
    	radicaledescr = ", [[Appendice:Caratteri cinesi/Radicali|radicale]] ".. radicale.. " (".. p.wiki(rad).. ")+".. trattirad.. p.cat(carattere.. " di radicale ".. radicale.. " ".. rad.. "|".. trattiradcat)
end

--stringa "zhcatrad"; realizza le sottocategorie per gli hanzi cinesi tradizionali/semplificati in base al radicale
    if tipo == "hanzi" and zhset == "zh-sc" then zhcatrad = p.cat("Hanzi semplificati di radicale ".. radicale.. " ".. rad.. "|".. trattiradcat)
    elseif tipo == "hanzi" and zhset == "zh-tc" then zhcatrad = p.cat("Hanzi tradizionali di radicale ".. radicale.. " ".. rad.. "|".. trattiradcat)
    elseif tipo == "hanzi" and zhset == "zh-tcsc" then zhcatrad = p.cat("Hanzi semplificati di radicale ".. radicale.. " ".. rad.. "|".. trattiradcat).. p.cat("Hanzi tradizionali di radicale ".. radicale.. " ".. rad.. "|".. trattiradcat)
    else zhcatrad = "" end

--stringa "descrizione", incorpora i parametri precedenti "numerotratti", "radicaledescr" e "zhcatrad" in un'unica stringa di output
    descrizione = "\n".. numerotratti.. radicaledescr.. zhcatrad
    
--stringa "significati", incorpora il parametro "significato" del template
    significati = "\n".. "Significato (come carattere):".. "\n".. "\n".. "# ".. significato

--stringa "pronuncia", incorpora i parametri "zh-pinyin" o "ja-on" e "ja-kun" del template
    if tipo == "hanzi" then
    	pronuncia = "\n".. "Pronuncia ([[Appendice:Pinyin|pinyin]]): ".. zhpinyin
    elseif tipo == "kanji" then 
    	if jaaltro == "" or jaaltro == false then
    	pronuncia = "\n".. "* Lettura [[on'yomi|'''On''']]: ".. jaon.. "\n".. "\n".. "* Lettura [[kun'yomi|'''Kun''']]: ".. jakun
     	else pronuncia = "\n".. "* Lettura [[on'yomi|'''On''']]: ".. jaon.. "\n".. "\n".. "* Lettura [[kun'yomi|'''Kun''']]: ".. jakun.. "\n".. "\n".. "* Lettura ".. jaaltro end
	else
    	pronuncia = ""
end

--stringa "composti", genera il link ai composti del carattere in appendice, la relativa categoria ed il link alla stessa
	if tipo == "hanzi" then 
		composticat = "[[Categoria:Composti di ".. mw.title.getCurrentTitle().text.. " in cinese| ]]"; composticatlink = ""
	elseif tipo == "kanji" then 
		composticat = "[[Categoria:Composti di ".. mw.title.getCurrentTitle().text.. " in giapponese| ]]"; composticatlink = ""
	elseif tipo == "hanja" then 
		composticat = "[[Categoria:Composti di ".. mw.title.getCurrentTitle().text.. " in coreano| ]]"; composticatlink = ""
	end
    if tratti == "1" and compostilink ~= "no" then
    	composti = "([[Appendice:Caratteri cinesi/Composti/01 tratti/".. mw.title.getCurrentTitle().text.. "|vai ai composti]])".. composticat.. composticatlink.. "\n"
    elseif tonumber(tratti) > 1 and tonumber(tratti) < 10 and compostilink ~= "no" then
    	composti = " ([[Appendice:Caratteri cinesi/Composti/0".. tratti.. " tratti/".. mw.title.getCurrentTitle().text.. "|vai ai composti]])".. composticat.. composticatlink.. "\n"
    elseif tonumber(tratti) > 9 and compostilink ~= "no" then
		composti = " ([[Appendice:Caratteri cinesi/Composti/".. tratti.. " tratti/".. mw.title.getCurrentTitle().text.. "|vai ai composti]])".. composticat.. composticatlink.. "\n"
	elseif compostilink == "no" then
		composti = "\n"
end

-- infine, incorpora le stringhe "carattere", "definizione", "descrizione" e "composti" generando il testo di output
    return
    composti.. "\n".. carattere.. p.cat(carattere.. "|".. rad).. definizione.. "; ".. descrizione.. "\n".. pronuncia.. "\n".. significati.. "\n"
end

-- questa funzione rende il suo argomento un wikilink
function p.wiki(x)
    return "[[" .. x .. "]]"
end
-- questa funzione crea una categoria a partire dal o dai suoi argomenti
function p.cat(x)
	return "[[Categoria:" .. x .. "]]"
end
return p