Hello I saw your module on it.wiki, and I would like to make some changes to the code:
for flagParameter,commonsFile in pairs(master.twoLetter) do
if flagParameter == territory.args[1] then
commonsName = commonsFile
tempLink = commonsFile
end
end
is simpler and quicker try to assign and check for nil
commonsFile = master.twoLetter[territory.args[1]]
if commonsFile then --check for nil
commonsName = commonsFile
tempLink = commonsFile
end
3. Why check for if territory.args[2] ~= "{{{2}}}" then
? AFAIK a paremeter call will be resolved before call the module and substituded by its value.
I will upload my changes to the sandbox for test.--Moroboshi (talk) 11:14, 22 July 2013 (UTC)
if territory.args[2] ~= "{{{2}}}" then
is the way I found to check whether a parameter for variants i.e. "1945" has been defined, after asking at mediawiki.org. Improvements welcome.
{{{2|}}}
in the template and check for null string ""
in the module.--Moroboshi (talk) 18:01, 22 July 2013 (UTC)
{{{link}}}
or {{{text}}}
, set them to {{{link|}}}
or {{{text|}}}
and check for null string in the module. I uploaded the modified flags to Module:Flags/Sandbox with some comments about my changes. Apparently it works with the example test in the doc.--Moroboshi (talk) 18:49, 22 July 2013 (UTC)
{{{link}}}
or {{{text}}}
. Null string is actually different from no parameter defined. Users can set link= or text= to give specific instructions to the template (no link and same label as name of flag).I think the only thing I moved out of order was the function default_size (and obviously check_translation that is new), i assigned the name flag_code to territory.args[1] because is used in different points of the script (but maybe the name could be more specific).
Regarding the use of parameters do you known that you can simplify the template call removing all parameters like {{Invoke|Flags|flag}}
and access the parameters used in the template call directly in the lua module using territory:parent().args()
? Is sufficient to add this code to the start of the function:
function p.flag(territory)
-- get the frame of the calling calling template
local pframe = territory:getParent()
-- get all parameter and store them in a table (pframe return a table with limited function, see scribunto documentation)
local args = {}
for k, v in pairs( pframe.args ) do
args[k] = v
end
And then you can check the parameter in the standard way, args[1]
por positional parameter 1 and args['text']
or args.text
for named parameter "text". If text is not definet it will be nil, if its defined but empty text= then it will be equal to the null string ""
:
Good holiday, I will fly next week. --Moroboshi (talk) 22:25, 23 July 2013 (UTC)
There seems to be a problem with the flag for the Soviet Union. This is affecting at least 49 pages (the Winter Olympics articles at Category:Articles with missing files). One file being called is File:Flag of the Soviet Union 1955.svg, which seems to be a redirect to File:Flag of the Soviet Union (1938-1980).svg. Other Soviet Union flags redirecting to that one also seem to be missing, causing the bigger problem. - tucoxn\talk 01:11, 13 February 2014 (UTC)
Is this module faster or slower than the old flag templates based on Country data system? Petr Matas 01:15, 22 June 2014 (UTC)
mw.text.jsonDecode()
. – Minh Nguyễn 💬 05:33, 13 June 2019 (UTC){{flags|Chuuk}}
creates a link to a dab page Chuuk. It should like to the article Chuuk State instead. Here's an illustration: . Can someone fix that? Coastside (talk) 05:16, 20 January 2020 (UTC)