Zelda Wiki

Want to contribute to this wiki?
Sign up for an account, and get started!

Come join the Zelda Wiki community Discord server!

READ MORE

Zelda Wiki
Line 1: Line 1:
 
local p = {}
 
local p = {}
   
function p.getString(path)
+
function p.getString(path, ...)
 
local code = mw.getContentLanguage():getCode()
 
local code = mw.getContentLanguage():getCode()
 
local localeStrings = Strings[code]
 
local localeStrings = Strings[code]
Line 10: Line 10:
 
result = result[subkey]
 
result = result[subkey]
 
end
 
end
return result
+
return result:format(...)
 
end
 
end
   

Revision as of 01:30, 14 March 2020

Documentation for this module may be created at Module:I18n/Documentation

local p = {}

function p.getString(path, ...)
	local code = mw.getContentLanguage():getCode()
	local localeStrings = Strings[code]
	local subkeys = mw.text.split(path, "%.")
	
	local result = localeStrings
	for _, subkey in ipairs(subkeys) do
		result = result[subkey]
	end
	return result:format(...)
end

return p