Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Lang links: Difference between revisions

From Neodyland Wiki
fix html output of lle
No edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 10: Line 10:


local function lang_list()
local function lang_list()
-- This list was generated with help of query https://quarry.wmcloud.org/query/83535 which
-- This list was generated using the following manual process:
-- collected all the sub-templates on commons. That list was cross checked against a list of
--  1) run query https://quarry.wmcloud.org/query/83535 which collected all
-- language codes supported by MediaWiki. Afterwards each language was given a rank based on
--     the sub-templates on commons and save results into a spreadsheet
-- how many subtemplates do we have for that language code. Maximum rank is 231.
-- 2) download list of language codes supported by MediaWiki from
-- This list is sorted by the language code (see https://en.wikipedia.org/wiki/Wikipedia:Language_order_poll)
--     https://gerrit.wikimedia.org/g/mediawiki/core/%2B/HEAD/includes/languages/data/Names.php
return {'af/72', 'ak/180', 'als/79', 'am/163', 'an/110', 'ang/201', 'ar/10', 'arq/106',  
--    In 2024-12 there were 556 supported languages
'ary/164', 'arz/107', 'as/105', 'ast/81', 'av/202', 'az/58', 'azb/203', 'ba/181', 'ban/150',  
--  3) remove sub-templates which are not names of supported languages.
'bar/47', 'bcl/117', 'be/66', 'be-tarask/33', 'be-x-old/165', 'bg/42', 'bgn/137', 'bh/182',  
--    Use case sensative vlookup ("VLOOKUP(TRUE, CHOOSE({1,2}, EXACT(
'bho/144', 'bjn/204', 'blk/142', 'bn/21', 'bo/205', 'br/73', 'bs/87', 'ca/26', 'ce/108',  
--    lookup_value, lookup_array), return_array), 2, 0)".
'ceb/138', 'ch/166', 'ckb/121', 'co/183', 'cs/17', 'cu/167', 'cy/69', 'da/34', 'dag/114',  
--    In 2024-12 there were 274 supported languages used as subtemplates
'de/4', 'de-at/101', 'de-ch/100', 'de-formal/59', 'dga/206', 'diq/64', 'dsb/207', 'dv/184',  
--  4) add a rank column to the spreadsheet (from 1 to 274)
'el/40', 'en/1', 'en-ca/80', 'en-gb/71', 'en-us/208', 'eo/35', 'es/6', 'et/44', 'eu/49',  
--  5) create "lang/rank" string, using "=CONCAT("'",A2,"/",E2,"', ")"
'ext/185', 'fa/29', 'fi/19', 'fo/209', 'fr/3', 'frr/168', 'fy/83', 'ga/75', 'gd/151', 'gl/30',  
--    or something similar
'grc/210', 'gsw/103', 'gu/74', 'ha/131', 'haw/169', 'he/38', 'hi/41', 'hr/36', 'hsb/118',  
--  6) sort the rows by the language code, per
'ht/170', 'hu/14', 'hy/52', 'ia/143', 'id/31', 'ie/211', 'ig/145', 'io/88', 'is/86', 'it/12',  
--    https://en.wikipedia.org/wiki/Wikipedia:Language_order_poll
'ja/9', 'jbo/152', 'jv/124', 'ka/55', 'kaa/132', 'kcg/146', 'khw/212', 'kjp/213', 'kk/78',  
--  7) copy the results below
'kk-cyrl/147', 'km/97', 'kn/85', 'ko/27', 'ko-kp/111', 'ksh/156', 'ku/90', 'ku-arab/214',  
return {'abs/273', 'ace/256', 'af/71', 'als/79', 'am/139', 'an/108', 'ang/188',  
'ku-latn/215', 'ky/98', 'la/112', 'lb/57', 'lmo/157', 'lo/158', 'lt/54', 'lv/62', 'lzh/153',  
'anp/250', 'ar/9', 'arq/106', 'ary/184', 'arz/109', 'as/105', 'ast/81', 'av/204',  
'mai/216', 'mg/92', 'mi/171', 'min/154', 'mk/2', 'ml/22', 'mn/148', 'mnw/186', 'mr/65', 'ms/48',  
'az/57', 'azb/217', 'ba/162', 'ban/148', 'bar/46', 'bcl/115', 'be/66',  
'ms-arab/217', 'mt/82', 'mwl/139', 'my/67', 'myv/187', 'mzn/122', 'nah/159', 'nan/188', 'nap/125',  
'be-tarask/33', 'be-x-old/173', 'bg/42', 'bgn/143', 'bh/203', 'bho/144', 'bi/237',  
'nb/45', 'nds/46', 'nds-nl/218', 'ne/76', 'new/219', 'nl/7', 'nl-informal/189', 'nn/56', 'no/51',  
'bjn/200', 'blk/145', 'bn/21', 'bo/232', 'br/74', 'bs/85', 'bug/254', 'ca/27',  
'nso/190', 'ny/140', 'oc/77', 'or/128', 'os/160', 'pa/126', 'pam/191', 'pap/220', 'pcd/172',  
'cdo/274', 'ce/111', 'ceb/140', 'ch/186', 'ckb/119', 'co/193', 'cs/17', 'csb/265',  
'pih/221', 'pl/13', 'pms/222', 'ps/93', 'pt/8', 'pt-br/23', 'qu/161', 'rm/141', 'ro/39', 'ru/5',  
'cu/179', 'cv/235', 'cy/70', 'da/34', 'dag/116', 'de/3', 'de-at/104', 'de-ch/102',  
'rw/173', 'sah/192', 'sc/134', 'scn/24', 'sco/115', 'sd/119', 'se/102', 'sh/129', 'si/96',  
'de-formal/61', 'dga/228', 'diq/65', 'dsb/222', 'dtp/231', 'dv/199', 'el/41',  
'simple/116', 'sk/50', 'sl/18', 'sm/193', 'smn/223', 'sn/162', 'so/123', 'sq/63', 'sr/43',  
'en/1', 'en-ca/82', 'en-gb/73', 'eo/35', 'es/6', 'et/44', 'eu/49', 'ext/172',  
'sr-ec/224', 'sr-el/225', 'st/194', 'stq/226', 'su/127', 'sv/16', 'sw/120', 'syl/174', 'szl/135',  
'fa/29', 'fi/19', 'fiu-vro/263', 'fj/246', 'fo/205', 'fr/4', 'frc/243', 'frr/169',  
'ta/68', 'tcy/130', 'te/109', 'tg/104', 'tg-cyrl/195', 'th/37', 'tk/196', 'tl/70', 'tn/227',  
'fy/84', 'ga/75', 'gag/253', 'gd/157', 'gl/31', 'gn/257', 'gor/258', 'gpe/240',  
'to/228', 'tok/197', 'tpi/175', 'tr/28', 'tt/99', 'tt-cyrl/229', 'ug/198', 'uk/11', 'ur/61',  
'grc/190', 'gsw/103', 'gu/69', 'ha/132', 'haw/171', 'he/38', 'hi/37', 'hr/36',  
'uz/84', 'vec/95', 'vi/32', 'vo/176', 'wa/230', 'war/155', 'wuu/177', 'xh/199', 'yi/133',  
'hrx/247', 'hsb/117', 'ht/175', 'hu/14', 'hy/51', 'ia/135', 'id/30', 'ie/224',  
'yo/91', 'yue/94', 'zgh/231', 'zh/15', 'zh-classical/178', 'zh-cn/60', 'zh-hans/20', 'zh-hant/25',  
'ig/149', 'ilo/233', 'inh/236', 'io/89', 'is/86', 'it/12', 'ja/10', 'jbo/152',  
'zh-hk/89', 'zh-mo/149', 'zh-my/136', 'zh-sg/113', 'zh-tw/53', 'zh-yue/200', 'zu/179'}
'jv/126', 'ka/56', 'kaa/129', 'kcg/146', 'khw/206', 'kjp/227', 'kk/80',  
'kk-cyrl/150', 'km/101', 'kn/87', 'ko/24', 'ko-kp/113', 'krc/259', 'kri/268',  
'ks-arab/239', 'ksh/166', 'ku/92', 'ku-arab/230', 'ku-latn/226', 'ky/94', 'la/110',  
'lb/58', 'li/251', 'lmo/165', 'ln/255', 'lo/163', 'lt/54', 'ltg/262', 'lua/270',  
'lv/63', 'lzh/147', 'mai/195', 'mdf/269', 'mg/91', 'mi/181', 'min/156', 'mk/2',  
'ml/22', 'mn/155', 'mni/267', 'mnw/168', 'mo/244', 'mr/67', 'ms/48', 'ms-arab/219',  
'mt/83', 'mwl/136', 'my/68', 'myv/208', 'mzn/124', 'nah/160', 'nan/178', 'nap/122',  
'nb/45', 'nds/47', 'nds-nl/207', 'ne/76', 'new/229', 'nl/7', 'nl-informal/192',  
'nn/55', 'no/52', 'nqo/260', 'nso/202', 'ny/141', 'nyo/266', 'oc/78', 'or/131',  
'os/158', 'pa/125', 'pam/174', 'pap/213', 'pcd/167', 'pdc/261', 'pfl/242',  
'pih/223', 'pl/13', 'pms/225', 'pnb/214', 'prg/189', 'ps/93', 'pt/8', 'pt-br/23',  
'qu/159', 'rm/142', 'ro/40', 'ru/5', 'rw/183', 'sa/245', 'sah/196', 'sat/248',  
'sc/137', 'scn/25', 'sco/112', 'sd/121', 'se/100', 'sh/130', 'shn/264', 'si/97',
'simple/118', 'sk/50', 'sl/18', 'sm/210', 'sma/238', 'smn/212', 'sn/161', 'so/123',
'sq/64', 'sr/43', 'sr-ec/215', 'sr-el/220', 'st/194', 'stq/209', 'su/127', 'sv/16',
'sw/120', 'syl/185', 'szl/134', 'ta/59', 'tcy/128', 'te/107', 'tg/98', 'tg-cyrl/151',
'th/39', 'tk/197', 'tl/72', 'tn/216', 'to/221', 'tok/170', 'tpi/180', 'tr/28',
'tt/99', 'tt-cyrl/211', 'ttj/272', 'tw/271', 'tyv/234', 'udm/252', 'ug/187', 'uk/11',
'ur/60', 'uz/77', 'vec/96', 'vi/32', 'vo/164', 'wa/218', 'war/153', 'wuu/182',
'xh/198', 'xmf/249', 'yi/133', 'yo/90', 'yue/95', 'za/241', 'zgh/201', 'zh/15',
'zh-classical/177', 'zh-cn/62', 'zh-hans/20', 'zh-hant/26', 'zh-hk/88', 'zh-mo/154',  
'zh-my/138', 'zh-sg/114', 'zh-tw/53', 'zh-yue/191', 'zu/176'}
end
end


Line 83: Line 104:


function p.lang_links_external(frame)
function p.lang_links_external(frame)
local args = require('Module:Arguments').getArgs(frame)
local title, subpage, doc
local title, subpage, doc
local output = {}
local output = {}
     local page    = frame.args[1]
     local page    = args[1]
     local max_num = tonumber(frame.args[2] or '500')
     local max_num = tonumber(args[2] or '500')
if (page) then
if (page) then
title = mw.title.new(page)
title = mw.title.new(page)

Latest revision as of 23:01, 1 December 2024

Module documentation[ create · purge ]
This documentation is transcluded from Module:Lang links/doc.
 --  __  __           _       _        _                        _ _       _        
 -- |  \/  | ___   __| |_   _| | ___ _| |    __ _ _ __   __ _  | (_)_ __ | | _____ 
 -- | |\/| |/ _ \ / _` | | | | |/ _ (_) |   / _` | '_ \ / _` | | | | '_ \| |/ / __|
 -- | |  | | (_) | (_| | |_| | |  __/_| |__| (_| | | | | (_| | | | | | | |   <\__ \
 -- |_|  |_|\___/ \__,_|\__,_|_|\___(_)_____\__,_|_| |_|\__, | |_|_|_| |_|_|\_\___/
                                                     -- |___/                      
require('strict') -- used for debugging purposes as it detects cases of unintended global variables

local p = {}

local function lang_list()
	-- This list was generated using the following manual process:
	--  1) run query https://quarry.wmcloud.org/query/83535 which collected all 
	--     the sub-templates on commons and save results into a spreadsheet
	--  2) download list of language codes supported by MediaWiki from
	--     https://gerrit.wikimedia.org/g/mediawiki/core/%2B/HEAD/includes/languages/data/Names.php
	--     In 2024-12 there were 556 supported languages
	--  3) remove sub-templates which are not names of supported languages. 
	--     Use case sensative vlookup ("VLOOKUP(TRUE, CHOOSE({1,2}, EXACT(
	--     lookup_value, lookup_array), return_array), 2, 0)". 
	--     In 2024-12 there were 274 supported languages used as subtemplates
	--  4) add a rank column to the spreadsheet (from 1 to 274)
	--  5) create "lang/rank" string, using "=CONCAT("'",A2,"/",E2,"', ")"
	--     or something similar
	--  6) sort the rows by the language code, per 
	--     https://en.wikipedia.org/wiki/Wikipedia:Language_order_poll
	--  7) copy the results below
	return {'abs/273', 'ace/256', 'af/71', 'als/79', 'am/139', 'an/108', 'ang/188', 
		'anp/250', 'ar/9', 'arq/106', 'ary/184', 'arz/109', 'as/105', 'ast/81', 'av/204', 
		'az/57', 'azb/217', 'ba/162', 'ban/148', 'bar/46', 'bcl/115', 'be/66', 
		'be-tarask/33', 'be-x-old/173', 'bg/42', 'bgn/143', 'bh/203', 'bho/144', 'bi/237', 
		'bjn/200', 'blk/145', 'bn/21', 'bo/232', 'br/74', 'bs/85', 'bug/254', 'ca/27', 
		'cdo/274', 'ce/111', 'ceb/140', 'ch/186', 'ckb/119', 'co/193', 'cs/17', 'csb/265', 
		'cu/179', 'cv/235', 'cy/70', 'da/34', 'dag/116', 'de/3', 'de-at/104', 'de-ch/102', 
		'de-formal/61', 'dga/228', 'diq/65', 'dsb/222', 'dtp/231', 'dv/199', 'el/41', 
		'en/1', 'en-ca/82', 'en-gb/73', 'eo/35', 'es/6', 'et/44', 'eu/49', 'ext/172', 
		'fa/29', 'fi/19', 'fiu-vro/263', 'fj/246', 'fo/205', 'fr/4', 'frc/243', 'frr/169', 
		'fy/84', 'ga/75', 'gag/253', 'gd/157', 'gl/31', 'gn/257', 'gor/258', 'gpe/240', 
		'grc/190', 'gsw/103', 'gu/69', 'ha/132', 'haw/171', 'he/38', 'hi/37', 'hr/36', 
		'hrx/247', 'hsb/117', 'ht/175', 'hu/14', 'hy/51', 'ia/135', 'id/30', 'ie/224', 
		'ig/149', 'ilo/233', 'inh/236', 'io/89', 'is/86', 'it/12', 'ja/10', 'jbo/152', 
		'jv/126', 'ka/56', 'kaa/129', 'kcg/146', 'khw/206', 'kjp/227', 'kk/80', 
		'kk-cyrl/150', 'km/101', 'kn/87', 'ko/24', 'ko-kp/113', 'krc/259', 'kri/268', 
		'ks-arab/239', 'ksh/166', 'ku/92', 'ku-arab/230', 'ku-latn/226', 'ky/94', 'la/110', 
		'lb/58', 'li/251', 'lmo/165', 'ln/255', 'lo/163', 'lt/54', 'ltg/262', 'lua/270', 
		'lv/63', 'lzh/147', 'mai/195', 'mdf/269', 'mg/91', 'mi/181', 'min/156', 'mk/2', 
		'ml/22', 'mn/155', 'mni/267', 'mnw/168', 'mo/244', 'mr/67', 'ms/48', 'ms-arab/219', 
		'mt/83', 'mwl/136', 'my/68', 'myv/208', 'mzn/124', 'nah/160', 'nan/178', 'nap/122', 
		'nb/45', 'nds/47', 'nds-nl/207', 'ne/76', 'new/229', 'nl/7', 'nl-informal/192', 
		'nn/55', 'no/52', 'nqo/260', 'nso/202', 'ny/141', 'nyo/266', 'oc/78', 'or/131', 
		'os/158', 'pa/125', 'pam/174', 'pap/213', 'pcd/167', 'pdc/261', 'pfl/242', 
		'pih/223', 'pl/13', 'pms/225', 'pnb/214', 'prg/189', 'ps/93', 'pt/8', 'pt-br/23', 
		'qu/159', 'rm/142', 'ro/40', 'ru/5', 'rw/183', 'sa/245', 'sah/196', 'sat/248', 
		'sc/137', 'scn/25', 'sco/112', 'sd/121', 'se/100', 'sh/130', 'shn/264', 'si/97', 
		'simple/118', 'sk/50', 'sl/18', 'sm/210', 'sma/238', 'smn/212', 'sn/161', 'so/123', 
		'sq/64', 'sr/43', 'sr-ec/215', 'sr-el/220', 'st/194', 'stq/209', 'su/127', 'sv/16', 
		'sw/120', 'syl/185', 'szl/134', 'ta/59', 'tcy/128', 'te/107', 'tg/98', 'tg-cyrl/151', 
		'th/39', 'tk/197', 'tl/72', 'tn/216', 'to/221', 'tok/170', 'tpi/180', 'tr/28', 
		'tt/99', 'tt-cyrl/211', 'ttj/272', 'tw/271', 'tyv/234', 'udm/252', 'ug/187', 'uk/11', 
		'ur/60', 'uz/77', 'vec/96', 'vi/32', 'vo/164', 'wa/218', 'war/153', 'wuu/182', 
		'xh/198', 'xmf/249', 'yi/133', 'yo/90', 'yue/95', 'za/241', 'zgh/201', 'zh/15', 
		'zh-classical/177', 'zh-cn/62', 'zh-hans/20', 'zh-hant/26', 'zh-hk/88', 'zh-mo/154', 
		'zh-my/138', 'zh-sg/114', 'zh-tw/53', 'zh-yue/191', 'zu/176'}
end

function p.lang_links(frame)
	local title, subpage
	local output = {}
    local page    = frame.args[1]
    local max_num = tonumber(frame.args[2] or '70')
	if (page) then
		title = mw.title.new(page)
	else
		title = mw.title.getCurrentTitle()
		page  = tostring( title.basePageTitle )
	end
	
	-- if /lang subpage found transclude it and we are done
	subpage = page .. '/lang'
	if mw.title.new(subpage).exists then
		return frame:expandTemplate{ title = subpage }
	end

	local list = lang_list()
	local output = {}
	for _, key in pairs( list ) do
		local v = mw.text.split( key, '/' )
		local lang = v[1]
		local rank = tonumber(v[2])
		if rank<=max_num then
			subpage = page .. '/' .. lang
			if mw.title.new(subpage).exists then
				local lname = mw.language.fetchLanguageName( lang, lang )
				table.insert(output, '[[' .. subpage .. '|<bdi lang="'..lang..'">'.. lname..'</bdi>]]')
			elseif lang=='en' then -- some pages have English version in the main template. Assume that is the case if /en subpage is missing.
				table.insert(output, '[[' .. page .. '|<bdi lang="en">English</bdi>]]')
			end
		end
	end 
	
	list = table.concat(output, '&nbsp;<b>∙</b>&#32;')
	return '<span class="plainlinks" style="font-size:small;line-height:1.4">'.. list.. '</span>'
end

function p.lang_links_external(frame)
	local args = require('Module:Arguments').getArgs(frame)
	local title, subpage, doc
	local output = {}
    local page    = args[1]
    local max_num = tonumber(args[2] or '500')
	if (page) then
		title = mw.title.new(page)
	else
		title = mw.title.getCurrentTitle()
		page  = tostring( title.basePageTitle )
	end
	doc = '<noinclude>\n\n[[Category:Language link templates|' .. tostring( title.baseText ) .. ']]\n</noinclude>'

	local list = lang_list()
	local output = {}
	for _, key in pairs( list ) do
		local v = mw.text.split( key, '/' )
		local lang = v[1]
		local rank = tonumber(v[2])
		if rank<=max_num then
			subpage = page .. '/' .. lang
			title = mw.title.new(subpage)
			if title.exists then
				local lname = mw.language.fetchLanguageName( lang, lang )
				table.insert(output, '[' .. title:fullUrl() .. ' <bdi class="language lang-'..lang..'" lang="'..lang..'">'.. lname..'</bdi>]')
			end
		end
	end 
	title = mw.title.new(page .. '/lang')
	table.insert(output, '{{edit|' .. title.prefixedText .. '}}')
	list = table.concat(output, '&nbsp;<b>∙</b>&#32;<!--\n-->')
	return '<span style="font-size:small;line-height:1.4" class="plainlinks noprint"><!--\n-->'.. list.. '<!--\n--></span>' .. doc
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.