Module:Backpack item/format
Documentation for this module may be created at Module:Backpack item/format/doc
--[[ These are the order of parameters in different languages. When the template is evaluated, the english text here will be replaced with language-appropriate strings. Please note the missing spaces are intentional, as some languages concatenate words together. The raw strings for these words live in Template:Dictionary/common_strings#Module:Backpack_item Note that extra spaces, empty parenthesis, and extra dashes will be cleaned up automatically. --]] -- Missing translations: ar, cs item_name_format = { ['da'] = 'quality filter festivized killstreak item_name', ['de'] = 'item_name - quality filter killstreak - festivized', ['en'] = 'quality filter festivized killstreak item_name', ['es'] = 'item_name quality filter festivized killstreak', ['fi'] = 'qualityfilter killstreak festivizeditem_name', ['fr'] = 'item_name festivized (quality filter killstreak)', ['hu'] = 'qualityfilter festivizedkillstreak item_name', ['it'] = 'item_name (festivized) (quality filter killstreak)', ['ja'] = 'quality filter killstreak festivized item_name', ['ko'] = 'quality filter festivized killstreak item_name', ['nl'] = 'qualityfilter festivizedkillstreakitem_name', ['no'] = 'quality filter festivized killstreak item_name', ['pl'] = 'item_name (quality filter festivized killstreak)', ['pt'] = 'item_name filter (festivized) (quality killstreak)', ['pt-br'] = 'item_name filter (festivized) (quality killstreak)', ['ro'] = 'qualityfilter festivizedkillstreakitem_name', ['ru'] = 'item_name killstreak festivized quality filter', ['sv'] = 'quality filter festivized killstreakitem_name', ['tr'] = 'qualityfitler festivizedkillstreak item_name', ['zh-hans'] = 'quality filter festivizedkillstreak item_name', ['zh-hant'] = 'qualityfilter festivizedkillstreakitem_name', } -- TFUI_InvTooltip_Rarity -- Missing translations: ar, ja -- Self translated: none item_desc_format_grade = { ['cs'] = 'item_kind grade (wear)', ['da'] = 'grade item_kind (wear)', ['de'] = 'item_kind, grade (wear)', ['en'] = 'grade item_kind (wear)', ['es'] = 'item_kind grade (wear)', ['fi'] = 'grade item_kind (wear)', ['fr'] = 'grade - item_kind (wear)', ['hu'] = 'grade item_kind (wear)', ['it'] = 'item_kind - grade (wear)', ['ko'] = 'grade item_kind (wear)', ['nl'] = 'item_kind (grade, wear)', ['no'] = 'item_kind grade (wear)', ['pl'] = 'item_kind grade (wear)', ['pt'] = 'item_kind grade (wear)', ['pt-br'] = 'item_kind grade (wear)', ['ro'] = 'item_kind grade (wear)', ['ru'] = 'item_kind grade (wear)', ['sv'] = 'grade item_kind (wear)', ['tr'] = 'grade item_kind (wear)', ['zh-hans'] = 'gradeitem_kind(wear)', ['zh-hant'] = 'grade item_kind(wear)', } -- ItemTypeDescKillEater -- Missing translations: ar, fr (limited is missing) -- Self translated: none item_desc_format_strange = { ['cs'] = 'limited strange_rank_name item_kind - rankson', ['da'] = 'limited item_kind (strange_rank_name) - rankson', ['de'] = 'limited item_kind (strange_rank_name) - rankson', ['en'] = 'limited strange_rank_name item_kind - rankson', ['es'] = 'item_kind strange_rank_name limited - rankson', ['fi'] = 'limited strange_rank_name item_kind - rankson', ['fr'] = 'item_kind strange_rank_name - rankson', ['hu'] = 'limitedstrange_rank_name item_kind - rankson', ['it'] = 'item_kind - limited (strange_rank_name) - rankson', ['ja'] = 'limited strange_rank_name item_kind - rankson', ['ko'] = 'limited strange_rank_name item_kind - rankson', ['nl'] = 'limitedstrange_rank_name item_kind - rankson', ['no'] = 'limiteditem_kind strange_rank_name - rankson', ['pl'] = 'item_kind limited (strange_rank_name) - rankson', ['pt'] = 'item_kind (strange_rank_name) limited - rankson', ['pt-br'] = 'item_kind (strange_rank_name) limited - rankson', ['ro'] = 'limitedstrange_rank_name item_kind - rankson', ['ru'] = 'item_kind strange_rank_name limited - rankson', ['sv'] = 'limitedstrange_rank_name item_kind - rankson', ['tr'] = 'limitedstrange_rank_name item_kind - rankson', ['zh-hans'] = 'limitedstrange_rank_name item_kind - rankson', ['zh-hant'] = 'limitedstrange_rank_name item_kind - rankson', } -- ItemTypeDescLimited -- Missing translations: ar, no -- Self translated: none item_desc_format_default = { ['cs'] = 'item_kind (limited - item_level)', ['da'] = 'limited item_level item_kind', ['de'] = 'limiteditem_kind item_level', ['en'] = 'limited item_level item_kind', ['es'] = 'item_kind item_level limited', ['fi'] = 'limited item_level item_kind', ['fr'] = 'item_kind limited item_level', ['hu'] = 'item_level limiteditem_kind', ['it'] = 'item_kind - item_level (limited)', ['ja'] = 'limited item_level item_kind', ['ko'] = 'limited item_level item_kind', ['nl'] = 'limiteditem_level item_kind', ['pl'] = 'item_kind (limited) item_level', ['pt'] = 'item_kind limited - item_level', ['pt-br'] = 'item_kind limited item_level', ['ro'] = 'limiteditem_level item_kind', ['ru'] = 'item_kind limited item_level', ['sv'] = 'limiteditem_level item_kind', ['tr'] = 'limiteditem_level item_kind', ['zh-hans'] = 'item_level limiteditem_kind', ['zh-hant'] = 'limiteditem_level item_kind', } -- A list of strings which mean "don't show" rather than "use me" local negatives = { ['none'] = true, ['no'] = true, ['0'] = true, ['false'] = true, ['hide'] = true, ['negative'] = true, [''] = true, } function format_string(frame, format_dict, args) local order = frame:expandTemplate{title='Lang', args=format_dict} local output_string local idx = string.find(order, 'item_name') if idx ~= nil then -- Step 1: Split out prefix/suffix local prefix = string.sub(order, 0, idx - 1) local suffix = string.sub(order, idx + 9) -- Step 2: Replace parameters with their actual values for arg_name, arg_text in pairs(args) do assert(arg_text, 'Text for arg ' .. arg_name .. ' was nil') prefix = string.gsub(prefix, arg_name, arg_text) suffix = string.gsub(suffix, arg_name, arg_text) end -- Step 3: Replace prefix/suffix as needed if negatives[args['prefix']] then prefix = '' elseif args['prefix'] ~= nil then prefix = args['prefix'] .. ' ' end if negatives[args['suffix']] then suffix = '' elseif args['suffix'] ~= nil then suffix = ' ' .. args['suffix'] end assert(args['item_name'], 'Text for arg item_name was nil') output_string = prefix .. args['item_name'] .. suffix else -- No prefix/suffix, since there's no item_name -- Step 2: Replace parameters with their actual values for arg_name, arg_text in pairs(args) do assert(arg_text, 'Text for arg ' .. arg_name .. ' was nil') order = string.gsub(order, arg_name, arg_text) end output_string = order end -- Step 4: Clean up extra characters output_string = string.gsub(output_string, '%( *', '(') -- Extra spaces in parenthesis output_string = string.gsub(output_string, ' *%)', ')') -- Extra spaces in parenthesis output_string = string.gsub(output_string, ', *%)', ')') -- Comma, then end of parenthentical output_string = string.gsub(output_string, '%( *,', '(') -- Start of parenthetical, then comma output_string = string.gsub(output_string, '%(%)', '') -- Empty parentheticals output_string = string.gsub(output_string, '- *-', '-') -- Double dashes output_string = string.gsub(output_string, '- *$', '') -- Trailing dashes output_string = string.gsub(output_string, '^ *-', '') -- Leading dashes output_string = string.gsub(output_string, '- *%(', ' (') -- Dash, then start of parenthetical output_string = string.gsub(output_string, '%) *-', ') ') -- End of parenthetical, then dash output_string = string.gsub(output_string, ' +', ' ') -- Double spaces output_string = string.gsub(output_string, '^ ', '') -- Extra space at start output_string = string.gsub(output_string, ' $', '') -- Extra space at end local lang = frame:expandTemplate{title='If lang'} if lang == '/zh-hans' or lang == '/zh-hant' then -- Replace parenthesis in chinese output_string = string.gsub(output_string, '(', '(') output_string = string.gsub(output_string, ')', ')') end return output_string end