Module:Flags: Difference between revisions

Content deleted Content added
m QuimGil moved page Module:Sandbox/QuimGil/Flagicon to Module:Sandbox/QuimGil/Flags without leaving a redirect: Final name
Supporting localization. Now English/default strings are stored in FlagMaster, while all localization is done in FlagTranslations
Line 1:
local p = {}
 
-- Converts "Flag of" in a variable in order to accept images that don't follow this name schema
flagOf = "Flag_of_"
 
-- Loading the flag translations module --
local translations = mw.loadData("Module:Sandbox/QuimGil/FlagTranslations")
local master = mw.loadData("Module:Sandbox/QuimGil/FlagMaster")
-- Converts "Flag of" in a variable in order to accept images that don't follow this name schema
flagOf = "Flag_of_"
-- Assigning the parameter to a flag and a link
function p.flag(territory)
-- Searching in the translationmaster table only.
-- 2 letter code search
if #territory.args[1] == 2 then
for english,locale in pairs(translationsmaster.twoLetter) do
if territory.args[1] == locale then
commonsName = english
Line 23 ⟶ 24:
-- 3 letter code search
if #territory.args[1] == 3 then
for english,locale in pairs(translationsmaster.threeLetter) do
if territory.args[1] == locale then
commonsName = english
Line 31 ⟶ 32:
end
-- Searching in both tables
-- Full name search
forflagTables english,locale= in{ pairs(translationsmaster.fullName), dotranslations.fullName, }
for k,v in ipairs(flagTables) do
if territory.args[1] == locale or territory.args[1] == english then
for english,locale in pairs(v) commonsName = englishdo
linkif territory.args[1] == locale or territory.args[1] == english then
commonsName = english
link = locale
end
end
end
 
-- In the absence of translation for an existing entry, links to the english/original name --
if commonsName ~= nil and link == '' then