--[[
  
  language.lua - alternative of translate function
  
  language.translate()
  _()
]]

language = {}

local file = PREFPATH .. "language.cfg"
local trans = {}

local function initialize()
	local line, s, e, f
	f = io.open(file)
	if f then
		for line in f:lines() do
			s, e = string.match(line, "([^=]+)=(.+)")
			if s and e then
				s = string.gsub(s, "^%s*", "", 1)
				s = string.gsub(s, "%s*$", "", 1)
				e = string.gsub(e, "%s*$", "", 1)
				e = string.gsub(e, "^%s*", "", 1)
				trans[s] = e
			end
		end
		f:close()
	end
end

function language.translate(from)
	return trans[from]
end

_ = language.translate

initialize()
