Editing Module:LangGive feedback
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision | Your text | ||
| Line 295: | Line 295: | ||
html:wikitext(label) | html:wikitext(label) | ||
return tostring(html) | return tostring(html) | ||
end | |||
p.test = function(frame) | |||
return p.get_string('CitadelCategoryWeapon', 'en') | |||
end | |||
-- Get a localized string by the raw key, return fallback string if unable to be localized | |||
p.get_string_fallback = function(frame) | |||
local key = frame.args[1] | |||
local fallback = frame.args[2] | |||
local lang_code = get_lang_code() | |||
local data = get_lang_file(lang_code) | |||
if (data == nil) then | |||
return string.format("Lang code '%s' does not have a json file", lang_code) | |||
end | |||
local label = data[key] | |||
if (label == nil) then | |||
return fallback | |||
end | |||
return label | |||
end | |||
--Get a localized string by the raw key, and remove %variable% from key | |||
p.get_string_remove_var = function(frame) | |||
local key = frame.args[1] | |||
local spaces = frame.args[2] | |||
local lang_code = get_lang_code() | |||
local data = get_lang_file(lang_code) | |||
if (data == nil) then | |||
return string.format("Lang code '%s' does not have a json file", lang_code) | |||
end | |||
local label = data[key] | |||
label = util_module.remove_var(label, spaces) | |||
return label | |||
end | |||
-- get_string, but for internal use by other modules | |||
p._get_string = function(key, lang_override) | |||
lang_code = get_lang_code() | |||
local data = get_lang_file(lang_override or lang_code) | |||
if (data == nil) then | |||
return nil | |||
end | |||
local label = data[KEY_OVERRIDES[key] or key] | |||
if (label == nil) then | |||
return nil | |||
end | |||
return label | |||
end | end | ||