Tuesday, August 6, 2013

Wiktionary - Recent changes [en]: Module:User:CodeCat/labels

Wiktionary - Recent changes [en]
Track the most recent changes to the wiki in this feed. // via fulltextrssfeed.com 
Module:User:CodeCat/labels
Aug 7th 2013, 00:59, by CodeCat

Line 47: Line 47:
   
 

local data = get_data(label)

 

local data = get_data(label)

  +

error(m_debug.dump(data))

 

data.display = data.display or label

 

data.display = data.display or label

 

data.next_label = data.next_label or next_label

 

data.next_label = data.next_label or next_label


This module lacks a documentation page. Please create it.
  local m_labeldata = mw.loadData("Module:labels/data")  local m_languages = mw.loadData("Module:languages")  local m_utilities = require("Module:utilities")     local m_debug = require("Module:debug")     local export = {}     -- The main entry point.  -- This is the only function that can be invoked from a template.  function export.show(frame)      local args = frame:getParent().args      NAMESPACE = mw.title.getCurrentTitle().nsText      local ret = ""      local compat = (frame.args["compat"] or "") ~= ""         -- Gather parameters      local lang = args[(compat and "lang" or 1)] or (NAMESPACE == "Template" and "und") or ""; if compat and lang == "" then lang = "en" end --(NAMESPACE == "Template" and "und") or error("Language code has not been specified. Please pass parameter \"lang=\" to the template.")      local script = args["script"]; if script == ""  then script = nil end      local script2 = args["script2"]; if script2 == ""  then script2 = nil end      local sort_key = args["sort"]; if sort_key == ""  then sort_key = nil end      local sort_key2 = args["sort2"]; if sort_key2 == ""  then sort_key2 = nil end         -- Show the labels      ret = ret .. "<span class=\"ib-brac qualifier-brac\">(</span><span class=\"ib-content qualifier-content\">"      local i = (compat and 1 or 2)      local label = args[i]; if label == "" then label = nil end      local next_label = args[i+1]; if next_label == "" then next_label = nil end         while label do          if label == "," then              ret = ret .. '<span class="ib-comma"><span class="qualifier-comma">,</span></span>&#32;'          elseif label == "or" then              ret = ret .. 'or&#32;'          elseif label == "and" then              ret = ret .. 'and&#32;'          elseif label == "_" then              if next_label and next_label ~= "," then                  ret = ret .. '&#32;'              end          else              -- Is this label really an alias of another label?              -- If so, then just "rename" the current label to the one it points to.              if m_labeldata.aliases[label] then                  label = m_labeldata.aliases[label]              end                 local data = get_data(label)              error(m_debug.dump(data))              data.display = data.display or label              data.next_label = data.next_label or next_label                 ret = ret .. show_label(data) .. show_categories(data, lang, script, sort_key, script2, sort_key2)          end             i = i + 1          label = next_label          next_label = args[i+1]; if next_label == "" then next_label = nil end      end         ret = ret .. "</span><span class=\"ib-brac qualifier-brac\">)</span>"         return ret  end     function show_label(data)      if data.next_label == "," or data.next_label == "or" or data.next_label == "and" or data.next_label == "_" then          return data.display .. "&#32;"      elseif data.next_label then          return data.display .. "<span class=\"ib-comma qualifier-comma\">,</span>&#32;"      else          return data.display      end  end     function show_categories(data, lang, script, sort_key, script2, sort_key2)      local langinfo = m_languages[lang] or error("The language code \"" .. lang .. "\" is not valid.")         local categories = {}      local categories2 = {}         for i, cat in ipairs(data.topical_categories or {}) do          table.insert(categories, lang .. ":" .. cat)             if script then              table.insert(categories, lang .. ":" .. cat .. " in " .. script .. " script")          end             if script2 then              table.insert(categories2, lang .. ":" .. cat .. " in " .. script2 .. " script")          end      end         for i, cat in ipairs(data.pos_categories or {}) do          table.insert(categories, langinfo.names[1] .. " " .. cat)             if script then              table.insert(categories, langinfo.names[1] .. " " .. cat .. " in " .. script .. " script")          end             if script2 then              table.insert(categories2, langinfo.names[1] .. " " .. cat .. " in " .. script2 .. " script")          end      end         for i, cat in ipairs(data.regional_categories or {}) do          table.insert(categories, cat .. " " .. langinfo.names[1])             if script then              table.insert(categories, cat .. " " .. langinfo.names[1] .. " in " .. script .. " script")          end             if script2 then              table.insert(categories2, cat .. " " .. langinfo.names[1] .. " in " .. script2 .. " script")          end      end         for i, cat in ipairs(data.plain_categories or {}) do          table.insert(categories, cat)             if script then              table.insert(categories, cat .. " in " .. script .. " script")          end             if script2 then              table.insert(categories2, cat .. " in " .. script2 .. " script")          end      end         return m_utilities.format_categories(categories, lang, sort_key) .. m_utilities.format_categories(categories2, lang, sort_key2)  end     function get_data(label)      local data = {}         -- Is this label a known/recognised label?      if m_labeldata.labels[label] then          data = mw.clone(m_labeldata.labels[label])      else          -- Does a valid context label template exist for this label?          local label_template = mw.title.new("Template:" .. label)          local frame = mw.getCurrentFrame()             if label_template and label_template.exists and frame:expandTemplate{ title = label, args = { ["sub"] = "test" } } == "valid context label" then              data.display = frame:expandTemplate{ title = label, args = {["sub"] = "helper2", [1] = "label"} }; if data.display == "" then data.display = nil end              data.next_label = frame:expandTemplate{ title = label, args = {["sub"] = "helper2", [1] = "next"} }; if data.next_label == "" then data.next_label = nil end              data.topical_categories = frame:expandTemplate{ title = label, args = {["sub"] = "helper2", [1] = "topcat"} }; if data.topical_categories == "" then data.topical_categories = nil end              data.pos_categories = frame:expandTemplate{ title = label, args = {["sub"] = "helper2", [1] = "poscat"} }; if data.pos_categories == "" then data.pos_categories = nil end              data.regional_categories = frame:expandTemplate{ title = label, args = {["sub"] = "helper2", [1] = "regcat"} }; if data.regional_categories == "" then data.regional_categories = nil end              data.plain_categories = frame:expandTemplate{ title = label, args = {["sub"] = "helper2", [1] = "cat"} }; if data.plain_categories == "" then data.plain_categories = nil end                 data.topical_categories = data.topical_categories and {data.topical_categories} or nil              data.pos_categories = data.pos_categories and {data.pos_categories} or nil              data.regional_categories = data.regional_categories and {data.regional_categories} or nil              data.plain_categories = data.plain_categories and {data.plain_categories} or nil          end      end         return data  end     return export  

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions