Editing Module:Lang

Warning: You are not logged in. Once you make an edit, a temporary account will be created for you. Learn more. Log in or create an account to continue receiving notifications after this account expires, and to access other features.
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


Please note that all contributions to The Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see Deadlock:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template