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
No edit summary
No edit summary
Line 10: Line 10:


function p.lang_links(frame)
function p.lang_links(frame)
     local title = frame.args[1]
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  = title.basePageTitle
end
subpage = page .. '/lang'
if mw.title.new(subpage).exists then
--return frame:expandTemplate{ title = subpage }
end


-- This list was generated by collecting all the templates from  
-- This list was generated by collecting all the templates from  
-- [[Category:Translated marker templates]] and [[Category:Translated license tags]]
-- [[Category:Translated marker templates]] and [[Category:Translated license tags]]
-- and counting how many subtemplates from each language we have. This is top 70 list.
-- subpages of 2400 templates and counting how many subtemplates from each language we have.  
local list = {'af', 'als', 'ar', 'az', 'be', 'be-tarask', 'bg', 'bn', 'br', 'ca', 'cs',  
-- Than we assigned rank based on how many pages in a given language we had
'cy', 'da', 'de', 'diq', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fa', 'fi', 'fr', 'ga',  
local list = {'af/65', 'als/66', 'an/89', 'ar/15', 'arq/81', 'ast/84', 'az/54', 'bar/74',
'gl', 'he', 'hi', 'hr', 'hu', 'hy', 'id', 'it', 'ja', 'ka', 'ko', 'lb', 'lt', 'lv',  
'bcl/85', 'be/67', 'be-tarask/35', 'bg/41', 'bn/21', 'br/52', 'bs/79', 'ca/22', 'ce/103',  
'mk', 'ml', 'mr', 'ms', 'mt', 'nb', 'nds', 'ne', 'nl', 'nn', 'pl', 'pt', 'pt-br',  
'cs/12', 'cy/56', 'da/37', 'dag/92', 'de/4', 'de-at/112', 'de-ch/113', 'de-formal/73',  
'ro', 'ru', 'scn', 'sk', 'sk', 'sl', 'sq', 'sr', 'sv', 'ta', 'th', 'tl', 'tr', 'uk',  
'diq/64', 'el/43', 'en/1', 'en-ca/114', 'en-gb/88', 'eo/34', 'es/6', 'et/32', 'eu/48',  
'ur', 'vi', 'zh', 'zh-hans', 'zh-hant'}
'fa/29', 'fi/23', 'fr/3', 'fy/72', 'ga/62', 'gl/30', 'gu/90', 'ha/107', 'he/40', 'hi/44',  
'hr/39', 'hu/16', 'hy/45', 'id/28', 'io/71', 'is/97', 'it/10', 'ja/9', 'jv/98', 'ka/51',
'kk/77', 'km/94', 'kn/95', 'ko/26', 'ko-kp/99', 'ku/80', 'ky/82', 'lb/57', 'lt/55',  
'lv/61', 'mg/75', 'min/116', 'mk/2', 'ml/18', 'mr/68', 'ms/46', 'mt/69', 'my/83', 'nb/47',  
'nds/49', 'ne/59', 'nl/7', 'nn/60', 'ny/108', 'oc/93', 'or/100', 'pa/101', 'pl/13',
'ps/109', 'pt/8', 'pt-br/25', 'rm/104', 'ro/36', 'ru/5', 'scn/14', 'sd/110', 'se/86',
'sh/105', 'sk/50', 'sl/19', 'sq/58', 'sr/33', 'su/102', 'sv/24', 'sw/117', 'ta/70',
'te/118', 'test/115', 'th/38', 'tl/53', 'tr/27', 'tt/91', 'uk/11', 'ur/63', 'uz/111',  
'vec/87', 'vi/42', 'yo/76', 'yue/106', 'zh/31', 'zh-cn/96', 'zh-hans/17', 'zh-hant/20', 'zh-tw/78'}
local output = {}
local output = {}
for _, lang in pairs( list ) do
for _, key in pairs( list ) do
local subpage = title .. '/' .. lang
local v = mw.text.split( key, '/' )
if mw.title.new(subpage).exists then
local lang = v[1]
local lname = mw.language.fetchLanguageName( lang, lang )
local rank = tonumber(v[2])
table.insert(output, '[[' .. subpage .. '|<bdi lang="'..lang..'">'.. lname..'</bdi>]]')
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>]]')
end
end
end
end  
end  
local subpage = title .. '/lang'
if mw.title.new(subpage).exists then
table.insert(output, '[[' .. subpage .. '|+/−]]')
end
list = table.concat(output, '&nbsp;<b>∙</b>&#32;')
list = table.concat(output, '&nbsp;<b>∙</b>&#32;')
return '<span class="plainlinks" style="font-size:small;line-height:1.4">'.. list.. '</span>'
return '<span class="plainlinks" style="font-size:small;line-height:1.4">'.. list.. '</span>'

Revision as of 04:51, 25 January 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 = {}

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  = title.basePageTitle
	end
	
	subpage = page .. '/lang'
	if mw.title.new(subpage).exists then
		--return frame:expandTemplate{ title = subpage }
	end

	-- This list was generated by collecting all the templates from 
	-- [[Category:Translated marker templates]] and [[Category:Translated license tags]]
	-- subpages of 2400 templates and counting how many subtemplates from each language we have. 
	-- Than we assigned rank based on how many pages in a given language we had
	local list = {'af/65', 'als/66', 'an/89', 'ar/15', 'arq/81', 'ast/84', 'az/54', 'bar/74', 
		'bcl/85', 'be/67', 'be-tarask/35', 'bg/41', 'bn/21', 'br/52', 'bs/79', 'ca/22', 'ce/103', 
		'cs/12', 'cy/56', 'da/37', 'dag/92', 'de/4', 'de-at/112', 'de-ch/113', 'de-formal/73', 
		'diq/64', 'el/43', 'en/1', 'en-ca/114', 'en-gb/88', 'eo/34', 'es/6', 'et/32', 'eu/48', 
		'fa/29', 'fi/23', 'fr/3', 'fy/72', 'ga/62', 'gl/30', 'gu/90', 'ha/107', 'he/40', 'hi/44', 
		'hr/39', 'hu/16', 'hy/45', 'id/28', 'io/71', 'is/97', 'it/10', 'ja/9', 'jv/98', 'ka/51', 
		'kk/77', 'km/94', 'kn/95', 'ko/26', 'ko-kp/99', 'ku/80', 'ky/82', 'lb/57', 'lt/55', 
		'lv/61', 'mg/75', 'min/116', 'mk/2', 'ml/18', 'mr/68', 'ms/46', 'mt/69', 'my/83', 'nb/47', 
		'nds/49', 'ne/59', 'nl/7', 'nn/60', 'ny/108', 'oc/93', 'or/100', 'pa/101', 'pl/13', 
		'ps/109', 'pt/8', 'pt-br/25', 'rm/104', 'ro/36', 'ru/5', 'scn/14', 'sd/110', 'se/86', 
		'sh/105', 'sk/50', 'sl/19', 'sq/58', 'sr/33', 'su/102', 'sv/24', 'sw/117', 'ta/70', 
		'te/118', 'test/115', 'th/38', 'tl/53', 'tr/27', 'tt/91', 'uk/11', 'ur/63', 'uz/111', 
		'vec/87', 'vi/42', 'yo/76', 'yue/106', 'zh/31', 'zh-cn/96', 'zh-hans/17', 'zh-hant/20', 'zh-tw/78'}
	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>]]')
			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

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