12,601
edits
Blinkingline (talk | contribs) (Just trying to remove the translation.) Tag: Reverted |
Blinkingline (talk | contribs) No edit summary Tag: Reverted |
||
Line 44: | Line 44: | ||
local templates = require('Module:LuacardTemplates') | local templates = require('Module:LuacardTemplates') | ||
local cardstyle = require('Module:LuacardStyle') | local cardstyle = require('Module:LuacardStyle') | ||
local translations = require("Module:LocaleTable") -- double quotes to not stage | |||
local luastache = require("Module:luastache") -- double quotes to not stage | local luastache = require("Module:luastache") -- double quotes to not stage | ||
local translate_table = {} | |||
local translate = function(word) | |||
if(translate_table[word]~=nil) then | |||
return translate_table[word] | |||
else | |||
return word | |||
end | |||
end | |||
function insert_translated(tab) | |||
local trans_tab = {} | |||
for k,v in pairs(tab) do | |||
trans_tab[k..'_t'] = translate(v) | |||
end | |||
combine(tab, trans_tab) | |||
end | |||
function stachify(table) | function stachify(table) | ||
Line 96: | Line 96: | ||
function stache(s, tab) | function stache(s, tab) | ||
stachify(tab) | stachify(tab) | ||
insert_translated(tab) | |||
s = '{{=${ }=}}'..s | s = '{{=${ }=}}'..s | ||
return luastache:render(s, tab) | return luastache:render(s, tab) | ||
Line 116: | Line 116: | ||
end | end | ||
local translate_trait = function(frame, type, word) | |||
if(frame.args.locale) then | |||
if(not translations[type][frame.args.locale]) then | |||
return word | |||
end | |||
if(not translations[type][frame.args.locale][mw.ustring.lower(word)]) then | |||
return word | |||
end | |||
return mw.ustring.upper(translations[type][frame.args.locale][mw.ustring.lower(word)]) | |||
else | |||
return word | |||
end | |||
end | |||
local load_translation_table = function(locale) | |||
local translate_table_results = cargo_results( | |||
'TranslationTable', | |||
'EnglishText,Type,TranslatedText', | |||
{ | |||
where='Locale="'..locale..'"' | |||
}) | |||
for r=1, #translate_table_results do | |||
local result = translate_table_results[r] | |||
translate_table[result.EnglishText] = result.TranslatedText | |||
end | |||
end | |||
local apply_altart = function(frame, vars) | local apply_altart = function(frame, vars) |