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
m (HylianKing moved page Module:Translate to Module:I18n without leaving a redirect)
No edit summary
Line 1: Line 1:
 
local p = {}
 
local p = {}
   
function p.translate()
+
function p.getString(path)
  +
local code = mw.getContentLanguage():getCode()
mw.logObject(Strings)
 
  +
local localeStrings = Strings[code]
  +
local subkey = mw.text.split(path, "%.")
  +
  +
local result = localeStrings
  +
for _, subkey in ipairs() do
  +
result = result[subkey]
  +
end
  +
return result
 
end
 
end
   

Revision as of 01:04, 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 subkey = mw.text.split(path, "%.")
	
	local result = localeStrings
	for _, subkey in ipairs() do
		result = result[subkey]
	end
	return result
end

return p