-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmsg.ms
More file actions
20 lines (17 loc) · 764 Bytes
/
msg.ms
File metadata and controls
20 lines (17 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
proc _util_msg_register_module(string @module, string @path) {
@model = import('org.cadabra.msutil.msg')
@model[@module] = array()
@model[@module]['path'] = length(@path)
}
proc _util_msg_register_file(string @module, array @msg) {
@model = import('org.cadabra.msutil.msg')
@model[@module]['msg'][@msg['name']] = @msg['msg']
}
string proc _util_msg(@module, @key, @stack = 1, @args = array()) {
@model = import('org.cadabra.msutil.msg')[@module]
@trace = get_stack_trace()
#extract the path to the file relative the folder from the stack
@file = replace(@trace[@stack]['file'][cslice(@model['path']+1, -1)], _util_sdn(), '.')
return(sprintf(@model['msg'][@file][@key], @args))
}
export('org.cadabra.msutil.msg', array())