jbe@203: -- string localization function jbe/bsw@0: function _(text, replacements) jbe/bsw@0: local text = locale._get_translation_table()[text] or text jbe/bsw@0: if replacements then jbe/bsw@0: return ( jbe/bsw@0: string.gsub( jbe/bsw@0: text, jbe/bsw@0: "#{(.-)}", jbe/bsw@0: function (placeholder) jbe/bsw@0: return replacements[placeholder] jbe/bsw@0: end jbe/bsw@0: ) jbe/bsw@0: ) jbe/bsw@0: else jbe/bsw@0: return text jbe/bsw@0: end jbe/bsw@0: end jbe@203: jbe@203: --[[-- jbe@203: cloned_table = -- newly generated table jbe@203: table.new( jbe@203: table_or_nil -- keys of a given table will be copied to the new table jbe@203: ) jbe@203: jbe@203: If a table is given, then a cloned table is returned. jbe@203: If nil is given, then a new empty table is returned. jbe@203: jbe@203: --]]-- jbe@203: function table.new(tbl) jbe@240: local new_tbl = {} jbe@203: if tbl then jbe@203: for key, value in pairs(tbl) do jbe@203: new_tbl[key] = value jbe@203: end jbe@203: end jbe@203: return new_tbl jbe@203: end jbe@203: --//-- jbe@203: jbe@203: -- load libraries jbe@203: extos = require 'extos' jbe@203: nihil = require 'nihil' jbe@229: --multirand = require 'multirand' -- TODO: load after forking jbe@203: mondelefant = require 'mondelefant' jbe@203: mondelefant.connection_prototype.error_objects = true jbe@203: atom = require 'atom' jbe@203: json = require 'json' jbe@203: require 'mondelefant_atom_connector' jbe@203: jbe@206: --[[-- jbe@206: app -- table to store an application state jbe@206: jbe@206: 'app' is a global table for storing any application state data jbe@206: --]]-- jbe@206: app = {} jbe@206: --//-- jbe@206: jbe@206: --[[-- jbe@206: config -- table to store application configuration jbe@206: jbe@206: 'config' is a global table, which can be modified by a config file of an application to modify the behaviour of that application. jbe@206: --]]-- jbe@206: config = {} jbe@206: --//-- jbe@206: