Module:Lang: Difference between revisions

Sur (talk | contribs)
m revert previous and instead return label if label is found in english but key does not exist for that lang; Undo revision 10494 by Sur (talk)
Sur (talk | contribs)
m get_string upper_lower param removed, use css inline instead
Line 29: Line 29:


-- Get a localized string by the raw key
-- Get a localized string by the raw key
p.get_string = function(key, lang_code_override, fallback_str, remove_var_index, upper_lower)
p.get_string = function(key, lang_code_override, fallback_str, remove_var_index)
-- If called internally (direct Lua call), args will be passed directly.
-- If called internally (direct Lua call), args will be passed directly.
     -- If called from wikitext, `key` will be the `frame` object, and we get args from `frame.args`.
     -- If called from wikitext, `key` will be the `frame` object, and we get args from `frame.args`.
Line 40: Line 40:
         fallback_str = frame.args["fallback_str"]
         fallback_str = frame.args["fallback_str"]
         remove_var_index = frame.args["remove_var_index"]
         remove_var_index = frame.args["remove_var_index"]
        upper_lower = frame.args["upper_lower"]
     end
     end


Line 70: Line 69:
if (remove_var_index ~= nil) then  
if (remove_var_index ~= nil) then  
label = util_module.remove_var(label, remove_var_index)
label = util_module.remove_var(label, remove_var_index)
end
-- Apply upper or lowercase
if (upper_lower ~= nil) then
if (mw.ustring.lower(upper_lower) == 'upper') then
label = mw.ustring.upper(label)
elseif mw.ustring.lower(upper_lower) == 'lower' then
label = mw.ustring.lower(label)
end
end
end