#include "ui_defs.lua" Ui.LocString = { Mt = { __tostring = function(tbl) return tbl.value end, getSize = function(self) return Ui.GetTextSize(self.value) end, translate = function(self) return GetTranslatedStringByKey(self.value) end, }, new = function(value) local obj = { value = value } setmetatable(obj, Ui.LocString.Mt) return obj end, } Ui.LocString.Mt.__index = Ui.LocString.Mt Ui.loc = function (value) return Ui.LocString.new(value) end --[[ EXAMPLE: local cancelButton = Ui.loc"UI_BUTTON_CANCEL" print(cancelButton) -- calls the __tostring function and outputs "UI_BUTTON_CANCEL" print(cancelButton:translate()) -- presumably translates the string and outputs the result ]]