]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/debian/missing-sources/framework/Web/Javascripts/source/tinymce-405/classes/util/I18n.js
baculum: Add missing-sources directory in debian metadata structure
[bacula/bacula] / gui / baculum / debian / missing-sources / framework / Web / Javascripts / source / tinymce-405 / classes / util / I18n.js
1 /**
2  * I18n.js
3  *
4  * Copyright, Moxiecode Systems AB
5  * Released under LGPL License.
6  *
7  * License: http://www.tinymce.com/license
8  * Contributing: http://www.tinymce.com/contributing
9  */
10
11 /**
12  * I18n class that handles translation of TinyMCE UI.
13  * Uses po style with csharp style parameters.
14  *
15  * @class tinymce.util.I18n
16  */
17 define("tinymce/util/I18n", [], function() {
18         "use strict";
19
20         var data = {};
21
22         return {
23                 /**
24                  * Adds translations for a specific language code.
25                  *
26                  * @method add
27                  * @param {String} code Language code like sv_SE.
28                  * @param {Array} items Name/value array with English en_US to sv_SE.
29                  */
30                 add: function(code, items) {
31                         for (var name in items) {
32                                 data[name] = items[name];
33                         }
34                 },
35
36                 /**
37                  * Translates the specified text.
38                  *
39                  * It has a few formats:
40                  * I18n.translate("Text");
41                  * I18n.translate(["Text {0}/{1}", 0, 1]);
42                  * I18n.translate({raw: "Raw string"});
43                  *
44                  * @method translate
45                  * @param {String/Object/Array} text Text to translate.
46                  * @return {String} String that got translated.
47                  */
48                 translate: function(text) {
49                         if (typeof(text) == "undefined") {
50                                 return text;
51                         }
52
53                         if (typeof(text) != "string" && text.raw) {
54                                 return text.raw;
55                         }
56
57                         if (text.push) {
58                                 var values = text.slice(1);
59
60                                 text = (data[text[0]] || text[0]).replace(/\{([^\}]+)\}/g, function(match1, match2) {
61                                         return values[match2];
62                                 });
63                         }
64
65                         return data[text] || text;
66                 },
67
68                 data: data
69         };
70 });