Template:Languages
--[=[ Not globally exposed. Internal function only.
language_subpages( frame, transform, options ) Parameters
frame: The frame that was passed to the method invoked. The first argument or the page argument will be respected. transform: A transform function. Example: function( basepagename, subpagename, code, langname ) end options: An object with options. Example: { abort= { on=function() end, time=0.8 } } Following options are available: abort: Aborts iterating over the subpages if one of the conditions is met. If the process is aborted, nil is returned! on: Function to be called if an abort-condition was met. cycles: The maximum number of subpages to run over. time: Maximum time to spend running over the subpages.
]=] function language_subpages( frame, transform, options )
local args, pargs, options = frame.args, ( frame:getParent() or {} ).args or {}, options or {}; local title = args.page or args[1] or pargs.page or pargs[1] or ""; local abort = options.abort or {}; local at, clock = type( abort.on ), os.clock(); local ac = function() if at == 'function' or ( at == 'table' and getmetatable(abort.on).__call ) then abort.on(); end end local tt = type( transform ); local page = require( 'Module:Page' ); title = page.clean(title); if tt == 'function' or ( tt == 'table' and getmetatable(transform).__call ) then local fetch, pages, langcode, langname = mw.language.fetchLanguageName, {}; for pg in page.subpages( title, { ignoreNS=true } ) do if abort.cycles then abort.cycles = abort.cycles - 1 if 0 == abort.cycles then return ac() end end if abort.time then if (os.clock() - clock) > abort.time then return ac() end end if mw.ustring.len( pg ) <= 12 then langcode = string.lower( pg ); langname = fetch( langcode ); if langname ~= then table.insert( pages, transform( title, pg, langcode, langname ) ); end end end return pages; end return {};
end
local p = {};
--[=[ Usage: Script error: No such module "languages". ]=] function p.internal(frame)
pages = language_subpages( frame, function( title, page, code, name )
return mw.ustring.format( '%s',
code, code, code, title, page, name
);
end);
return table.concat( pages, ' · ' );
end
--[=[ Usage: Script error: No such module "languages". ]=] function p.external(frame)
pages = language_subpages( frame, function( title, page, code, name )
return mw.ustring.format( '[%s/%s %s]',
code, code, code, tostring( mw.uri.fullUrl( title ) ), page:gsub( ' ', '_' ), name
);
end);
return table.concat( pages, ' | ' );
end
--[=[ forEachLanguage
This function iterates over all language codes known to MediaWiki based on a maintained list replacing patterns in a pattern-string for each language
Usage: Script error: No such module "Languages".
Parameters
pattern: A pattern string which is processed for each language and which is concatenated at the end and returned as one string before: A string that is inserted before the concatenated result after: A string that is inserted after the concatenated result sep: A string that is inserted between each line created from the pattern while iterating (like ProcessedPattern_sep_ProcessedPattern_sep_ProcessedPattern) inLang: Langcode to use for $lnTrP and $lnTrUC1
Patterns:
$lc - language code such as en or de $lnP - language name in own language $lnUC1 - language name in own language, first letter upper case $lnTrP - language name translated to the language requested by language code passed to inLang $lnTrUC1 - language name translated to the language requested by language code passed to inLang, first letter upper case
Example
Script error: No such module "Languages".
]=]
-- =p.forEachLanguage({ args= { pattern = "$lc - $lnTrP\n", inLang = "en" } }) function p.forEachLanguage(frame)
local l = require( "Module:Languages/List" ) local ret = {} local lang = mw.language local contentLangInstance = mw.language.getContentLanguage() local langInstance = contentLangInstance --Quota hit here otherwise local fetch = lang.fetchLanguageName local line local pattern = frame.args.pattern or frame.args[1] or "" local before = frame.args.before or frame.args[2] or "" local after = frame.args.after or frame.args[3] or "" local sep = frame.args.separator or frame.args[4] or "" local inLang = frame.args.inLang or frame.args[5] or nil local langName local langNameUCFirst local langNameTranslated local langNameTranslatedUCFirst local langNameUCFirstReq = not not pattern:find( "$lnUC1", 1, true ) local langNameReq = not not pattern:find( "$lnP", 1, true ) or langNameUCFirstReq local langNameTranslatedUCFirstReq = not not pattern:find( "$lnTrUC1", 1, true ) local langNameTranslatedReq = not not pattern:find( "$lnTrP", 1, true ) or langNameTranslatedUCFirstReq for k, v in pairs( l.list ) do line = pattern:gsub( "$lc", v ) if langNameReq then langName = fetch( v ) line = line:gsub( "$lnP", langName ) end if langNameUCFirstReq then --langInstance = mw.getLanguage( v ) --Quota hit here langNameUCFirst = langInstance:ucfirst( langName ) line = line:gsub( "$lnUC1", langNameUCFirst ) end if langNameTranslatedReq and inLang then langNameTranslated = fetch( v, inLang ) line = line:gsub( "$lnTrP", langNameTranslated ) end if langNameTranslatedUCFirstReq and inLang then --if not langInstance then langInstance = mw.getLanguage( v ) end --Quota hit here langNameTranslatedUCFirst = langInstance:ucfirst( langNameTranslated ) line = line:gsub( "$lnTrUC1", langNameTranslatedUCFirst ) --langInstance = nil end -- Don't know why ret:insert( line ) throws >>attempt to call method 'insert' (a nil value)<< table.insert(ret, line) end return before .. table.concat( ret, sep ) .. after
end
--[=[
Provide logic for Template:Lle (Language Links external, to be substituted)
]=] function p.lle(frame)
local ret local pattern = "{{subst:#ifexist:Template:Languages/doc/$lc|$lnUC1 {{subst:!}} }}" ret = p.forEachLanguage({ args= { pattern = pattern } }) ret = frame:preprocess(ret) return ret
end
--[=[
Provide logic for Template:Ll (Language Links, to be substituted)
]=] function p.ll(frame)
local ret local pattern = "{{subst:#ifexist:Template:Languages/doc/$lc|[[Template:Languages/doc/$lc{{subst:!}}$lnUC1]] {{subst:!}} }}" ret = p.forEachLanguage({ args= { pattern = pattern } }) ret = frame:preprocess(ret) return ret
end
--- Different approaches for Template:Lang links ---
--[=[
Provide logic for Template:Lang links Using a cute Hybrid-Method: First check the subpages which is quite fast; if there are too many fall back to checking for each language page individually
]=]
-- =p.langLinksNonExpensive({ args= { page='Commons:Picture of the Year/2010' }, getParent=function() end }) -- =p.langLinksNonExpensive({ args= { page='Main Page' }, getParent=function() end }) -- =p.langLinksNonExpensive({ args= { page='Template:No_source_since' }, getParent=function() end }) -- =p.langLinksNonExpensive({ args= { page='MediaWiki:Gadget-HotCat' }, getParent=function() end }) function p.langLinksNonExpensive(frame)
local contentLangInstance = mw.language.getContentLanguage();
local pages2
local options = { abort= { time=1, on=function()
pages2 = p.langLinksUsingLinks( frame )
end } }
local pages = language_subpages( frame, function( basepagename, subpagename, code, langname )
return mw.ustring.format( '%s | ',
code, code, code, basepagename, subpagename, contentLangInstance:ucfirst( langname ) )
end, options );
return table.concat( pages2 or pages, );
end
--[=[
Provide logic for Template:Lang links (Language Links, creating wikilinks and parsing them to find out whether pages exist for Expensive-Parser-Function-Quota reasons {{#ifexists:}} is not used and LUA page objects are not created)
]=] -- =p.langLinksUsingLinks({ args= { page='Template:No_source_since' }, getParent=function() end }) function p.langLinksUsingLinks(frame)
local contentLangInstance = mw.language.getContentLanguage() -- Get the current page or the supplied one local args, pargs = frame.args, ( frame:getParent() or {} ).args or {} local title = args.page or args[1] or pargs.page or pargs[1] or "" -- Load required modules local M_page = require( 'Module:Page' ); local M_link = require( 'Module:Link' ); title = M_page.clean(title); if not title then return "<LUA: Module:Languages: langLinksUsingLinks: NO TITLE SUPPLIED>" end -- Generate the Wikitext we will parse as links (to bypass the expensive parser function limit) local pattern = '$lc' local wikitext = p.forEachLanguage( { args= { pattern = pattern } } ) local fetch = mw.language.fetchLanguageName -- Iterate over all links we created and return the concatenated result local ret = M_link.forEachLink( wikitext, function(linkInfo) if linkInfo.red then return end return mw.ustring.format( '%s | ', linkInfo.text, linkInfo.text, linkInfo.text, title, linkInfo.text, contentLangInstance:ucfirst( fetch( linkInfo.text ) )) end ); return ret
end
Template:Autolang -----------------
--[[
Works like Template:Languages/en just allowing an unlimited number of arguments, even named arguments. It's doing Magic! No arguments should be passed to Script error: You must specify a function to call.
]]
function p.autolang(frame)
local args, pargs = frame.args, ( frame:getParent() or {} ).args or {} if nil == args.useargs then if not args.base then args = pargs end elseif 'both' == args.useargs then for k,v in pairs(args) do pargs[k] = v end args = pargs elseif 'parent' == args.useargs then args = pargs if pargs.base and not args.base then args.base = pargs.base end end local base = args.base local userlang = mw.message.newRawMessage( 'en' ):parse() local tl, tlns = 'Template:', 10 local tlb, fallback1, currenttemplate local fallback, contentlang = mw.text.split( userlang, '-', true )[1], mw.language.getContentLanguage():getCode() local createReturn = function(title) local ret local tlargs = {} -- When LUA is invoked, templates are already expanded. This must be respected. return frame:expandTemplate{ title = title, args = args } end if not base then return ("'autolang' in Module:Languages was called but the 'base' parameter could not be found." .. "The base parameter specifies the template that's subpages will be sought for a suitable translation.") end tlb = tl .. base .. '/' currenttemplate = tlb .. userlang if mw.title.new( currenttemplate, tlns ).exists then return createReturn(currenttemplate) end fallback1 = frame:preprocess( 'en' ) if fallback1 ~= contentlang then return createReturn(tlb .. fallback1) end currenttemplate = tlb .. fallback if mw.title.new( currenttemplate, tlns ).exists then return createReturn(currenttemplate) end currenttemplate = tlb .. contentlang if mw.title.new( currenttemplate, tlns ).exists then return createReturn(currenttemplate) end return createReturn(tl .. base)
end
function p.file_languages(frame)
local M_link = require( 'Module:Link' ) local contentLangInstance = mw.language.getContentLanguage() local pattern = frame.args.pattern or '%s (%s)' local original = frame.args.original or mw.title.getCurrentTitle().text local ext_start, _ = string.find( original, '\.%w+$' ) local file_ext = string.sub( original, ext_start ) original = string.sub( original, 0, ext_start-1 )return frame:preprocess('
-
%s', filename, contentLangInstance:ucfirst( mw.language.fetchLanguageName( linkInfo.text ) ) )
end
return p;
This template is mostly obsolete and should be replaced with <languages/> when possible (i.e. for translatable pages). |
Syntax
{{Languages|PageName}}
- PageName (optional) – the name of the page to display language links for. If omitted then the English version of the current page is used. This parameter can normally be omitted, as it is only required if you want to link to a page other than the one you place the template on, which is very uncommon. If this parameter is used on a sub-page make sure you supply the root name, not the full page name (e.g. on MediaWiki/fr you would need to use
{{Languages|MediaWiki}}
and not{{Languages|MediaWiki/fr}}
).
Usage
The template should only be placed on pages that exist in more than one language, and it should be placed in the same location on each translation of the page.
The English version of a page is always the main version, with all other languages as sub-pages, named using the appropriate language code (see below).
For example, on the Main Page you would include the text {{Languages}}
, both on Main Page itself, and on each of its language sub-pages. The template automatically creates links to any language sub-pages that exist, e.g. Main Page/ja
, Main Page/fr
, and ignores non-existant languages.
See Meta:Translate extension for further details about translating pages.
Supported languages
Special:SiteMatrix shows you the code and name of each supported language. Other languages may be added easily to the template as necessary.
If no Wikimedia project in your language exists, do not add pages in that language to Meta-Wiki!
Example
See Wikimedia maintenance notice.
Known issues
- The template uses
#ifexist
parser function to check whether each translation page exists. Unfortunately,#ifexist
unexpectedly populates WhatLinksHere: so all missing translation pages are wrongly listed at Special:WhatLinksHere. #ifexist
is also an expensive parser function; so using this template increases the chance the page exceeds the limit.
--[=[
Not globally exposed. Internal function only.
language_subpages( frame, transform, options )
Parameters
frame: The frame that was passed to the method invoked. The first argument or the page argument will be respected.
transform: A transform function. Example: function( basepagename, subpagename, code, langname ) end
options: An object with options. Example: { abort= { on=function() end, time=0.8 } }
Following options are available:
abort: Aborts iterating over the subpages if one of the conditions is met. If the process is aborted, nil is returned!
on: Function to be called if an abort-condition was met.
cycles: The maximum number of subpages to run over.
time: Maximum time to spend running over the subpages.
]=]
function language_subpages( frame, transform, options )
local args, pargs, options = frame.args, ( frame:getParent() or {} ).args or {}, options or {};
local title = args.page or args[1] or pargs.page or pargs[1] or "";
local abort = options.abort or {};
local at, clock = type( abort.on ), os.clock();
local ac = function()
if at == 'function' or ( at == 'table' and getmetatable(abort.on).__call ) then
abort.on();
end
end
local tt = type( transform );
local page = require( 'Module:Page' );
title = page.clean(title);
if tt == 'function' or ( tt == 'table' and getmetatable(transform).__call ) then
local fetch, pages, langcode, langname = mw.language.fetchLanguageName, {};
for pg in page.subpages( title, { ignoreNS=true } ) do
if abort.cycles then
abort.cycles = abort.cycles - 1
if 0 == abort.cycles then return ac() end
end
if abort.time then
if (os.clock() - clock) > abort.time then return ac() end
end
if mw.ustring.len( pg ) <= 12 then
langcode = string.lower( pg );
langname = fetch( langcode );
if langname ~= '' then
table.insert( pages, transform( title, pg, langcode, langname ) );
end
end
end
return pages;
end
return {};
end
local p = {};
--[=[
Usage:
{{#invoke:languages|internal|Template:Adjective}}
]=]
function p.internal(frame)
pages = language_subpages( frame, function( title, page, code, name )
return mw.ustring.format( '<span lang="%s" xml:lang="%s" class="language lang-%s">[[%s/%s|%s]]</span>',
code, code, code, title, page, name
);
end);
return table.concat( pages, ' · ' );
end
--[=[
Usage:
{{#invoke:languages|external|Template:Adjective}}
]=]
function p.external(frame)
pages = language_subpages( frame, function( title, page, code, name )
return mw.ustring.format( '<span lang="%s" xml:lang="%s" class="language lang-%s">[%s/%s %s]</span>',
code, code, code, tostring( mw.uri.fullUrl( title ) ), page:gsub( ' ', '_' ), name
);
end);
return table.concat( pages, ' | ' );
end
--[=[
forEachLanguage
This function iterates over all language codes known to MediaWiki based on a maintained list
replacing patterns in a pattern-string for each language
Usage:
{{#invoke:Languages|forEachLanguage
|pattern=patternstring
|before=string to insert before iteration
|after=string added after iteration
|sep=separator string between iterations
|inLang=langcode used for $lnTrP and $lnTrUC1
}}
Parameters
pattern: A pattern string which is processed for each language and which is concatenated at the end and returned as one string
before: A string that is inserted before the concatenated result
after: A string that is inserted after the concatenated result
sep: A string that is inserted between each line created from the pattern while iterating (like ProcessedPattern_sep_ProcessedPattern_sep_ProcessedPattern)
inLang: Langcode to use for $lnTrP and $lnTrUC1
Patterns:
$lc - language code such as en or de
$lnP - language name in own language
$lnUC1 - language name in own language, first letter upper case
$lnTrP - language name translated to the language requested by language code passed to inLang
$lnTrUC1 - language name translated to the language requested by language code passed to inLang, first letter upper case
Example
{{#invoke:Languages|forEachLanguage|pattern=<span lang="$lc" xml:lang="$lc" class="language lang-$lc">[[Page/$lc|$lnP]]</span>}}
]=]
-- =p.forEachLanguage({ args= { pattern = "$lc - $lnTrP\n", inLang = "en" } })
function p.forEachLanguage(frame)
local l = require( "Module:Languages/List" )
local ret = {}
local lang = mw.language
local contentLangInstance = mw.language.getContentLanguage()
local langInstance = contentLangInstance --Quota hit here otherwise
local fetch = lang.fetchLanguageName
local line
local pattern = frame.args.pattern or frame.args[1] or ""
local before = frame.args.before or frame.args[2] or ""
local after = frame.args.after or frame.args[3] or ""
local sep = frame.args.separator or frame.args[4] or ""
local inLang = frame.args.inLang or frame.args[5] or nil
local langName
local langNameUCFirst
local langNameTranslated
local langNameTranslatedUCFirst
local langNameUCFirstReq = not not pattern:find( "$lnUC1", 1, true )
local langNameReq = not not pattern:find( "$lnP", 1, true ) or langNameUCFirstReq
local langNameTranslatedUCFirstReq = not not pattern:find( "$lnTrUC1", 1, true )
local langNameTranslatedReq = not not pattern:find( "$lnTrP", 1, true ) or langNameTranslatedUCFirstReq
for k, v in pairs( l.list ) do
line = pattern:gsub( "$lc", v )
if langNameReq then
langName = fetch( v )
line = line:gsub( "$lnP", langName )
end
if langNameUCFirstReq then
--langInstance = mw.getLanguage( v ) --Quota hit here
langNameUCFirst = langInstance:ucfirst( langName )
line = line:gsub( "$lnUC1", langNameUCFirst )
end
if langNameTranslatedReq and inLang then
langNameTranslated = fetch( v, inLang )
line = line:gsub( "$lnTrP", langNameTranslated )
end
if langNameTranslatedUCFirstReq and inLang then
--if not langInstance then langInstance = mw.getLanguage( v ) end --Quota hit here
langNameTranslatedUCFirst = langInstance:ucfirst( langNameTranslated )
line = line:gsub( "$lnTrUC1", langNameTranslatedUCFirst )
--langInstance = nil
end
-- Don't know why ret:insert( line ) throws >>attempt to call method 'insert' (a nil value)<<
table.insert(ret, line)
end
return before .. table.concat( ret, sep ) .. after
end
--[=[
Provide logic for [[Template:Lle]] (Language Links external, to be substituted)
]=]
function p.lle(frame)
local ret
local pattern = "{{<includeonly/>subst:#ifexist:{{{1}}}/$lc|[{{fullurl:{{{1}}}/$lc}} $lnUC1] {{<includeonly/>subst:!}} <!--\n-->}}"
ret = p.forEachLanguage({ args= { pattern = pattern } })
ret = frame:preprocess(ret)
return ret
end
--[=[
Provide logic for [[Template:Ll]] (Language Links, to be substituted)
]=]
function p.ll(frame)
local ret
local pattern = "{{<includeonly/>subst:#ifexist:{{{1}}}/$lc|[[{{{1}}}/$lc{{<includeonly/>subst:!}}$lnUC1]] {{<includeonly/>subst:!}} <!--\n-->}}"
ret = p.forEachLanguage({ args= { pattern = pattern } })
ret = frame:preprocess(ret)
return ret
end
--------------------------------------------------------
--- Different approaches for [[Template:Lang links]] ---
--------------------------------------------------------
--[=[
Provide logic for [[Template:Lang links]]
Using a cute Hybrid-Method:
First check the subpages which is quite fast; if there are too many fall back to checking for each language page individually
]=]
-- =p.langLinksNonExpensive({ args= { page='Commons:Picture of the Year/2010' }, getParent=function() end })
-- =p.langLinksNonExpensive({ args= { page='Main Page' }, getParent=function() end })
-- =p.langLinksNonExpensive({ args= { page='Template:No_source_since' }, getParent=function() end })
-- =p.langLinksNonExpensive({ args= { page='MediaWiki:Gadget-HotCat' }, getParent=function() end })
function p.langLinksNonExpensive(frame)
local contentLangInstance = mw.language.getContentLanguage();
local pages2
local options = { abort= { time=1, on=function()
pages2 = p.langLinksUsingLinks( frame )
end } }
local pages = language_subpages( frame, function( basepagename, subpagename, code, langname )
return mw.ustring.format( '<span lang="%s" xml:lang="%s" class="language lang-%s" style="white-space:nowrap">[[%s/%s|%s]]</span> | ',
code, code, code, basepagename, subpagename, contentLangInstance:ucfirst( langname ) )
end, options );
return table.concat( pages2 or pages, '' );
end
--[=[
Provide logic for [[Template:Lang links]] (Language Links,
creating wikilinks and parsing them to find out whether pages exist for Expensive-Parser-Function-Quota reasons
{{#ifexists:}} is not used and LUA page objects are not created)
]=]
-- =p.langLinksUsingLinks({ args= { page='Template:No_source_since' }, getParent=function() end })
function p.langLinksUsingLinks(frame)
local contentLangInstance = mw.language.getContentLanguage()
-- Get the current page or the supplied one
local args, pargs = frame.args, ( frame:getParent() or {} ).args or {}
local title = args.page or args[1] or pargs.page or pargs[1] or ""
-- Load required modules
local M_page = require( 'Module:Page' );
local M_link = require( 'Module:Link' );
title = M_page.clean(title);
if not title then return "<LUA: [[Module:Languages]]: langLinksUsingLinks: NO TITLE SUPPLIED>" end
-- Generate the Wikitext we will parse as links (to bypass the expensive parser function limit)
local pattern = '[[' .. title .. '/$lc|$lc]]'
local wikitext = p.forEachLanguage( { args= { pattern = pattern } } )
local fetch = mw.language.fetchLanguageName
-- Iterate over all links we created and return the concatenated result
local ret = M_link.forEachLink( wikitext,
function(linkInfo)
if linkInfo.red then return '' end
return mw.ustring.format( '<span lang="%s" xml:lang="%s" class="language lang-%s" style="white-space:nowrap">[[%s/%s|%s]]</span> | ',
linkInfo.text, linkInfo.text, linkInfo.text, title, linkInfo.text, contentLangInstance:ucfirst( fetch( linkInfo.text ) ))
end
);
return ret
end
---------------------------------------------------------
----------------- [[Template:Autolang]] -----------------
---------------------------------------------------------
--[[
Works like {{autotranslate}} just allowing an unlimited number of arguments, even named arguments.
It's doing Magic! No arguments should be passed to {{#invoke:}}
]]
function p.autolang(frame)
local args, pargs = frame.args, ( frame:getParent() or {} ).args or {}
if nil == args.useargs then
if not args.base then args = pargs end
elseif 'both' == args.useargs then
for k,v in pairs(args) do pargs[k] = v end
args = pargs
elseif 'parent' == args.useargs then
args = pargs
if pargs.base and not args.base then
args.base = pargs.base
end
end
local base = args.base
local userlang = mw.message.newRawMessage( '{{int:lang}}' ):parse()
local tl, tlns = 'Template:', 10
local tlb, fallback1, currenttemplate
local fallback, contentlang = mw.text.split( userlang, '-', true )[1], mw.language.getContentLanguage():getCode()
local createReturn = function(title)
local ret
local tlargs = {}
-- When LUA is invoked, templates are already expanded. This must be respected.
return frame:expandTemplate{ title = title, args = args }
end
if not base then
return ("'autolang' in [[Module:Languages]] was called but the 'base' parameter could not be found." ..
"The base parameter specifies the template that's subpages will be sought for a suitable translation.")
end
tlb = tl .. base .. '/'
currenttemplate = tlb .. userlang
if mw.title.new( currenttemplate, tlns ).exists then
return createReturn(currenttemplate)
end
fallback1 = frame:preprocess( '{{Fallback|1=' .. base .. '|2=' .. userlang .. '}}' )
if fallback1 ~= contentlang then
return createReturn(tlb .. fallback1)
end
currenttemplate = tlb .. fallback
if mw.title.new( currenttemplate, tlns ).exists then
return createReturn(currenttemplate)
end
currenttemplate = tlb .. contentlang
if mw.title.new( currenttemplate, tlns ).exists then
return createReturn(currenttemplate)
end
return createReturn(tl .. base)
end
function p.file_languages(frame)
local M_link = require( 'Module:Link' )
local contentLangInstance = mw.language.getContentLanguage()
local pattern = frame.args.pattern or '%s (%s)'
local original = frame.args.original or mw.title.getCurrentTitle().text
local ext_start, _ = string.find( original, '\.%w+$' )
local file_ext = string.sub( original, ext_start )
original = string.sub( original, 0, ext_start-1 )
return frame:preprocess('<gallery>\n'..(table.concat(M_link.forEachLink( p.forEachLanguage( { args= { pattern = '[[$lc]]' } } ),
function(linkInfo)
local filename = mw.ustring.format( pattern, original, linkInfo.text ) .. file_ext
if mw.title.new( filename, 6 ).exists then
return mw.ustring.format( '%s|%s', filename, contentLangInstance:ucfirst( mw.language.fetchLanguageName( linkInfo.text ) ) )
else
return nil
end
end
), '\n'))..'\n</gallery>')
end
return p;