From Afropedia.world
Revision as of 17:47, 19 January 2026 by Djehuti (talk | contribs) (Created Module:Zh for Chinese language support)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

-- Module:Zh -- Handles Chinese language text display with traditional/simplified characters and romanization

local p = {}

function p.zh(frame)

   local args = frame:getParent().args
   
   -- Get parameters
   local traditional = args['t'] or args['traditional'] or 
   local simplified = args['s'] or args['simplified'] or 
   local pinyin = args['p'] or args['pinyin'] or 
   local hanpin = args['hp'] or args['hanpin'] or 
   local wade = args['w'] or args['wade'] or 
   local literal = args['l'] or args['literal'] or 
   
   -- Determine which Chinese text to display
   local chinese_text = 
   if simplified ~=  then
       chinese_text = simplified
   elseif traditional ~=  then
       chinese_text = traditional
   end
   
   -- Build romanization
   local romanization = hanpin or pinyin or wade
   
   -- Build output
   local result = 
   
   if chinese_text ~=  then
       result = '' .. chinese_text .. ''
   end
   
   if romanization ~=  then
       if result ~=  then
           result = result .. '; '
       end
       result = result .. '' .. romanization .. ''
   end
   
   if literal ~=  then
       if result ~=  then
           result = result .. ', literally: '
       end
       result = result .. '"' .. literal .. '"'
   end
   
   return result

end

return p