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 4: Line 4:
 
local code = mw.getContentLanguage():getCode()
 
local code = mw.getContentLanguage():getCode()
 
local localeStrings = Strings[code]
 
local localeStrings = Strings[code]
local subkey = mw.text.split(path, "%.")
+
local subkeys = mw.text.split(path, "%.")
 
 
 
local result = localeStrings
 
local result = localeStrings
for _, subkey in ipairs() do
+
for _, subkey in ipairs(subkeys) do
 
result = result[subkey]
 
result = result[subkey]
 
end
 
end

Revision as of 01:06, 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
end

return p