tr8n 3.2.2 → 3.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/tr8n/version.rb +1 -1
- data/tr8n.gemspec +2 -2
- metadata +41 -117
- data/app/javascript/compile.rb +0 -37
- data/app/javascript/compile.sh +0 -1
- data/app/javascript/compressors/google/COPYING +0 -202
- data/app/javascript/compressors/google/README +0 -292
- data/app/javascript/compressors/google/compiler.jar +0 -0
- data/app/javascript/config.yml +0 -66
- data/app/javascript/src/base.js +0 -35
- data/app/javascript/src/effects.js +0 -67
- data/app/javascript/src/ext/inflector.js +0 -309
- data/app/javascript/src/ext/jsDraw2D.js +0 -24
- data/app/javascript/src/ext/keyboard_1_36.js +0 -1214
- data/app/javascript/src/ext/keyboard_1_44.js +0 -1735
- data/app/javascript/src/ext/keyboard_1_49.js +0 -1796
- data/app/javascript/src/ext/md5.js +0 -209
- data/app/javascript/src/ext/shortcut.js +0 -223
- data/app/javascript/src/init.js +0 -47
- data/app/javascript/src/language.js +0 -38
- data/app/javascript/src/logger.js +0 -203
- data/app/javascript/src/prototype/effects.js +0 -65
- data/app/javascript/src/proxy.js +0 -254
- data/app/javascript/src/rules/date_rule.js +0 -37
- data/app/javascript/src/rules/gender_list_rule.js +0 -37
- data/app/javascript/src/rules/gender_rule.js +0 -87
- data/app/javascript/src/rules/language_rule.js +0 -55
- data/app/javascript/src/rules/list_rule.js +0 -37
- data/app/javascript/src/rules/numeric_rule.js +0 -95
- data/app/javascript/src/tml/label.js +0 -60
- data/app/javascript/src/tml/token.js +0 -107
- data/app/javascript/src/tokens/data_token.js +0 -45
- data/app/javascript/src/tokens/decoration_token.js +0 -82
- data/app/javascript/src/tokens/token.js +0 -121
- data/app/javascript/src/tokens/transform_token.js +0 -106
- data/app/javascript/src/translation_key.js +0 -183
- data/app/javascript/src/ui/language_case_manager.js +0 -155
- data/app/javascript/src/ui/language_selector.js +0 -126
- data/app/javascript/src/ui/lightbox.js +0 -72
- data/app/javascript/src/ui/translator.js +0 -257
- data/app/javascript/src/utils.js +0 -286
@@ -1,37 +0,0 @@
|
|
1
|
-
/****************************************************************************
|
2
|
-
Copyright (c) 2010-2012 Michael Berkovich, Ian McDaniel, tr8n.net
|
3
|
-
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
a copy of this software and associated documentation files (the
|
6
|
-
"Software"), to deal in the Software without restriction, including
|
7
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be
|
13
|
-
included in all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
****************************************************************************/
|
23
|
-
|
24
|
-
Tr8n.Proxy.DateRule = function(definition, options) {
|
25
|
-
this.definition = definition;
|
26
|
-
this.options = options;
|
27
|
-
}
|
28
|
-
|
29
|
-
Tr8n.Proxy.DateRule.prototype = new Tr8n.Proxy.LanguageRule();
|
30
|
-
|
31
|
-
Tr8n.Proxy.DateRule.transform = function(object, values) {
|
32
|
-
return "";
|
33
|
-
}
|
34
|
-
|
35
|
-
Tr8n.Proxy.DateRule.prototype.evaluate = function(token, token_values) {
|
36
|
-
return true;
|
37
|
-
}
|
@@ -1,37 +0,0 @@
|
|
1
|
-
/****************************************************************************
|
2
|
-
Copyright (c) 2010-2012 Michael Berkovich, Ian McDaniel, tr8n.net
|
3
|
-
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
a copy of this software and associated documentation files (the
|
6
|
-
"Software"), to deal in the Software without restriction, including
|
7
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be
|
13
|
-
included in all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
****************************************************************************/
|
23
|
-
|
24
|
-
Tr8n.Proxy.GenderListRule = function(definition, options) {
|
25
|
-
this.definition = definition;
|
26
|
-
this.options = options;
|
27
|
-
}
|
28
|
-
|
29
|
-
Tr8n.Proxy.GenderListRule.prototype = new Tr8n.Proxy.LanguageRule();
|
30
|
-
|
31
|
-
Tr8n.Proxy.GenderListRule.transform = function(object, values) {
|
32
|
-
return "";
|
33
|
-
}
|
34
|
-
|
35
|
-
Tr8n.Proxy.GenderListRule.prototype.evaluate = function(token, token_values) {
|
36
|
-
return true;
|
37
|
-
}
|
@@ -1,87 +0,0 @@
|
|
1
|
-
/****************************************************************************
|
2
|
-
Copyright (c) 2010-2012 Michael Berkovich, Ian McDaniel, tr8n.net
|
3
|
-
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
a copy of this software and associated documentation files (the
|
6
|
-
"Software"), to deal in the Software without restriction, including
|
7
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be
|
13
|
-
included in all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
****************************************************************************/
|
23
|
-
|
24
|
-
Tr8n.Proxy.GenderRule = function(definition, options) {
|
25
|
-
this.definition = definition;
|
26
|
-
this.options = options;
|
27
|
-
}
|
28
|
-
|
29
|
-
Tr8n.Proxy.GenderRule.prototype = new Tr8n.Proxy.LanguageRule();
|
30
|
-
|
31
|
-
// FORM: [male, female, unknown]
|
32
|
-
// {user | registered on}
|
33
|
-
// {user | he, she}
|
34
|
-
// {user | he, she, he/she}
|
35
|
-
Tr8n.Proxy.GenderRule.transform = function(object, values) {
|
36
|
-
if (values.length == 1) return values[0];
|
37
|
-
|
38
|
-
if (typeof object == 'string') {
|
39
|
-
if (object == 'male') return values[0];
|
40
|
-
if (object == 'female') return values[1];
|
41
|
-
} else if (typeof object == 'object') {
|
42
|
-
if (object['gender'] == 'male') return values[0];
|
43
|
-
if (object['gender'] == 'female') return values[1];
|
44
|
-
}
|
45
|
-
|
46
|
-
if (values.length == 3) return values[2];
|
47
|
-
return values[0] + "/" + values[1];
|
48
|
-
}
|
49
|
-
|
50
|
-
Tr8n.Proxy.GenderRule.prototype.evaluate = function(token_name, token_values) {
|
51
|
-
|
52
|
-
var object = this.getTokenValue(token_name, token_values);
|
53
|
-
if (!object) return false;
|
54
|
-
|
55
|
-
var gender = "";
|
56
|
-
|
57
|
-
if (typeof object != 'object') {
|
58
|
-
this.getLogger().error("Invalid token value for gender based token: " + token_name + ". Token value must be an object.");
|
59
|
-
return false;
|
60
|
-
}
|
61
|
-
|
62
|
-
if (!object['subject']) {
|
63
|
-
this.getLogger().error("Invalid token subject for gender based token: " + token_name + ". Token value must contain a subject. Subject can be a string or an object with a gender.");
|
64
|
-
return false;
|
65
|
-
}
|
66
|
-
|
67
|
-
if (typeof object['subject'] == 'string') {
|
68
|
-
gender = object['subject'];
|
69
|
-
} else if (typeof object['subject'] == 'object') {
|
70
|
-
gender = object['subject']['gender'];
|
71
|
-
if (!gender) {
|
72
|
-
this.getLogger().error("Cannot determine gender for token subject: " + token_name);
|
73
|
-
return false;
|
74
|
-
}
|
75
|
-
} else {
|
76
|
-
this.getLogger().error("Invalid token subject for gender based token: " + token_name + ". Subject does not have a gender.");
|
77
|
-
return false;
|
78
|
-
}
|
79
|
-
|
80
|
-
if (this.definition['operator'] == "is") {
|
81
|
-
return (gender == this.definition['value']);
|
82
|
-
} else if (this.definition['operator'] == "is_not") {
|
83
|
-
return (gender != this.definition['value']);
|
84
|
-
}
|
85
|
-
|
86
|
-
return false;
|
87
|
-
}
|
@@ -1,55 +0,0 @@
|
|
1
|
-
/****************************************************************************
|
2
|
-
Copyright (c) 2010-2012 Michael Berkovich, Ian McDaniel, tr8n.net
|
3
|
-
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
a copy of this software and associated documentation files (the
|
6
|
-
"Software"), to deal in the Software without restriction, including
|
7
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be
|
13
|
-
included in all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
****************************************************************************/
|
23
|
-
|
24
|
-
Tr8n.Proxy.LanguageRule = function() {}
|
25
|
-
|
26
|
-
Tr8n.Proxy.LanguageRule.prototype = {
|
27
|
-
getProxy: function() {
|
28
|
-
return this.options['proxy'];
|
29
|
-
},
|
30
|
-
getLogger: function() {
|
31
|
-
return this.getProxy().logger;
|
32
|
-
},
|
33
|
-
getTokenValue: function(token_name, token_values) {
|
34
|
-
var object = token_values[token_name];
|
35
|
-
if (object == null) {
|
36
|
-
this.getLogger().error("Invalid token value for token: " + token_name);
|
37
|
-
}
|
38
|
-
|
39
|
-
return object;
|
40
|
-
},
|
41
|
-
getDefinitionDescription: function() {
|
42
|
-
var result = [];
|
43
|
-
for (var key in this.definition)
|
44
|
-
result.push(key + ": '" + this.definition[key] + "'");
|
45
|
-
return "{" + result.join(", ") + "}";
|
46
|
-
},
|
47
|
-
sanitizeArrayValue: function(value) {
|
48
|
-
var results = [];
|
49
|
-
var arr = value.split(',');
|
50
|
-
for (var index = 0; index < arr.length; index++) {
|
51
|
-
results.push(Tr8n.Utils.trim(arr[index]));
|
52
|
-
}
|
53
|
-
return results;
|
54
|
-
}
|
55
|
-
}
|
@@ -1,37 +0,0 @@
|
|
1
|
-
/****************************************************************************
|
2
|
-
Copyright (c) 2010-2012 Michael Berkovich, Ian McDaniel, tr8n.net
|
3
|
-
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
a copy of this software and associated documentation files (the
|
6
|
-
"Software"), to deal in the Software without restriction, including
|
7
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be
|
13
|
-
included in all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
****************************************************************************/
|
23
|
-
|
24
|
-
Tr8n.Proxy.ListRule = function(definition, options) {
|
25
|
-
this.definition = definition;
|
26
|
-
this.options = options;
|
27
|
-
}
|
28
|
-
|
29
|
-
Tr8n.Proxy.ListRule.prototype = new Tr8n.Proxy.LanguageRule();
|
30
|
-
|
31
|
-
Tr8n.Proxy.ListRule.transform = function(object, values) {
|
32
|
-
return "";
|
33
|
-
}
|
34
|
-
|
35
|
-
Tr8n.Proxy.ListRule.prototype.evaluate = function(token, token_values) {
|
36
|
-
return true;
|
37
|
-
}
|
@@ -1,95 +0,0 @@
|
|
1
|
-
/****************************************************************************
|
2
|
-
Copyright (c) 2010-2012 Michael Berkovich, Ian McDaniel, tr8n.net
|
3
|
-
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
a copy of this software and associated documentation files (the
|
6
|
-
"Software"), to deal in the Software without restriction, including
|
7
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be
|
13
|
-
included in all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
****************************************************************************/
|
23
|
-
|
24
|
-
Tr8n.Proxy.NumericRule = function(definition, options) {
|
25
|
-
this.definition = definition;
|
26
|
-
this.options = options;
|
27
|
-
}
|
28
|
-
|
29
|
-
Tr8n.Proxy.NumericRule.prototype = new Tr8n.Proxy.LanguageRule();
|
30
|
-
|
31
|
-
// English based transform method
|
32
|
-
// FORM: [singular, plural]
|
33
|
-
// {count | message, messages}
|
34
|
-
// {count | person, people}
|
35
|
-
Tr8n.Proxy.NumericRule.transform = function(count, values) {
|
36
|
-
if (count == 1) return values[0];
|
37
|
-
if (values.length == 2) {
|
38
|
-
return values[1];
|
39
|
-
}
|
40
|
-
return values[0].pluralize();
|
41
|
-
}
|
42
|
-
|
43
|
-
Tr8n.Proxy.NumericRule.prototype.evaluate = function(token_name, token_values){
|
44
|
-
// "count":{"value1":"2,3,4","operator":"and","type":"number","multipart":true,"part2":"does_not_end_in","value2":"12,13,14","part1":"ends_in"}
|
45
|
-
|
46
|
-
var object = this.getTokenValue(token_name, token_values);
|
47
|
-
if (object == null) return false;
|
48
|
-
|
49
|
-
var token_value = null;
|
50
|
-
if (typeof object == 'string' || typeof object == 'number') {
|
51
|
-
token_value = "" + object;
|
52
|
-
} else if (typeof object == 'object' && object['subject']) {
|
53
|
-
token_value = "" + object['subject'];
|
54
|
-
} else {
|
55
|
-
this.getLogger().error("Invalid token value for numeric token: " + token_name);
|
56
|
-
return false;
|
57
|
-
}
|
58
|
-
|
59
|
-
this.getLogger().debug("Rule value: '" + token_value + "' for definition: " + this.getDefinitionDescription());
|
60
|
-
|
61
|
-
var result1 = this.evaluatePartialRule(token_value, this.definition['part1'], this.sanitizeArrayValue(this.definition['value1']));
|
62
|
-
if (this.definition['multipart'] == 'false' || this.definition['multipart'] == false || this.definition['multipart'] == null) return result1;
|
63
|
-
this.getLogger().debug("Part 1: " + result1 + " Processing part 2...");
|
64
|
-
|
65
|
-
var result2 = this.evaluatePartialRule(token_value, this.definition['part2'], this.sanitizeArrayValue(this.definition['value2']));
|
66
|
-
this.getLogger().debug("Part 2: " + result2 + " Completing evaluation...");
|
67
|
-
|
68
|
-
if (this.definition['operator'] == "or") return (result1 || result2);
|
69
|
-
return (result1 && result2);
|
70
|
-
}
|
71
|
-
|
72
|
-
|
73
|
-
Tr8n.Proxy.NumericRule.prototype.evaluatePartialRule = function(token_value, name, values) {
|
74
|
-
if (name == 'is') {
|
75
|
-
if (Tr8n.Utils.indexOf(values, token_value)!=-1) return true;
|
76
|
-
return false;
|
77
|
-
}
|
78
|
-
if (name == 'is_not') {
|
79
|
-
if (Tr8n.Utils.indexOf(values, token_value)==-1) return true;
|
80
|
-
return false;
|
81
|
-
}
|
82
|
-
if (name == 'ends_in') {
|
83
|
-
for(var i=0; i<values.length; i++) {
|
84
|
-
if (token_value.match(values[i] + "$")) return true;
|
85
|
-
}
|
86
|
-
return false;
|
87
|
-
}
|
88
|
-
if (name == 'does_not_end_in') {
|
89
|
-
for(var i=0; i<values.length; i++) {
|
90
|
-
if (token_value.match(values[i] + "$")) return false;
|
91
|
-
}
|
92
|
-
return true;
|
93
|
-
}
|
94
|
-
return false;
|
95
|
-
}
|
@@ -1,60 +0,0 @@
|
|
1
|
-
/****************************************************************************
|
2
|
-
Copyright (c) 2010-2012 Michael Berkovich, Ian McDaniel, tr8n.net
|
3
|
-
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
a copy of this software and associated documentation files (the
|
6
|
-
"Software"), to deal in the Software without restriction, including
|
7
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be
|
13
|
-
included in all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
****************************************************************************/
|
23
|
-
|
24
|
-
Tr8n.Tml = Tr8n.Tml || {};
|
25
|
-
|
26
|
-
Tr8n.Tml.Label = function(node, proxy) {
|
27
|
-
this.node = node;
|
28
|
-
this.label = "";
|
29
|
-
this.description = "";
|
30
|
-
this.tokens = {};
|
31
|
-
this.options = {};
|
32
|
-
this.proxy = proxy;
|
33
|
-
|
34
|
-
for (var i=0; i < this.node.childNodes.length; i++) {
|
35
|
-
var childNode = this.node.childNodes[i];
|
36
|
-
|
37
|
-
// text should just be added to the label
|
38
|
-
if (childNode.nodeType == 3) {
|
39
|
-
this.label = this.label + " " + Tr8n.Utils.trim(childNode.nodeValue);
|
40
|
-
} else if (childNode.nodeName == "TML:TOKEN") {
|
41
|
-
var token = new Tr8n.Tml.Token(childNode, this.tokens);
|
42
|
-
this.label = Tr8n.Utils.trim(this.label) + " " + token.toTokenString();
|
43
|
-
}
|
44
|
-
|
45
|
-
}
|
46
|
-
|
47
|
-
this.description = this.node.attributes['desc'] || this.node.attributes['description'];
|
48
|
-
this.description = this.description ? this.description.value : null;
|
49
|
-
|
50
|
-
this.label = this.label.replace(/\n/g, '');
|
51
|
-
this.label = Tr8n.Utils.trim(this.label);
|
52
|
-
|
53
|
-
// console.log(this.label + " : " + this.description);
|
54
|
-
}
|
55
|
-
|
56
|
-
Tr8n.Tml.Label.prototype = {
|
57
|
-
translate: function() {
|
58
|
-
this.node.innerHTML = this.proxy.translate(this.label, this.description, this.tokens, this.options);
|
59
|
-
}
|
60
|
-
}
|
@@ -1,107 +0,0 @@
|
|
1
|
-
/****************************************************************************
|
2
|
-
Copyright (c) 2010-2012 Michael Berkovich, Ian McDaniel, tr8n.net
|
3
|
-
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
a copy of this software and associated documentation files (the
|
6
|
-
"Software"), to deal in the Software without restriction, including
|
7
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be
|
13
|
-
included in all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
****************************************************************************/
|
23
|
-
|
24
|
-
Tr8n.Tml = Tr8n.Tml || {};
|
25
|
-
|
26
|
-
Tr8n.Tml.Token = function(node, tokens) {
|
27
|
-
this.node = node;
|
28
|
-
|
29
|
-
this.type = this.node.attributes['type'];
|
30
|
-
this.type = this.type ? this.type.value : 'data';
|
31
|
-
|
32
|
-
this.name = this.node.attributes['name'];
|
33
|
-
this.name = this.name ? this.name.value : 'unknown';
|
34
|
-
this.name = this.name.toLowerCase();
|
35
|
-
|
36
|
-
this.context = this.node.attributes['context'];
|
37
|
-
this.context = this.context ? this.context.value : null;
|
38
|
-
|
39
|
-
this.content = "";
|
40
|
-
|
41
|
-
for (var i=0; i < this.node.childNodes.length; i++) {
|
42
|
-
var childNode = this.node.childNodes[i];
|
43
|
-
// console.log(childNode.nodeType + " " + childNode.nodeValue);
|
44
|
-
var token_type = this.node.attributes['type'] ? this.node.attributes['type'].nodeValue : 'data';
|
45
|
-
// console.log(this.name + " " + token_type);
|
46
|
-
|
47
|
-
if (childNode.nodeType == 3) {
|
48
|
-
// text should just be added to the label
|
49
|
-
// <tml:label>You have <tml:token type="data" name="count" context="number">2</tml:token> messages.</tml:label>
|
50
|
-
|
51
|
-
if (node.attributes['context'] && node.attributes['context'].nodeValue == 'gender') {
|
52
|
-
tokens[this.name] = {subject: node.attributes['value'].nodeValue, value: Tr8n.Utils.trim(childNode.nodeValue)};
|
53
|
-
} else {
|
54
|
-
tokens[this.name] = Tr8n.Utils.trim(childNode.nodeValue);
|
55
|
-
}
|
56
|
-
|
57
|
-
} else {
|
58
|
-
// the first element inside the token must be a decoration span, bold, etc...
|
59
|
-
// <tml:label>Hello
|
60
|
-
// <tml:token type="decoration" name="span">
|
61
|
-
// <span style='color:brown;font-weight:bold;'>
|
62
|
-
// World
|
63
|
-
// </span>
|
64
|
-
// </tml:token>
|
65
|
-
// </tml:label>
|
66
|
-
|
67
|
-
var html_tag = childNode.nodeName.toLowerCase();
|
68
|
-
var attributes = [];
|
69
|
-
if (childNode.attributes['style']) {
|
70
|
-
attributes.push("style='" + childNode.attributes['style'].nodeValue + "'");
|
71
|
-
}
|
72
|
-
if (childNode.attributes['class']) {
|
73
|
-
attributes.push("class='" + childNode.attributes['class'].nodeValue + "'");
|
74
|
-
}
|
75
|
-
|
76
|
-
tokens[this.name] = "<" + html_tag + " " + attributes.join(' ') + ">{$0}</" + html_tag + ">";
|
77
|
-
|
78
|
-
// console.log(this.name + " has value of " + tokens[this.name]);
|
79
|
-
|
80
|
-
this.content = "";
|
81
|
-
|
82
|
-
for (var j=0; j<childNode.childNodes.length; j++) {
|
83
|
-
var grandChildNode = childNode.childNodes[j];
|
84
|
-
if (grandChildNode.nodeType == 3) {
|
85
|
-
this.content = Tr8n.Utils.trim(this.content) + " " + Tr8n.Utils.trim(grandChildNode.nodeValue);
|
86
|
-
} else if (grandChildNode.nodeName == "TML:TOKEN") {
|
87
|
-
var token = new Tr8n.Tml.Token(grandChildNode, tokens);
|
88
|
-
this.content = Tr8n.Utils.trim(this.content) + " " + token.toTokenString();
|
89
|
-
}
|
90
|
-
}
|
91
|
-
}
|
92
|
-
}
|
93
|
-
|
94
|
-
this.content = this.content.replace(/\n/g, '');
|
95
|
-
this.content = Tr8n.Utils.trim(this.content);
|
96
|
-
}
|
97
|
-
|
98
|
-
Tr8n.Tml.Token.prototype = {
|
99
|
-
toTokenString: function() {
|
100
|
-
if (this.type == "data") {
|
101
|
-
// TODO: we may need to add dependencies here: gender, number and language cases
|
102
|
-
return "{" + this.name + "}";
|
103
|
-
} else {
|
104
|
-
return "[" + this.name + ": " + this.content + "]";
|
105
|
-
}
|
106
|
-
}
|
107
|
-
}
|