Module:Différences de traduction
Aller à la navigation
Aller à la recherche
Ce module permet de récupérer les données de Module:Différences de traduction/traductions pour les modèles {{Traduction}}
et {{TableauTraduction}}
.
Voir les modèles respectifs pour plus d'information sur l'utilisation.
[lire] [modifier] [historique] [purger]La documentation ci-dessus est tirée de Module:Différences de traduction/doc.
local p = {}
local translations = require('Module:Différences de traduction/traductions')
function p.generateDiffTable(frame)
local tableMarkup = '{| class="wikitable mw-collapsible sortable mw-collapsed"\n|-\n'
tableMarkup = tableMarkup .. '! style="width: 200px;" | Java 🇫🇷\n'
.. '! style="width: 200px;" | Bedrock 🇫🇷\n'
.. '! style="width: 200px;" | Java 🇨🇦\n'
.. '! style="width: 200px;" | Bedrock 🇨🇦\n'
.. '|-\n'
local keys = {}
for key in pairs(translations) do
table.insert(keys, key)
end
table.sort(keys)
for _, java_fr in ipairs(keys) do
local t = translations[java_fr]
local opened_brackets = (frame.args[4] == "" or (frame.args[1] == "instrument" or frame.args[1] == "banner")) and "" or "[["
local closed_brackets = (frame.args[4] == "" or (frame.args[1] == "instrument" or frame.args[1] == "banner")) and "" or "]]"
if frame.args[4] ~= "" or t.bedrock_fr or t.java_ca or t.bedrock_ca then
if t.type == frame.args[1] or t.type == frame.args[2] or t.type == frame.args[3] then
local fr_match = not t.bedrock_fr and 'tc-yes' or 'tc-no'
local ca_match = t.java_ca == t.bedrock_ca and 'tc-yes' or 'tc-no'
tableMarkup = tableMarkup .. '| class="' .. fr_match .. '"|' .. opened_brackets .. (java_fr) .. closed_brackets .. '\n'
.. '| class="' .. fr_match .. '"|' .. opened_brackets .. (t.exclusive ~= "java" and (t.bedrock_fr or java_fr) or "-") .. closed_brackets .. '\n'
.. '| class="' .. ca_match .. '"|' .. opened_brackets .. (t.java_ca or java_fr) .. closed_brackets .. '\n'
.. '| class="' .. ca_match .. '"|' .. opened_brackets .. (t.exclusive ~= "java" and (t.bedrock_ca or java_fr) or "-") .. closed_brackets .. '\n'
.. '|-\n'
end
end
end
tableMarkup = tableMarkup .. '|}'
return tableMarkup
end
function p.getTranslation(frame)
local java_fr, translation = frame.args[1], frame.args[2]
return translations[java_fr] and translations[java_fr][translation] or java_fr
end
function p.getTranslations(java_fr)
local key = java_fr.args[1]
local data = translations[key] or {}
local result = {}
for _, lang in ipairs({ "java_ca", "bedrock_fr", "bedrock_ca" }) do
table.insert(result, data[lang] ~= key and data[lang] or "")
end
return table.concat(result, "§")
end
return p