Module:Utilities: Difference between revisions

fixed add_space_before_cap
Sur (talk | contribs)
m pre_expand_str test
Line 42: Line 42:
-- Add a space before each capital letter that is not the first character
-- Add a space before each capital letter that is not the first character
-- i.e. BulletVelocity > Bullet Velocity
-- i.e. BulletVelocity > Bullet Velocity
-- when a string doesn't have localization, it can outputted as add_space_before_cap(unlocalized_key)
function p.add_space_before_cap(str)
function p.add_space_before_cap(str)
    local result = str:gsub("(%l)(%u)", "%1 %2")
    local result = str:gsub("(%l)(%u)", "%1 %2")
    return result:gsub("(%u)(%u%l)", " %1%2")
    return result:gsub("(%u)(%u%l)", " %1%2")
end
p.pre_expand_str = function(frame)
local str = frame.args[1]
return str
end
end
return p
return p