fbpx
วิกิพีเดีย

มอดูล:Lang/documentor tool

คู่มือการใช้งานมอดูล[ดู] [แก้] [ประวัติ] [ล้างแคช]

มอดูล:Lang/documentor tool ใช้โดยแม่แบบต่อไปนี้:

require('มอดูล:No globals') local p = {}   --[[ -------------------------- < L A N G - X X _ S E T T I N G S > --------------------------  {{#invoke:Lang/documentor tool|lang_xx_settings|template={{ROOTPAGENAME}}}}  Reads the content of the template and extracts the parameters from {{#invoke:Lang|...}} for display on the template's documentation page.  ]]  local function lang_xx_settings(frame)  local page = mw.title.makeTitle('Template', frame.args['template'] or frame.args[1]) -- get a page object for this page in 'Template:' namespace  if not page then  return '' -- TODO: error message?  end   local content = page:getContent() -- get unparsed content  if not page then  return '' -- TODO: error message?  end   local out = {}   local params  local style   if content:match('{{%s*#invoke:%s*[Ll]ang%s*|[^|]+|[^}]+}}') or content:match('{{%s*#invoke:%s*[Ll]ang/sandbox%s*|[^|]+|[^}]+}}') then -- if this template uses [[Module:Lang]]  params = content:match('{{%s*#invoke:%s*[Ll]ang%s*|[^|]+(|[^}]+)}}') or content:match('{{%s*#invoke:%s*[Ll]ang/sandbox%s*|[^|]+(|[^}]+)}}') -- extract the #invoke:'s parameters  if not params then  return '' -- there should be at least one or the template/module won't work TODO: error message?  end  table.insert(out, '{| class="wikitable" style="text-align: right; float: right;"\n|+settings') -- start a wikitable  for k, v in params:gmatch('%s*|%s*([^%s=]+)%s*=%s*([^%s|]+)') do -- get the parameter names (k) and values (v)  if 'label' == k then -- special case for labels because spaces and pipes  v = params:match('label%s*=%s*(%[%[[^%]]+%]%])') or params:match('label%s*=%s*([^|\n]+)') or 'missing label'  end  table.insert(out, table.concat({k, '\n|', v})) -- make rudimentary wikitable entries  end   style = content:match('lang_xx_([^|]+)')  return table.concat({table.concat(out,'\n|-\n! scope="row" | '), '\n|-\n|colspan="2"|style: ', style, '\n|-\n|}'}) -- add inter-row markup and close the wikitable and done  else  return '' -- does not use [[Module:Lang]] so abandon quietly  end end   --[[ -------------------------- < U S E S _ M O D U L E > --------------------------  {{#invoke:Lang/documentor tool|uses_module|template={{ROOTPAGENAME}}}}  Reads the content of the template to determine if this {{lang-xx}} template uses Module:Lang. Returns the index of the substring '{{#invoke|lang|' in the template page content if true; empty string if false.  Used in template documentation {{#if:}} parser functions.  ]]  local function uses_module(frame)  local page = mw.title.makeTitle('Template', frame.args['template'] or frame.args[1]) -- get a page object for this page in 'Template:' namespace  if not page then  return '' -- TODO: error message?  end   local content = page:getContent() -- get unparsed content  if not page then  return '' -- TODO: error message?  end   return content:find('{{%s*#invoke:[Ll]ang%s*|') or '' -- return index or empty string end   --[[ -------------------------- < S H A R E D _ C O D E > --------------------------  - Tables: -- language_categories -- error_messages -- strings  - Functions: -- make_error(message, layout, parent_category, nocat) -- get_language_link(language_name, language_code) -- get_see_also_section(page_title, language_name, language_code) -- get_hidden_category_template(frame) -- get_top_section(frame) -- get_bottom_section(frame, language_name, see_also_section, parent_category)  ]]  local language_categories = {  ["LANGUAGES_SOURCES"] = "บทความที่มีแหล่งที่มาภาษา%s (%s)",  ["LANGUAGES_COLLECTIVE_SOURCES"] = "บทความที่มีแหล่งรวมภาษา%s (%s)",  ["CS1"] = "CS1 แหล่งที่มาภาษา%s (%s)",  ["LANGUAGE_TEXT"] = "บทความที่มีข้อความภาษา%s",  -- old version ["LANGUAGES_COLLECTIVE_TEXT"] = "Articles with text from the %s collective",  ["LANGUAGES_COLLECTIVE_TEXT"] = "บทความที่มีข้อความภาษา%s",  ["THAI"] = "บทความที่มีข้อความภาษา%sอ้างอิงอย่างชัดเจน", }  local error_assistance = "โปรดดู [[คุยเรื่องแม่แบบ:Lang]] สำหรับความช่วยเหลือ"  local error_messages = {  ["ASSISTANCE"] = "โปรดดู [[คุยเรื่องแม่แบบ:Lang]] สำหรับความช่วยเหลือ",  ["INCORRECT_CATEGORY_TITLE"] = "[[:%s]] ไม่ใช่หมวดหมู่ที่สร้างโดยแม่แบบ {{tlx|%s}} หมวดหมู่ที่ถูกต้องอยู่ที่: [[:%s]]",  ["NO_CATEGORY_TITLE_FOUND"] = "ไม่พบหมวดหมู่ภาษาสำหรับ'''%s'''" .. error_assistance,  ["NOT_VALID_CATEGORY_FORMAT"] = "'''%s'''ไม่ใช่ชื่อหมวดหมู่ที่ถูกต้อง" .. error_assistance,  ["NOT_VALID_LANGUAGE_CODE"] = "[[%s]]ไม่ใช่ชื่อภาษา ISO 639 หรือ IETF ที่ถูกต้อง" .. error_assistance, }  local strings = {  ["ERROR_CATEGORY"] = "[[หมวดหมู่:ข้อผิดพลาดแม่แบบ Lang และ lang-xx]]",  ["ERROR_SPAN"] = '<span style="font-size: 100%%; font-style: normal;" class="error">ข้อผิดพลาด: %s </span>',  ["PURGE_DIV"] = '<div style="font-size: x-small;">%s</div>',  ["SEE_ALSO"] = "\n==ดูเพิ่ม==",  ["SEE_ALSO_ITEM"] = "* [[:%s]]", }   --[[ -------------------------- < M A K E _ E R R O R > --------------------------  Create an error message. Does not place page in error category if args.nocat is used. Does not categorize in parent cateogory if used in category namespace (usually for /testcases).  ]]  local function make_error(message, layout, parent_category, nocat)  table.insert(layout, string.format(strings["ERROR_SPAN"], message))   if not nocat then  table.insert(layout, strings["ERROR_CATEGORY"])  end   if mw.title.getCurrentTitle().nsText == "หมวดหมู่" then  table.insert(layout, parent_category)  end   return table.concat(layout) end   --[[ -------------------------- < G E T _ L A N G U A G E _ L I N K > --------------------------  Generates a language link for the correct style.  Collective languages use the name_from_tag value, while other languages use a display name of "x-language".  ]]  local function get_language_link(language_name, language_code)  local lang_module = require('มอดูล:Lang')  -- Is a language collective?  if language_name:find('languages') then  return lang_module.name_from_tag({language_code, link = "yes"})  else  return lang_module.name_from_tag({language_code, link = "yes", label = "ภาษา" .. lang_module.name_from_tag({language_code})})  end end   --[[ -------------------------- < G E T _ S E E _ A L S O _ S E C T I O N > --------------------------  Generates a consistent style See also section for {{Category articles containing non-English-language text}} and {{Non-English-language source category}}.  If {{CS1 language sources}} is converted, it should also use it.  ]]  local function get_see_also_section(page_title, language_name, language_code)  local see_also_section = {}   for _, category_name in pairs(language_categories) do  local category = mw.title.new(string.format(category_name, language_name, language_code), 14)  if category and page_title ~= category.text and category.exists then  table.insert(see_also_section, string.format(strings["SEE_ALSO_ITEM"], category.prefixedText))  end  end   table.sort(see_also_section)  table.insert(see_also_section, 1, strings["SEE_ALSO"])   if table.getn(see_also_section) == 1 then  return ""  else  return table.concat(see_also_section, "\n")  end end   --[[ -------------------------- < G E T _ H I D D E N _ C A T E G O R Y _ T E M P L A T E > --------------------------  Generates the Template:Hidden category template.  This function is separate from the get_top_section() function as this should be used in both error categories and valid categories.  ]]  local function get_hidden_category_template(frame)  return frame:expandTemplate{title = 'หมวดหมู่ซ่อน'} end   --[[ -------------------------- < G E T _ T O P _ S E C T I O N > --------------------------  Generates a consistent top maintenance template section which consists of: -- Template:Possibly empty category -- Template:Purge  ]]  local function get_top_section(frame)  local top_section = {}  if mw.site.stats.pagesInCategory(mw.title.getCurrentTitle().text, "all") == 0 then  table.insert(top_section, frame:expandTemplate{title = 'หมวดหมู่อาจว่าง'})  else  table.insert(top_section, frame:expandTemplate{title = 'หมวดหมู่อาจว่าง', args = {hidden=true}})  end   local purge_module = require('มอดูล:Purge')  table.insert(top_section, string.format(strings["PURGE_DIV"], purge_module._main({"ล้างแคชของหน้า"})))   return table.concat(top_section, "\n\n") end   --[[ -------------------------- < G E T _ B O T T O M _ S E C T I O N > --------------------------  Generates a consistent non-text section which consists of: -- Template:CatAutoTOC -- A see also section -- {{DEFAULTSORT}} -- Categorization in parent category  ]]  local function get_bottom_section(frame, language_name, see_also_section, parent_category)  local bottom_section = {}  table.insert(bottom_section, frame:expandTemplate{title = 'CatAutoTOC'})  table.insert(bottom_section, see_also_section)   if mw.title.getCurrentTitle().nsText == "หมวดหมู่" then  table.insert(bottom_section, frame:preprocess{text = "{{DEFAULTSORT:" .. language_name .. "}}"})  table.insert(bottom_section, parent_category)  end   return table.concat(bottom_section, "\n\n\n") end   --[[ -------------------------- < N O N _ T H A I _ L A N G U A G E _ T E X T _ C A T E G O R Y > --------------------------  {{#invoke:Lang/documentor tool|non_thai_language_text_category}}  ฟังก์ชันนี้ใช้โดย {{หมวดหมู่ข้อความไม่ใช่ภาษาไทย}}  ]]  local non_thai_language_text_strings = {  ["LINE1"] = "หมวดหมู่นี้ประกอบด้วยบทความที่มีข้อความ%s%s วัตถุประสงค์หลักของหมวดหมู่นี้คือเพื่ออำนวยความสะดวกในการตรวจสอบข้อความในภาษาอื่นด้วยตนเองหรือโดยอัตโนมัติ",  ["LINE2"] = "ควรเพิ่มบทความในหมวดหมู่เหล่านี้ด้วย %s เท่านั้น ไม่ควรระบุโดยตรง",  ["LINE3"] = 'ตัวอย่างเช่น %s ซึ่งล้อมรอบข้อความด้วย <code>&lt;span lang="%s"&gt;</code>%s',  ["LINE3_EXTRA"] = "นอกจากนี้ยังมีให้ใช้งานคือ %s ซึ่งแสดงเป็น %s",  ["IN_SCRIPT"] = " (ในภาษา %s)",  ["EXAMPLE_DEFAULT_TEXT"] = "ข้อความในภาษา%sที่นี่",  ["PARENT_CATEGORY"] = "[[หมวดหมู่:บทความที่มีข้อความไม่ใช่ภาษาไทย]]",  ["TEMPLATE"] = "Lang", }  local function non_thai_language_text_category(frame)  local page = mw.title.getCurrentTitle()  local args = require('มอดูล:Arguments').getArgs(frame)  -- args.test is used for /testcases  if args.test then  page = mw.title.new(args.test)  end   -- Naming style: Articles with text from the Berber languages collective  local page_title_modified = page.text  local split_title = "([^,]+)%%s([^,]*)"  local part1 = ""  local part2 = ""   if page_title_modified:find('บทความที่มีข้อความในภาษา') then  -- Naming style: Category:Articles with text from Afro-Asiatic languages (as currently implemented in Module:lang)  part1, part2 = language_categories["LANGUAGES_COLLECTIVE_TEXT"]:match(split_title)  elseif page_title_modified:find('อ้างอิงอย่างชัดเจน') then  part1, part2 = language_categories["THAI"]:match(split_title)  else  -- Naming style: Category:Articles containing French-language text  part1, part2 = language_categories["LANGUAGE_TEXT"]:match(split_title)  end   page_title_modified = page_title_modified:gsub(part1, "")  page_title_modified = page_title_modified:gsub(part2, "")  local language_name = page_title_modified   local layout = {}  table.insert(layout, get_hidden_category_template(frame))  local parent_category = non_thai_language_text_strings["PARENT_CATEGORY"]   if language_name == page.text then  -- Error: Category title format not supported.  return make_error(string.format(error_messages["NOT_VALID_CATEGORY_FORMAT"], page.text), layout, parent_category, args.nocat)  end   local lang_module = require('มอดูล:Lang')  local language_code = lang_module._tag_from_name({language_name})   if language_code:find('error') then  -- Error: Language code not found in database.  return make_error(string.format(error_messages["NOT_VALID_LANGUAGE_CODE"], language_name), layout, parent_category, args.nocat)  end   local correct_language_category_title = lang_module._category_from_tag({language_code})  if correct_language_category_title:find('error') then  -- Error: No category title found for language code.  return make_error(string.format(error_messages["NO_CATEGORY_TITLE_FOUND"], language_code), layout, parent_category, args.nocat)  end   local current_category_title = page.prefixedText  if current_category_title ~= correct_language_category_title then  -- Error: The current title used is not in the supported format. TODO: can this still be reached?  return make_error(  string.format(error_messages["INCORRECT_CATEGORY_TITLE"], current_category_title, non_thai_language_text_strings["LANG"], correct_language_category_title),  layout, parent_category, args.nocat)  end   table.insert(layout, get_top_section(frame))   local script_text = ""  if args.script then  script_text = string.format(non_thai_language_text_strings["IN_SCRIPT"], args.script)  end   local language_link = get_language_link(language_name, language_code)  table.insert(layout, string.format(non_thai_language_text_strings["LINE1"], language_link, script_text))   local lang_template = frame:expandTemplate{title = 'Tl', args = {non_thai_language_text_strings["TEMPLATE"]}}  table.insert(layout, string.format(non_thai_language_text_strings["LINE2"], lang_template))   local language_code_link = lang_module._name_from_tag({language_code, link="yes", label=language_code})  local example_default_text = string.format(non_thai_language_text_strings["EXAMPLE_DEFAULT_TEXT"], language_name)  local example_text = args.example or example_default_text  local lang_template_example = frame:expandTemplate{title = 'Tlx', args = {non_thai_language_text_strings["TEMPLATE"], language_code_link, example_text}}  local lang_x = mw.title.makeTitle(10, "Lang-" .. language_code)   local line3_extra = ""  if lang_x.exists then  local lang_x_template_example = frame:expandTemplate{title = 'Tlx', args = {lang_x.text, example_text}}  local lang_x_template = frame:expandTemplate{title = lang_x.text, args = {example_text}}  line3_extra = string.format(non_thai_language_text_strings["LINE3_EXTRA"], lang_x_template_example, lang_x_template)  end   table.insert(layout, string.format(non_thai_language_text_strings["LINE3"], lang_template_example, language_code, line3_extra))  local see_also_section = get_see_also_section(page.text, language_name, language_code)   local bottom = get_bottom_section(frame, language_name, see_also_section, non_thai_language_text_strings["PARENT_CATEGORY"])  return table.concat(layout, "\n\n") .. bottom end   --[[ -------------------------- < N O N _ T H A I _ L A N G U A G E _ S O U R C E S _ C A T E G O R Y > --------------------------  {{#invoke:Lang/documentor tool|non_thai_language_sources_category}}  ฟังก์ชันนี้ใช้โดย {{หมวดหมู่แหล่งที่มาไม่ใช่ภาษาไทย}}  ]]  local non_thai_language_sources_strings = {  ["LINE1"] = "หมวดหมู่การติดตามสำหรับบทความที่ใช้ %s เพื่อระบุแหล่งที่มา%s",  ["PARENT_CATEGORY"] = "[[หมวดหมู่:บทความที่มีแหล่งที่มาไม่ใช่ภาษาไทย]]",  ["TEMPLATE"] = "In lang", }  local function non_thai_language_sources_category(frame)  local page = mw.title.getCurrentTitle()  local args = require('มอดูล:Arguments').getArgs(frame)  -- args.test is used for /testcases  if args.test then  page = mw.title.new(args.test)  end   local page_title = page.text  local language_code = page_title:match('%(([%a%-]+)%)')  local language_name = require('มอดูล:Lang')._name_from_tag({language_code})   local layout = {}  table.insert(layout, get_hidden_category_template(frame))  local parent_category = non_thai_language_sources_strings["PARENT_CATEGORY"]   local correct_language_category_title = require('มอดูล:In lang')._in_lang({language_code, ["list-cats"]="yes"})  if correct_language_category_title == "" then  -- Error: No category title found for language code.  return make_error(string.format(error_messages["NO_CATEGORY_TITLE_FOUND"], language_code), layout, parent_category, args.nocat)  end   local current_category_title = page.prefixedText  if correct_language_category_title ~= current_category_title then  -- Error: The current title used is not in the supported format.  return make_error(  string.format(error_messages["INCORRECT_CATEGORY_TITLE"], current_category_title, non_thai_language_sources_strings["TEMPLATE"], correct_language_category_title),  layout, parent_category, args.nocat)  end   local language_link = get_language_link(language_name, language_code)  local text = string.format(non_thai_language_sources_strings["LINE1"], frame:expandTemplate{title = 'Tlx', args = {non_thai_language_sources_strings["TEMPLATE"], language_code}}, language_link)   table.insert(layout, get_top_section(frame))  table.insert(layout, text)  local see_also_section = get_see_also_section(page_title, language_name, language_code)   local bottom = get_bottom_section(frame, language_name, see_also_section, parent_category)  return table.concat(layout, "\n\n") .. bottom end   --[[ -------------------------- < N O N _ E N G L I S H _ L A N G U A G E _ C S 1 _ S O U R C E S _ C A T E G O R Y > --------------------------  {{#invoke:Lang/documentor tool|non_english_language_cs1_sources_category}}  This function implements {{Non-English-language CS1 sources category}}.  ]]  local non_english_language_cs1_text_strings = {  ["LINE1"] = "This is a tracking category for [[WP:CS1|CS1 citations]] that use the parameter %s to identify a source in [[%s language|%s]]. Pages in this category should only be added by CS1 templates and [[Module:Citation/CS1]].",  ["PARENT_CATEGORY"] = "[[Category:CS1 foreign language sources]]", -- #TODO change to "Articles with non-english CS1 language sources" or "CS1 non-English language sources" }   --"This is a tracking category for [[WP:CS1|CS1 citations]] that use the parameter %s to hold a citation title that uses %s characters and contains the language prefix <code>%s:</code>. Pages in this category should only be added by CS1 templates and [[Module:Citation/CS1]].",  --"[[Category:CS1 uses foreign language script]]",   -- "This is a tracking category for [[WP:CS1|CS1 citations]] that use the parameter %s. Pages in this category should only be added by CS1 templates and [[Module:Citation/CS1]].",  -- "to identify a source in [[%s language|%s]].",  -- "to hold a citation title that uses %s characters and contains the language prefix <code>%s:</code>.",  local function non_english_language_cs1_sources_category(frame)  local page_title_object = mw.title.getCurrentTitle()  local page_title = page_title_object.text  local language_code = page_title:match('%(([%a%-]+)%)')  local language_name = require('มอดูล:Lang')._name_from_tag({language_code})  local layout = {}  table.insert(layout, get_hidden_category_template(frame))  local see_also_section = ""  local parameter_doc = frame:expandTemplate{title = 'para', args = {"language", language_code}}  table.insert(layout, get_top_section(frame))  table.insert(layout, string.format(non_english_language_cs1_text_strings["LINE1"], parameter_doc, language_name, language_name))  local see_also_section = get_see_also_section(page_title, language_name, language_code)  local bottom = get_bottom_section(frame, language_name, see_also_section, non_english_language_cs1_text_strings["PARENT_CATEGORY"])  return table.concat(layout, "\n\n") .. bottom end   --[[ -------------------------- < T E S T _ C A S E S _ S H A R E D _ C O D E > --------------------------   ]]  local function compare_by_keys2(a, b) -- local function used by table.sort()  return a[2] < b[2] -- ascending sort by code end   local function compare_by_keys(a, b) -- local function used by table.sort()  return a[1] < b[1] -- ascending sort by code end   -- Used by testcases_iso_code_to_name() local function get_language_code_table_from_code(args)  local entry = {}  --if args.override_table[args.language_code] then  -- table.insert(entry, args.override_table[args.language_code][1]) -- :gsub(' %b()$', '') fails here  --else  table.insert(entry, args.language_code) -- end  return entry end   -- Used by testcases_name_from_tag() local function get_language_code_and_name_table_from_code(args)  local entry = {}  if args.override_table[args.language_code] then  table.insert(entry, args.language_code)  local language_code, _ = args.override_table[args.language_code][1]:gsub(' %b()$', '')  table.insert(entry, language_code)  else  table.insert(entry, args.language_code)  table.insert(entry, args.language_table[args.language_code])  end  return entry end   -- Used by testcases_category_from_tag() local function get_language_code_and_category_table_from_code(args)  local entry = {}  table.insert(entry, args.language_code)  table.insert(entry, args.test_function({args.language_code}))  return entry end   -- Used by testcases_iso_name_to_code() and testcases_tag_from_name() local function get_language_name_and_code_table_from_code(args)  local entry = {}  if args.override_table[args.language_code] then  table.insert(entry, args.override_table[args.language_code][1]) -- only the first name when there are multiples  table.insert(entry, args.language_code)  else  table.insert(entry, args.language_names[1]) -- only the first name when there are multiples  table.insert(entry, args.language_code)  end  return entry end   local function get_table(table_function, language_table, length, range, iso_number, test_function)  local table_of_language_name_and_code_tables = {}   local override_table_name = "override"  if iso_number then  override_table_name = "override_" .. iso_number  end  local override_table = require("Module:Language/data/ISO_639_override/sandbox")[override_table_name]   -- For most ISO 639s.  if range then  for language_code, language_names in pairs(language_table) do  if language_code:find(range) then  table.insert(table_of_language_name_and_code_tables, table_function({  override_table = override_table,  language_code = language_code,  language_names = language_names,  test_function = test_function,  language_table = language_table  }))  end  end  -- For ISO 639-1.  elseif length then  for language_code, language_names in pairs(language_table) do  if language_code:len() == 2 then  table.insert(table_of_language_name_and_code_tables, table_function({  override_table = override_table,  language_code = language_code,  language_names = language_names,  test_function = test_function,  language_table = language_table  }))  end  end  -- For general /testcases.  else  for language_code, language_names in pairs(language_table) do  table.insert(table_of_language_name_and_code_tables, table_function({  override_table = override_table,  language_code = language_code,  language_names = language_names,  test_function = test_function,  language_table = language_table  }))  end  end  return table_of_language_name_and_code_tables end   local function get_undabbed_table(language_list, length, range)  local undabbed_language_table = {} -- for this test, ISO 639-3 language name disambiguators must be removed; un-dabbed names go here  for language_code, language_names in pairs(language_list) do  -- For most ISO 639s.  if range then  if language_code:find(range) then  undabbed_language_table[language_code] = language_names[1]:gsub(' %b()$', '') -- undab and save only the first name; ignore all other names assigned to a code  end  -- For ISO 639-1.  elseif length then  if language_code:len() == 2 then  undabbed_language_table[language_code] = language_names[1]:gsub(' %b()$', '') -- undab and save only the first name; ignore all other names assigned to a code  end  -- For general /testcases.  else  undabbed_language_table[language_code] = language_names[1]:gsub(' %b()$', '')  end  end  return undabbed_language_table end   --[[ -------------------------- < T E S T C A S E S _ C A T E G O R Y _ F R O M _ T A G > --------------------------  Entry point for the various category_from_tag testcases.  Build a table of test patterns where each entry in the table is a table with two members:  {"<language_code>", "<category name according to Module:Lang>"}  - "Expected" column value is the category name according to Module:Lang. - "Actual" column value is the result of {{#invoke:Lang/sandbox|category_from_tag|<language_code>}}.  TODO: Currently not working.  ]]  local function testcases_category_from_tag(self, args)  local cat_from_tag_function = require('มอดูล:Lang')._category_from_tag  local language_tables = get_table(get_language_code_and_category_table_from_code, args.language_list, args.length, args.range, args.iso_number, cat_from_tag_function)  table.sort(language_tables, compare_by_keys)   self:preprocess_equals_preprocess_many(  '{{#invoke:Lang/sandbox|category_from_tag|', '}}', '', '',  language_tables,  {nowiki=false}  ) end   --[[ -------------------------- < T E S T C A S E S _ N A M E _ F R O M _ T A G > --------------------------  Entry point for the various name_from_tag testcases.  Build a table of test patterns where each entry in the table is a table with two members:  {"<language_code>", "<language_name>"}  - "Expected" column value is the <language_name>. - "Actual" column value is the result of sandbox version {{#invoke:Lang/sandbox|name_from_tag|<language_code>}}.  ]]  local function testcases_name_from_tag(self, args)  local undabbed_language_table = get_undabbed_table(args.language_list, args.length, args.range, nil)  local language_tables = get_table(get_language_code_and_name_table_from_code, undabbed_language_table, args.length, args.range)  table.sort(language_tables, compare_by_keys)   self:preprocess_equals_preprocess_many(  '{{#invoke:Lang/sandbox|name_from_tag|', '}}', '', '',  language_tables,  {nowiki=false}  ) end   --[[ -------------------------- < T E S T C A S E S _ T A G _ F R O M _ N A M E > --------------------------  Entry point for the various tag_from_name testcases.  Build a table of test patterns where each entry in the table is a table with two members:  {"<language_name>", "<language_code>"}  - "Expected" column value is the <language_code>. - "Actual" column value is the result of sandbox version {{#invoke:Lang/sandbox|tag_from_name|<language_name>}}.  TODO: Currently not working.  ]]  local function testcases_tag_from_name(self, args)  local language_tables = get_table(get_language_name_and_code_table_from_code, args.language_list, args.length, args.range, args.iso_number, nil)  table.sort(language_tables, compare_by_keys2)   local ordered_table = {}  table.sort(unordered_table)  for _, key in ipairs(unordered_table) do  table.insert(ordered_table, {key, reverse_table[key]})  end   self:preprocess_equals_preprocess_many(  '{{#invoke:Lang/sandbox|tag_from_name|', '}}', '', '',  language_tables,  {nowiki=false}  ) end   --[[ -------------------------- < T E S T C A S E S _ I S O _ C O D E _ T O _ N A M E > --------------------------  Entry point for the various iso_code_to_name testcases.  Build a table of test patterns where each entry in the table is a table with one member:  {"<language_code>"}  - "Expected" column value is the result of the live version of {{#invoke:ISO 639 name|iso_639_name_to_code|<language_code>}}. - "Actual" column value is the result of sandbox version {{#invoke:ISO 639 name/sandbox|iso_639_name_to_code|<language_code>}}.  ]]  local function testcases_iso_code_to_name(self, args)  local language_tables = get_table(get_language_code_table_from_code, args.language_list, args.length, args.range, args.iso_number, nil)  table.sort(language_tables, compare_by_keys)   self:preprocess_equals_preprocess_many(  '{{#invoke:ISO 639 name/sandbox|iso_639_code_to_name|link=yes|', '}}', '{{#invoke:ISO 639 name|iso_639_code_to_name|link=yes|', '}}',  language_tables,  {nowiki=false}  ) end   --[[ -------------------------- < T E S T C A S E S _ I S O _ N A M E _ T O _ C O D E > --------------------------  Entry point for the various iso_name_to_code testcases.  Build a table of test patterns where each entry in the table is a table with two members:  {"<language_name>", "<language_code>"}  - "Expected" column value is the <language_code>. - "Actual" column is value the result of {{#invoke:ISO 639 name/sandbox|iso_639_name_to_code|<language_name>}}.  ]]  local function testcases_iso_name_to_code(self, args)  local language_tables = get_table(get_language_name_and_code_table_from_code, args.language_list, args.length, args.range, args.iso_number, nil)  table.sort(language_tables, compare_by_keys2)  self:preprocess_equals_preprocess_many(  '{{#invoke:ISO 639 name/sandbox|iso_639_name_to_code|2=' .. args.iso_number .. "|", '}}', '', '',  language_tables,  {nowiki=false}  ) end   --[[ -------------------------- < E X P O R T E D _ F U N C T I O N S > --------------------------  ]]  return {  lang_xx_settings = lang_xx_settings,  uses_module = uses_module,  non_thai_language_text_category = non_thai_language_text_category,  non_thai_language_sources_category = non_thai_language_sources_category,  non_english_language_cs1_sources_category = non_english_language_cs1_sources_category,   -- Module:Lang testcases  testcases_category_from_tag = testcases_category_from_tag,  testcases_name_from_tag = testcases_name_from_tag,  testcases_tag_from_name = testcases_tag_from_name,   -- Module:ISO 639 name testcases  testcases_iso_code_to_name = testcases_iso_code_to_name,  testcases_iso_name_to_code = testcases_iso_name_to_code, } 

มอด, lang, documentor, tool, อการใช, งานมอด, แก, ประว, างแคช, แม, แบบน, ใช, สคร, ปต, ภาษาล, อา, มอด, argumentsมอด, globalsมอด, langมอด, langมอด, purge, ใช, โดยแม, แบบต, อไปน, หมวดหม, อความไม, ใช, ภาษาไทย, หมวดหม, แหล, งท, มาไม, ใช, ภาษาไทย, lang, อการใช, งานท,. khumuxkarichnganmxdul du aek prawti langaekhch aemaebbniichskhriptphasaluxa mxdul Argumentsmxdul No globalsmxdul In langmxdul Langmxdul Purgemxdul Lang documentor tool ichodyaemaebbtxipni hmwdhmukhxkhwamimichphasaithy hmwdhmuaehlngthimaimichphasaithy Lang x doc khumuxkarichnganthipraktdanbnnidungmacak mxdul Lang documentor tool doc aek prawti phuekhiynsamarththakarthdlxngidthikrabathray srang khdlxk aelachudthdsxb srang khxngmxdulni hnayxykhxngmxdulnirequire mxdul No globals local p lt L A N G X X S E T T I N G S gt invoke Lang documentor tool lang xx settings template ROOTPAGENAME Reads the content of the template and extracts the parameters from invoke Lang for display on the template s documentation page local function lang xx settings frame local page mw title makeTitle Template frame args template or frame args 1 get a page object for this page in Template namespace if not page then return TODO error message end local content page getContent get unparsed content if not page then return TODO error message end local out local params local style if content match s invoke s Ll ang s or content match s invoke s Ll ang sandbox s then if this template uses Module Lang params content match s invoke s Ll ang s or content match s invoke s Ll ang sandbox s extract the invoke s parameters if not params then return there should be at least one or the template module won t work TODO error message end table insert out class wikitable style text align right float right n settings start a wikitable for k v in params gmatch s s s s s s do get the parameter names k and values v if label k then special case for labels because spaces and pipes v params match label s s or params match label s s n or missing label end table insert out table concat k n v make rudimentary wikitable entries end style content match lang xx return table concat table concat out n n scope row n n colspan 2 style style n n add inter row markup and close the wikitable and done else return does not use Module Lang so abandon quietly end end lt U S E S M O D U L E gt invoke Lang documentor tool uses module template ROOTPAGENAME Reads the content of the template to determine if this lang xx template uses Module Lang Returns the index of the substring invoke lang in the template page content if true empty string if false Used in template documentation if parser functions local function uses module frame local page mw title makeTitle Template frame args template or frame args 1 get a page object for this page in Template namespace if not page then return TODO error message end local content page getContent get unparsed content if not page then return TODO error message end return content find s invoke Ll ang s or return index or empty string end lt S H A R E D C O D E gt Tables language categories error messages strings Functions make error message layout parent category nocat get language link language name language code get see also section page title language name language code get hidden category template frame get top section frame get bottom section frame language name see also section parent category local language categories LANGUAGES SOURCES bthkhwamthimiaehlngthimaphasa s s LANGUAGES COLLECTIVE SOURCES bthkhwamthimiaehlngrwmphasa s s CS1 CS1 aehlngthimaphasa s s LANGUAGE TEXT bthkhwamthimikhxkhwamphasa s old version LANGUAGES COLLECTIVE TEXT Articles with text from the s collective LANGUAGES COLLECTIVE TEXT bthkhwamthimikhxkhwamphasa s THAI bthkhwamthimikhxkhwamphasa sxangxingxyangchdecn local error assistance oprddu khuyeruxngaemaebb Lang sahrbkhwamchwyehlux local error messages ASSISTANCE oprddu khuyeruxngaemaebb Lang sahrbkhwamchwyehlux INCORRECT CATEGORY TITLE s imichhmwdhmuthisrangodyaemaebb tlx s hmwdhmuthithuktxngxyuthi s NO CATEGORY TITLE FOUND imphbhmwdhmuphasasahrb s error assistance NOT VALID CATEGORY FORMAT s imichchuxhmwdhmuthithuktxng error assistance NOT VALID LANGUAGE CODE s imichchuxphasa ISO 639 hrux IETF thithuktxng error assistance local strings ERROR CATEGORY hmwdhmu khxphidphladaemaebb Lang aela lang xx ERROR SPAN lt span style font size 100 font style normal class error gt khxphidphlad s lt span gt PURGE DIV lt div style font size x small gt s lt div gt SEE ALSO n duephim SEE ALSO ITEM s lt M A K E E R R O R gt Create an error message Does not place page in error category if args nocat is used Does not categorize in parent cateogory if used in category namespace usually for testcases local function make error message layout parent category nocat table insert layout string format strings ERROR SPAN message if not nocat then table insert layout strings ERROR CATEGORY end if mw title getCurrentTitle nsText hmwdhmu then table insert layout parent category end return table concat layout end lt G E T L A N G U A G E L I N K gt Generates a language link for the correct style Collective languages use the name from tag value while other languages use a display name of x language local function get language link language name language code local lang module require mxdul Lang Is a language collective if language name find languages then return lang module name from tag language code link yes else return lang module name from tag language code link yes label phasa lang module name from tag language code end end lt G E T S E E A L S O S E C T I O N gt Generates a consistent style See also section for Category articles containing non English language text and Non English language source category If CS1 language sources is converted it should also use it local function get see also section page title language name language code local see also section for category name in pairs language categories do local category mw title new string format category name language name language code 14 if category and page title category text and category exists then table insert see also section string format strings SEE ALSO ITEM category prefixedText end end table sort see also section table insert see also section 1 strings SEE ALSO if table getn see also section 1 then return else return table concat see also section n end end lt G E T H I D D E N C A T E G O R Y T E M P L A T E gt Generates the Template Hidden category template This function is separate from the get top section function as this should be used in both error categories and valid categories local function get hidden category template frame return frame expandTemplate title hmwdhmusxn end lt G E T T O P S E C T I O N gt Generates a consistent top maintenance template section which consists of Template Possibly empty category Template Purge local function get top section frame local top section if mw site stats pagesInCategory mw title getCurrentTitle text all 0 then table insert top section frame expandTemplate title hmwdhmuxacwang else table insert top section frame expandTemplate title hmwdhmuxacwang args hidden true end local purge module require mxdul Purge table insert top section string format strings PURGE DIV purge module main langaekhchkhxnghna return table concat top section n n end lt G E T B O T T O M S E C T I O N gt Generates a consistent non text section which consists of Template CatAutoTOC A see also section DEFAULTSORT Categorization in parent category local function get bottom section frame language name see also section parent category local bottom section table insert bottom section frame expandTemplate title CatAutoTOC table insert bottom section see also section if mw title getCurrentTitle nsText hmwdhmu then table insert bottom section frame preprocess text DEFAULTSORT language name table insert bottom section parent category end return table concat bottom section n n n end lt N O N T H A I L A N G U A G E T E X T C A T E G O R Y gt invoke Lang documentor tool non thai language text category fngkchnniichody hmwdhmukhxkhwamimichphasaithy local non thai language text strings LINE1 hmwdhmuniprakxbdwybthkhwamthimikhxkhwam s s wtthuprasngkhhlkkhxnghmwdhmunikhuxephuxxanwykhwamsadwkinkartrwcsxbkhxkhwaminphasaxundwytnexnghruxodyxtonmti LINE2 khwrephimbthkhwaminhmwdhmuehlanidwy s ethann imkhwrrabuodytrng LINE3 twxyangechn s sunglxmrxbkhxkhwamdwy lt code gt amp lt span lang s amp gt lt code gt s LINE3 EXTRA nxkcakniyngmiihichngankhux s sungaesdngepn s IN SCRIPT inphasa s EXAMPLE DEFAULT TEXT khxkhwaminphasa sthini PARENT CATEGORY hmwdhmu bthkhwamthimikhxkhwamimichphasaithy TEMPLATE Lang local function non thai language text category frame local page mw title getCurrentTitle local args require mxdul Arguments getArgs frame args test is used for testcases if args test then page mw title new args test end Naming style Articles with text from the Berber languages collective local page title modified page text local split title s local part1 local part2 if page title modified find bthkhwamthimikhxkhwaminphasa then Naming style Category Articles with text from Afro Asiatic languages as currently implemented in Module lang part1 part2 language categories LANGUAGES COLLECTIVE TEXT match split title elseif page title modified find xangxingxyangchdecn then part1 part2 language categories THAI match split title else Naming style Category Articles containing French language text part1 part2 language categories LANGUAGE TEXT match split title end page title modified page title modified gsub part1 page title modified page title modified gsub part2 local language name page title modified local layout table insert layout get hidden category template frame local parent category non thai language text strings PARENT CATEGORY if language name page text then Error Category title format not supported return make error string format error messages NOT VALID CATEGORY FORMAT page text layout parent category args nocat end local lang module require mxdul Lang local language code lang module tag from name language name if language code find error then Error Language code not found in database return make error string format error messages NOT VALID LANGUAGE CODE language name layout parent category args nocat end local correct language category title lang module category from tag language code if correct language category title find error then Error No category title found for language code return make error string format error messages NO CATEGORY TITLE FOUND language code layout parent category args nocat end local current category title page prefixedText if current category title correct language category title then Error The current title used is not in the supported format TODO can this still be reached return make error string format error messages INCORRECT CATEGORY TITLE current category title non thai language text strings LANG correct language category title layout parent category args nocat end table insert layout get top section frame local script text if args script then script text string format non thai language text strings IN SCRIPT args script end local language link get language link language name language code table insert layout string format non thai language text strings LINE1 language link script text local lang template frame expandTemplate title Tl args non thai language text strings TEMPLATE table insert layout string format non thai language text strings LINE2 lang template local language code link lang module name from tag language code link yes label language code local example default text string format non thai language text strings EXAMPLE DEFAULT TEXT language name local example text args example or example default text local lang template example frame expandTemplate title Tlx args non thai language text strings TEMPLATE language code link example text local lang x mw title makeTitle 10 Lang language code local line3 extra if lang x exists then local lang x template example frame expandTemplate title Tlx args lang x text example text local lang x template frame expandTemplate title lang x text args example text line3 extra string format non thai language text strings LINE3 EXTRA lang x template example lang x template end table insert layout string format non thai language text strings LINE3 lang template example language code line3 extra local see also section get see also section page text language name language code local bottom get bottom section frame language name see also section non thai language text strings PARENT CATEGORY return table concat layout n n bottom end lt N O N T H A I L A N G U A G E S O U R C E S C A T E G O R Y gt invoke Lang documentor tool non thai language sources category fngkchnniichody hmwdhmuaehlngthimaimichphasaithy local non thai language sources strings LINE1 hmwdhmukartidtamsahrbbthkhwamthiich s ephuxrabuaehlngthima s PARENT CATEGORY hmwdhmu bthkhwamthimiaehlngthimaimichphasaithy TEMPLATE In lang local function non thai language sources category frame local page mw title getCurrentTitle local args require mxdul Arguments getArgs frame args test is used for testcases if args test then page mw title new args test end local page title page text local language code page title match a local language name require mxdul Lang name from tag language code local layout table insert layout get hidden category template frame local parent category non thai language sources strings PARENT CATEGORY local correct language category title require mxdul In lang in lang language code list cats yes if correct language category title then Error No category title found for language code return make error string format error messages NO CATEGORY TITLE FOUND language code layout parent category args nocat end local current category title page prefixedText if correct language category title current category title then Error The current title used is not in the supported format return make error string format error messages INCORRECT CATEGORY TITLE current category title non thai language sources strings TEMPLATE correct language category title layout parent category args nocat end local language link get language link language name language code local text string format non thai language sources strings LINE1 frame expandTemplate title Tlx args non thai language sources strings TEMPLATE language code language link table insert layout get top section frame table insert layout text local see also section get see also section page title language name language code local bottom get bottom section frame language name see also section parent category return table concat layout n n bottom end lt N O N E N G L I S H L A N G U A G E C S 1 S O U R C E S C A T E G O R Y gt invoke Lang documentor tool non english language cs1 sources category This function implements Non English language CS1 sources category local non english language cs1 text strings LINE1 This is a tracking category for WP CS1 CS1 citations that use the parameter s to identify a source in s language s Pages in this category should only be added by CS1 templates and Module Citation CS1 PARENT CATEGORY Category CS1 foreign language sources TODO change to Articles with non english CS1 language sources or CS1 non English language sources This is a tracking category for WP CS1 CS1 citations that use the parameter s to hold a citation title that uses s characters and contains the language prefix lt code gt s lt code gt Pages in this category should only be added by CS1 templates and Module Citation CS1 Category CS1 uses foreign language script This is a tracking category for WP CS1 CS1 citations that use the parameter s Pages in this category should only be added by CS1 templates and Module Citation CS1 to identify a source in s language s to hold a citation title that uses s characters and contains the language prefix lt code gt s lt code gt local function non english language cs1 sources category frame local page title object mw title getCurrentTitle local page title page title object text local language code page title match a local language name require mxdul Lang name from tag language code local layout table insert layout get hidden category template frame local see also section local parameter doc frame expandTemplate title para args language language code table insert layout get top section frame table insert layout string format non english language cs1 text strings LINE1 parameter doc language name language name local see also section get see also section page title language name language code local bottom get bottom section frame language name see also section non english language cs1 text strings PARENT CATEGORY return table concat layout n n bottom end lt T E S T C A S E S S H A R E D C O D E gt local function compare by keys2 a b local function used by table sort return a 2 lt b 2 ascending sort by code end local function compare by keys a b local function used by table sort return a 1 lt b 1 ascending sort by code end Used by testcases iso code to name local function get language code table from code args local entry if args override table args language code then table insert entry args override table args language code 1 gsub b fails here else table insert entry args language code end return entry end Used by testcases name from tag local function get language code and name table from code args local entry if args override table args language code then table insert entry args language code local language code args override table args language code 1 gsub b table insert entry language code else table insert entry args language code table insert entry args language table args language code end return entry end Used by testcases category from tag local function get language code and category table from code args local entry table insert entry args language code table insert entry args test function args language code return entry end Used by testcases iso name to code and testcases tag from name local function get language name and code table from code args local entry if args override table args language code then table insert entry args override table args language code 1 only the first name when there are multiples table insert entry args language code else table insert entry args language names 1 only the first name when there are multiples table insert entry args language code end return entry end local function get table table function language table length range iso number test function local table of language name and code tables local override table name override if iso number then override table name override iso number end local override table require Module Language data ISO 639 override sandbox override table name For most ISO 639s if range then for language code language names in pairs language table do if language code find range then table insert table of language name and code tables table function override table override table language code language code language names language names test function test function language table language table end end For ISO 639 1 elseif length then for language code language names in pairs language table do if language code len 2 then table insert table of language name and code tables table function override table override table language code language code language names language names test function test function language table language table end end For general testcases else for language code language names in pairs language table do table insert table of language name and code tables table function override table override table language code language code language names language names test function test function language table language table end end return table of language name and code tables end local function get undabbed table language list length range local undabbed language table for this test ISO 639 3 language name disambiguators must be removed un dabbed names go here for language code language names in pairs language list do For most ISO 639s if range then if language code find range then undabbed language table language code language names 1 gsub b undab and save only the first name ignore all other names assigned to a code end For ISO 639 1 elseif length then if language code len 2 then undabbed language table language code language names 1 gsub b undab and save only the first name ignore all other names assigned to a code end For general testcases else undabbed language table language code language names 1 gsub b end end return undabbed language table end lt T E S T C A S E S C A T E G O R Y F R O M T A G gt Entry point for the various category from tag testcases Build a table of test patterns where each entry in the table is a table with two members lt language code gt lt category name according to Module Lang gt Expected column value is the category name according to Module Lang Actual column value is the result of invoke Lang sandbox category from tag lt language code gt TODO Currently not working local function testcases category from tag self args local cat from tag function require mxdul Lang category from tag local language tables get table get language code and category table from code args language list args length args range args iso number cat from tag function table sort language tables compare by keys self preprocess equals preprocess many invoke Lang sandbox category from tag language tables nowiki false end lt T E S T C A S E S N A M E F R O M T A G gt Entry point for the various name from tag testcases Build a table of test patterns where each entry in the table is a table with two members lt language code gt lt language name gt Expected column value is the lt language name gt Actual column value is the result of sandbox version invoke Lang sandbox name from tag lt language code gt local function testcases name from tag self args local undabbed language table get undabbed table args language list args length args range nil local language tables get table get language code and name table from code undabbed language table args length args range table sort language tables compare by keys self preprocess equals preprocess many invoke Lang sandbox name from tag language tables nowiki false end lt T E S T C A S E S T A G F R O M N A M E gt Entry point for the various tag from name testcases Build a table of test patterns where each entry in the table is a table with two members lt language name gt lt language code gt Expected column value is the lt language code gt Actual column value is the result of sandbox version invoke Lang sandbox tag from name lt language name gt TODO Currently not working local function testcases tag from name self args local language tables get table get language name and code table from code args language list args length args range args iso number nil table sort language tables compare by keys2 local ordered table table sort unordered table for key in ipairs unordered table do table insert ordered table key reverse table key end self preprocess equals preprocess many invoke Lang sandbox tag from name language tables nowiki false end lt T E S T C A S E S I S O C O D E T O N A M E gt Entry point for the various iso code to name testcases Build a table of test patterns where each entry in the table is a table with one member lt language code gt Expected column value is the result of the live version of invoke ISO 639 name iso 639 name to code lt language code gt Actual column value is the result of sandbox version invoke ISO 639 name sandbox iso 639 name to code lt language code gt local function testcases iso code to name self args local language tables get table get language code table from code args language list args length args range args iso number nil table sort language tables compare by keys self preprocess equals preprocess many invoke ISO 639 name sandbox iso 639 code to name link yes invoke ISO 639 name iso 639 code to name link yes language tables nowiki false end lt T E S T C A S E S I S O N A M E T O C O D E gt Entry point for the various iso name to code testcases Build a table of test patterns where each entry in the table is a table with two members lt language name gt lt language code gt Expected column value is the lt language code gt Actual column is value the result of invoke ISO 639 name sandbox iso 639 name to code lt language name gt local function testcases iso name to code self args local language tables get table get language name and code table from code args language list args length args range args iso number nil table sort language tables compare by keys2 self preprocess equals preprocess many invoke ISO 639 name sandbox iso 639 name to code 2 args iso number language tables nowiki false end lt E X P O R T E D F U N C T I O N S gt return lang xx settings lang xx settings uses module uses module non thai language text category non thai language text category non thai language sources category non thai language sources category non english language cs1 sources category non english language cs1 sources category Module Lang testcases testcases category from tag testcases category from tag testcases name from tag testcases name from tag testcases tag from name testcases tag from name Module ISO 639 name testcases testcases iso code to name testcases iso code to name testcases iso name to code testcases iso name to code ekhathungcak https th wikipedia org w index php title mxdul Lang documentor tool amp oldid 9735896, wikipedia, วิกิ หนังสือ, หนังสือ, ห้องสมุด,

บทความ

, อ่าน, ดาวน์โหลด, ฟรี, ดาวน์โหลดฟรี, mp3, วิดีโอ, mp4, 3gp, jpg, jpeg, gif, png, รูปภาพ, เพลง, เพลง, หนัง, หนังสือ, เกม, เกม