Module talk:Flags

Code change
Hello I saw your module on it.wiki, and I would like to make some changes to the code: is simpler and quicker try to assign and check for 3. Why check for  ? AFAIK a paremeter call will be resolved before call the module and substituded by its value.
 * 1) declare local all variables, they are more efficient and quick to access and you dont pollute global namespace
 * 2) Why do you use a for loop to check if a key is in the table like:

I will upload my changes to the sandbox for test.--Moroboshi (talk) 11:14, 22 July 2013 (UTC)
 * Thank you for the interest and the good advice! This is not only my first attempt with Lua programming, it is also my most serious attempt to program anything out of HTML/CSS. For instance, I wasn't aware that by not declaring variables explicitly local the module would pullute the global namespace (something that sounds obvious now that you say it).
 * Your approach in 2) is definitely smarter and I'm happy to take it after testing that there are no side effects (I don't see why there should be any).
 * 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.
 * Now I comprend you check for a parameter not definited. I think its cleaner to set the parameter to  in the template and check for null string   in the module.--Moroboshi (talk) 18:01, 22 July 2013 (UTC)
 * The same for  or , set them to   or   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)
 * I had a first look at you version in the sandbox. Looks good, and you are saving almost 20 LOC! But I want to be cautious taking the changes since the template is already transcluded in 600 articles at ca.wiki. Where is git when you need it? ;) I'm starting my holidays tomorrow, flying and then having less time in front of the laptop. Still, I should be able to connect in the evenings. Feel free to "merge" your changes, just trying to do it edit by edit with comments for posterity. Welcome to the team!  :)
 * Just curious: why are you changing the sequence of the script? It makes comparing code a bit more difficult. I had the idea of going for 1 Name; 2 Variant; 3 Size; 4 Link; 5 Label - but if there are good reasons to change it I'm all ears.
 * I had trouble with other approaches for  or  . 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  and access the parameters used in the template call directly in the lua module using   ? Is sufficient to add this code to the start of the function: And then you can check the parameter in the standard way,  por positional parameter 1 and   or   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)
 * Changes tested and taken. Thank you very much!--QuimGil (talk) 03:56, 22 August 2013 (UTC)

Problem with File:Flag of the Soviet Union 1955.svg
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. -   t  u coxn \talk 01:11, 13 February 2014 (UTC)
 * Please spell it out with an example for dummies unfamiliar with the topic. I would like a link to an article and a brief description of how I can see there is something wrong (I don't mean the category, I mean where is the error in the article). Johnuniq (talk) 07:07, 13 February 2014 (UTC)
 * I'd better add User:Tucoxn for a ping. Johnuniq (talk) 07:09, 13 February 2014 (UTC)
 * Johnuniq: Thanks for your response but it looks like this got fixed. It looks like this was an issue with some changes on Commons due to a rename request. Here are some Commons file histories that might explain what the problem was: history for "File:Flag of the Soviet Union (1938-1980).svg", history for "File:Flag of the Soviet Union 1955.svg", and history for "File:Flag of the Soviet Union (1955-1980).svg" (a new file). Again, this seems fixed for now. Thanks! -   t  u coxn \talk 09:43, 13 February 2014 (UTC)

Performance
Is this module faster or slower than the old flag templates based on Country data system? Petr Matas 01:15, 22 June 2014 (UTC)
 * I have done some measurements myself. Analysis of a page with 50 Flagicons takes 429±65 ms, analysis of a page with 50 Flags takes 472±66 ms of CPU time. The performance difference is lower than the measurement error. Petr Matas 10:47, 23 June 2014 (UTC)


 * Perhaps it would help performance to convert Module:Flags/MasterData to a JSON page and load its contents using . – Minh Nguyễn  &#x1f4ac; 05:33, 13 June 2019 (UTC)

Chuuk creates a link to a dab page
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)