Jump to content

Module talk:zh/templates

Page contents not supported in other languages.
Add topic
From Wiktionary, the free dictionary

Edit request

[edit]

@Fish bowl could you please add ['mb'] = 'Min Bei' into lang_abbrev? -- 08:37, 23 March 2022 (UTC)Reply

Done DoneFish bowl (talk) 08:43, 23 March 2022 (UTC)Reply

Suggest adding language tags for TC/SC

[edit]

There are parts of the file I don't understand, but I think something like this should do it:

--- a/templates.lua
+++ b/templates.lua
@@ -9,6 +9,8 @@ local match = mw.ustring.match
 local find = mw.ustring.find
 
 local function format_Chinese_text(text) return '<span class="Hani" lang="zh">' .. text .. '</span>' end
+local function format_Chinese_text_trad(text) return '<span class="Hant" lang="zh-Hant">' .. text .. '</span>' end
+local function format_Chinese_text_simp(text) return '<span class="Hans" lang="zh-Hans">' .. text .. '</span>' end
 local function format_rom(text) return text and '<i><span class="tr Latn">' .. text .. '</span></i>' or nil end
 local function format_gloss(text) return text and '“' .. text .. '”' or nil end
 
@@ -50,10 +52,10 @@ function M.der(frame)
 						table.insert(formatted_word, format_Chinese_text("[[" .. w .. "#Chinese|" .. w .. "]]"))
 					end
 				else
-					table.insert(formatted_word, format_Chinese_text("[[" .. word .. "#Chinese|" .. word .. "]]"))
+					table.insert(formatted_word, format_Chinese_text_trad("[[" .. word .. "#Chinese|" .. word .. "]]"))
 					local word_s = replace_chars(word, m_ts_data.ts)
 					if word_s ~= word then
-						table.insert(formatted_word, format_Chinese_text("[[" .. word_s .. "#Chinese|" .. word_s .. "]]"))
+						table.insert(formatted_word, format_Chinese_text_simp("[[" .. word_s .. "#Chinese|" .. word_s .. "]]"))
 					end
 				end
 				table.insert(result, table.concat(formatted_word, "/"))
@@ -262,8 +264,8 @@ function M.short(frame)
 			table.insert(tr, extracted_pron)
 		end
 	end
-	local trad = format_Chinese_text(table.concat(t))
-	local simp = format_Chinese_text(table.concat(s))
+	local trad = format_Chinese_text_trad(table.concat(t))
+	local simp = format_Chinese_text_simp(table.concat(s))
 	pinyin = pinyin ~= "-" and pinyin or (#tr == #t and table.concat(tr, " ") or false)
 	table.insert(anno, format_rom(pinyin))
 	table.insert(anno, format_gloss(gloss))

Wikifresc (talk) 22:34, 14 September 2022 (UTC)Reply

I updated Module:zh/link instead which makes this obsolete... Wikifresc (talk) 00:56, 15 September 2022 (UTC)Reply