ElEditors, Interface administrators, Administrators
85,550
edits
(Add lang support for multi-lang title dealing) |
m (Add i18n support) |
||
Line 1: | Line 1: | ||
-- pystart | -- pystart | ||
require('Module:CommonFunctions') | require('Module:CommonFunctions') | ||
local i18n = require('Module:I18n') | |||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
local inspect = require('Module:Inspect').inspect | local inspect = require('Module:Inspect').inspect | ||
local getTranslations = i18n.getTranslations | |||
local p = {} | local p = {} | ||
Line 8: | Line 10: | ||
function p.main(frame) | function p.main(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local tr = getTranslations(frame, 'Template:Damage', args.lang, true) | |||
local out | local out | ||
function translate(key) | |||
return i18n.translate(tr, key) | |||
end | |||
function inArgs(key) | function inArgs(key) | ||
Line 649: | Line 656: | ||
{ | { | ||
type = 'extra', | type = 'extra', | ||
text = { 'Average' }, | text = { translate('Average') }, | ||
is_visible = OPTIONS.no_max, | is_visible = OPTIONS.no_max, | ||
no_damage = true | no_damage = true | ||
Line 656: | Line 663: | ||
type = 'passives', | type = 'passives', | ||
text = checkPassives({ | text = checkPassives({ | ||
output = { 'Base' }, | output = { translate('Base') }, | ||
action = function(passive, output) | action = function(passive, output) | ||
if passive.is_combined then | if passive.is_combined then | ||
Line 688: | Line 695: | ||
type = 'passive_appended', | type = 'passive_appended', | ||
text = { | text = { | ||
'Normal', | translate('Normal'), | ||
OPTIONS.is_append and | OPTIONS.is_append and | ||
link(PASSIVES[OPTIONS.append_index].name, | link(PASSIVES[OPTIONS.append_index].name, | ||
Line 702: | Line 709: | ||
{ | { | ||
type = 'awakening', | type = 'awakening', | ||
text = { 'Regular', (function() | text = { translate('Regular'), (function() | ||
if OPTIONS.dmp then | if OPTIONS.dmp then | ||
return link('Dynamo Point System', 'Dynamo Configuration', args.awk_prefix, | return link('Dynamo Point System', 'Dynamo Configuration', args.awk_prefix, | ||
Line 719: | Line 726: | ||
type = 'traits', | type = 'traits', | ||
text = checkTraits({ | text = checkTraits({ | ||
output = { 'Normal' }, | output = { translate('Normal') }, | ||
action = function(trait, output) | action = function(trait, output) | ||
table.insert(output, trait.name) | table.insert(output, trait.name) | ||
Line 734: | Line 741: | ||
type = 'cancel', | type = 'cancel', | ||
text = { | text = { | ||
'Cancel', 'Full' | translate('Cancel'), | ||
translate('Full'), | |||
}, | }, | ||
keywords = { 'cancel' }, | keywords = { 'cancel' }, | ||
Line 744: | Line 752: | ||
text = { | text = { | ||
(inArgs('count') and not OPTIONS.use_avg) and | (inArgs('count') and not OPTIONS.use_avg) and | ||
(table.concat({ 'Per', args.count_name or 'Group' }, ' ')) or 'Average', | (table.concat({ 'Per', args.count_name or 'Group' }, ' ')) or | ||
'Max' | translate('Average'), | ||
translate('Max') | |||
}, | }, | ||
keywords = (function() | keywords = (function() | ||
Line 827: | Line 836: | ||
function doInitialCell(new_row) | function doInitialCell(new_row) | ||
return new_row:tag('th'):wikitext('Mode') | return new_row:tag('th'):wikitext(translate('Mode')) | ||
end | end | ||