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



Revision as of 22:20, 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 232 supported languages used as subtemplates
	--  4) add a rank column to the spreadsheet (from 1 to 235)
	--  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 {'af/71', 'als/79', 'am/135', 'an/108', 'ang/186', 'ar/9', 'arq/106', 
		'ary/168', 'arz/109', 'as/105', 'ast/81', 'av/187', 'az/57', 'azb/211', 
		'ba/161', 'ban/146', 'bar/46', 'bcl/114', 'be/66', 'be-tarask/33', 
		'be-x-old/169', 'bg/42', 'bgn/140', 'bh/188', 'bho/144', 'bjn/189', 
		'blk/145', 'bn/21', 'bo/212', 'br/74', 'bs/85', 'ca/27', 'ce/110', 
		'ceb/141', 'ch/190', 'ckb/118', 'co/191', 'cs/17', 'cu/170', 'cy/70', 
		'da/34', 'dag/116', 'de/3', 'de-at/103', 'de-ch/102', 'de-formal/61', 
		'dga/213', 'diq/65', 'dsb/214', 'dtp/215', 'dv/192', 'el/41', 'en/1', 
		'en-ca/82', 'en-gb/73', 'eo/35', 'es/6', 'et/44', 'eu/49', 'ext/171', 
		'fa/29', 'fi/19', 'fo/193', 'fr/4', 'frr/172', 'fy/84', 'ga/75', 
		'gd/156', 'gl/31', 'grc/194', 'gsw/104', 'gu/69', 'ha/132', 'haw/173', 
		'he/38', 'hi/37', 'hr/36', 'hsb/117', 'ht/174', 'hu/14', 'hy/51', 
		'ia/136', 'id/30', 'ie/216', 'ig/147', 'io/88', 'is/86', 'it/12', 
		'ja/10', 'jbo/148', 'jv/122', 'ka/56', 'kaa/129', 'kcg/149', 'khw/195', 
		'kjp/217', 'kk/80', 'kk-cyrl/150', 'km/100', 'kn/87', 'ko/24', 'ko-kp/112', 
		'ksh/162', 'ku/92', 'ku-arab/218', 'ku-latn/219', 'ky/94', 'la/111', 
		'lb/58', 'lmo/163', 'lo/164', 'lt/54', 'lv/63', 'lzh/151', 'mai/196', 
		'mg/91', 'mi/175', 'min/157', 'mk/2', 'ml/22', 'mn/152', 'mnw/176', 
		'mr/67', 'ms/48', 'ms-arab/220', 'mt/83', 'mwl/137', 'my/68', 'myv/197', 
		'mzn/123', 'nah/158', 'nan/177', 'nap/124', 'nb/45', 'nds/47', 'nds-nl/198', 
		'ne/76', 'new/221', 'nl/7', 'nl-informal/199', 'nn/55', 'no/52', 'nso/200', 
		'ny/142', 'oc/78', 'or/130', 'os/159', 'pa/125', 'pam/178', 'pap/222', 
		'pcd/165', 'pih/223', 'pl/13', 'pms/224', 'pnb/225', 'prg/201', 'ps/93', 
		'pt/8', 'pt-br/23', 'qu/160', 'rm/143', 'ro/40', 'ru/5', 'rw/179', 'sah/202', 
		'sc/138', 'scn/25', 'sco/113', 'sd/119', 'se/101', 'sh/131', 'si/97', 
		'simple/120', 'sk/50', 'sl/18', 'sm/203', 'smn/226', 'sn/166', 'so/126', 
		'sq/64', 'sr/43', 'sr-ec/227', 'sr-el/228', 'st/204', 'stq/205', 'su/127', 
		'sv/16', 'sw/121', 'syl/180', 'szl/133', 'ta/59', 'tcy/128', 'te/107', 
		'tg/98', 'tg-cyrl/153', 'th/39', 'tk/206', 'tl/72', 'tn/229', 'to/230', 
		'tok/181', 'tpi/182', 'tr/28', 'tt/99', 'tt-cyrl/231', 'ug/207', 'uk/11', 
		'ur/60', 'uz/77', 'vec/96', 'vi/32', 'vo/167', 'wa/232', 'war/154', 'wuu/183', 
		'xh/208', 'yi/134', 'yo/90', 'yue/95', 'zgh/209', 'zh/15', 'zh-classical/184', 
		'zh-cn/62', 'zh-hans/20', 'zh-hant/26', 'zh-hk/89', 'zh-mo/155', 'zh-my/139', 
		'zh-sg/115', 'zh-tw/53', 'zh-yue/210', 'zu/185', 'zh-tw/53', 'zh-yue/210', 
		'zu/178'}
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.