FANDOM


---------------------------------------------------------------------
-- This module is used to build and store translation dictionary.
-- The terms are orderd and case-sensitive.
---------------------------------------------------------------------
 
local p = {}
 
local Dictionary = {}
 
local OrderedTerms = {}
 
local CurrentGroup = nil
 
local Warnings = {}
 
function warn(message)
    ne = debug.traceback(message, 2)
    table.insert(Warnings, ne)
    return ne
end
 
function p.beginGroup(groupName)
    if groupName == nil or groupName == "" then warn("groupName cannot be nil or empty.") end
    if CurrentGroup ~= nil then warn(string.format("Currently in the Group: %s .", CurrentGroup)) end
    CurrentGroup = groupName
end
 
function p.endGroup()
    if CurrentGroup == nil then
        error("Currently not in any Group.")
    end
    CurrentGroup = groupName
end
 
-- Add a translation entry to the dictionary.
function p.addTranslation(term, translations)
    if Dictionary[term] ~= nil then
        warn(string.format("Term \"%s\" already exists. Translation ignored.", term))
        return
    end
    table.insert(OrderedTerms, term)
    Dictionary[term] = translations
end
 
function p.orderedTerms()
    return OrderedTerms
end
 
function p.getTranslation(term)
    return Dictionary[term]
end
 
function p.getWarnings()
    return Warnings
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.