##// END OF EJS Templates
i18n: replaced fragile extraction of JS translations from an _TM variable....
marcink -
r325:9f2e29d4 stable
parent child Browse files
Show More
@@ -1,33 +1,42 b''
1 // translate select2 components
1 // translate select2 components
2 select2Locales = {
2 select2Locales = {
3 formatLoadMore: function(pageNumber) {
3 formatLoadMore: function(pageNumber) {
4 return _TM["Loading more results..."];
4 return _gettext("Loading more results...");
5 },
5 },
6 formatSearching: function() {
6 formatSearching: function() {
7 return _TM["Searching..."];
7 return _gettext("Searching...");
8 },
8 },
9 formatNoMatches: function() {
9 formatNoMatches: function() {
10 return _TM["No matches found"];
10 return _gettext("No matches found");
11 },
11 },
12 formatAjaxError: function(jqXHR, textStatus, errorThrown) {
12 formatAjaxError: function(jqXHR, textStatus, errorThrown) {
13 return _TM["Loading failed"];
13 return _gettext("Loading failed");
14 },
14 },
15 formatMatches: function(matches) {
15 formatMatches: function(matches) {
16 if (matches === 1) {
16 if (matches === 1) {
17 return _TM["One result is available, press enter to select it."];
17 return _gettext("One result is available, press enter to select it.");
18 }
18 }
19 return _TM["{0} results are available, use up and down arrow keys to navigate."].format(matches);
19 return _gettext("{0} results are available, use up and down arrow keys to navigate.").format(matches);
20 },
20 },
21 formatInputTooShort: function(input, min) {
21 formatInputTooShort: function(input, min) {
22 var n = min - input.length;
22 var n = min - input.length;
23 return "Please enter {0} or more character".format(n) + (n === 1 ? "" : "s");
23 if (n === 1) {
24 return _gettext("Please enter {0} or more character").format(n);
25 }
26 return _gettext("Please enter {0} or more characters").format(n);
24 },
27 },
25 formatInputTooLong: function(input, max) {
28 formatInputTooLong: function(input, max) {
26 var n = input.length - max;
29 var n = input.length - max;
27 return "Please delete {0} character".format(n) + (n === 1 ? "" : "s");
30 if (n === 1) {
31 return _gettext("Please delete {0} character").format(n);
32 }
33 return _gettext("Please delete {0} characters").format(n);
28 },
34 },
29 formatSelectionTooBig: function(limit) {
35 formatSelectionTooBig: function(limit) {
30 return "You can only select {0} item".format(limit) + (limit === 1 ? "" : "s");
36 if (limit === 1) {
37 return _gettext("You can only select {0} item").format(limit);
38 }
39 return _gettext("You can only select {0} items").format(limit);
31 }
40 }
32 };
41 };
33
42
@@ -84,7 +84,7 b''
84 return typeof response === 'string' ? $.parseJSON(response) : response;
84 return typeof response === 'string' ? $.parseJSON(response) : response;
85 },
85 },
86 showNoSuggestionNotice: false,
86 showNoSuggestionNotice: false,
87 noSuggestionNotice: _TM['No results'],
87 noSuggestionNotice: _gettext('No results'),
88 orientation: 'bottom',
88 orientation: 'bottom',
89 forceFixPosition: false,
89 forceFixPosition: false,
90 replaceOnArrowKey: true
90 replaceOnArrowKey: true
@@ -10,21 +10,6 b' var AgeModule = (function () {'
10 var show_suffix = show_suffix || true;
10 var show_suffix = show_suffix || true;
11 var short_format = short_format || false;
11 var short_format = short_format || false;
12
12
13 // alias for backward compat
14 var _ = function(s) {
15 if (_TM.hasOwnProperty(s)) {
16 return _TM[s];
17 }
18 return s
19 };
20
21 var ungettext = function (singular, plural, n) {
22 if (n === 1){
23 return _(singular)
24 }
25 return _(plural)
26 };
27
28 var _get_relative_delta = function(now, prevdate) {
13 var _get_relative_delta = function(now, prevdate) {
29
14
30 var duration = moment.duration(moment(now).diff(prevdate));
15 var duration = moment.duration(moment(now).diff(prevdate));
@@ -121,12 +106,12 b' var AgeModule = (function () {'
121
106
122 } else {
107 } else {
123 var fmt_funcs = {
108 var fmt_funcs = {
124 'year': function(d) {return ungettext('{0} year', '{0} years', d).format(d)},
109 'year': function(d) {return _ngettext('{0} year', '{0} years', d).format(d)},
125 'month': function(d) {return ungettext('{0} month', '{0} months', d).format(d)},
110 'month': function(d) {return _ngettext('{0} month', '{0} months', d).format(d)},
126 'day': function(d) {return ungettext('{0} day', '{0} days', d).format(d)},
111 'day': function(d) {return _ngettext('{0} day', '{0} days', d).format(d)},
127 'hour': function(d) {return ungettext('{0} hour', '{0} hours', d).format(d)},
112 'hour': function(d) {return _ngettext('{0} hour', '{0} hours', d).format(d)},
128 'minute': function(d) {return ungettext('{0} min', '{0} min', d).format(d)},
113 'minute': function(d) {return _ngettext('{0} min', '{0} min', d).format(d)},
129 'second': function(d) {return ungettext('{0} sec', '{0} sec', d).format(d)}
114 'second': function(d) {return _ngettext('{0} sec', '{0} sec', d).format(d)}
130 }
115 }
131
116
132 }
117 }
@@ -146,7 +131,7 b' var AgeModule = (function () {'
146 var _val = fmt_funcs[part](value);
131 var _val = fmt_funcs[part](value);
147 if (future) {
132 if (future) {
148 if (show_suffix) {
133 if (show_suffix) {
149 return _('in {0}').format(_val)
134 return _gettext('in {0}').format(_val)
150 } else {
135 } else {
151 return _val
136 return _val
152 }
137 }
@@ -154,7 +139,7 b' var AgeModule = (function () {'
154 }
139 }
155 else {
140 else {
156 if (show_suffix) {
141 if (show_suffix) {
157 return _('{0} ago').format(_val)
142 return _gettext('{0} ago').format(_val)
158 } else {
143 } else {
159 return _val
144 return _val
160 }
145 }
@@ -166,17 +151,17 b' var AgeModule = (function () {'
166 if (short_format) {
151 if (short_format) {
167 var datetime_tmpl = '{0}, {1}';
152 var datetime_tmpl = '{0}, {1}';
168 if (show_suffix) {
153 if (show_suffix) {
169 datetime_tmpl = _('{0}, {1} ago');
154 datetime_tmpl = _gettext('{0}, {1} ago');
170 if (future) {
155 if (future) {
171 datetime_tmpl = _('in {0}, {1}');
156 datetime_tmpl = _gettext('in {0}, {1}');
172 }
157 }
173 }
158 }
174 } else {
159 } else {
175 var datetime_tmpl = _('{0} and {1}');
160 var datetime_tmpl = _gettext('{0} and {1}');
176 if (show_suffix) {
161 if (show_suffix) {
177 datetime_tmpl = _('{0} and {1} ago');
162 datetime_tmpl = _gettext('{0} and {1} ago');
178 if (future) {
163 if (future) {
179 datetime_tmpl = _('in {0} and {1}')
164 datetime_tmpl = _gettext('in {0} and {1}')
180 }
165 }
181 }
166 }
182 }
167 }
@@ -186,7 +171,7 b' var AgeModule = (function () {'
186 i += 1;
171 i += 1;
187 }
172 }
188
173
189 return _('just now')
174 return _gettext('just now')
190
175
191 },
176 },
192 createTimeComponent: function(dateTime, text) {
177 createTimeComponent: function(dateTime, text) {
@@ -24,15 +24,6 b' if (typeof console == "undefined" || typ'
24 console = { log: function() {} }
24 console = { log: function() {} }
25 }
25 }
26
26
27
28 // alias for backward compat
29 var _tm = function(s) {
30 if (_TM.hasOwnProperty(s)) {
31 return _TM[s];
32 }
33 return s
34 };
35
36 // TODO: move the following function to submodules
27 // TODO: move the following function to submodules
37
28
38 /**
29 /**
@@ -148,7 +139,7 b' var showRepoStats = function(target, dat'
148
139
149 var td2 = document.createElement('td');
140 var td2 = document.createElement('td');
150 var trending_language = document.createElement('div');
141 var trending_language = document.createElement('div');
151 var nr_files = obj.count +" "+ (obj.count === 1 ? _tm('file'): _tm('files'));
142 var nr_files = obj.count +" "+ _ngettext('file', 'files', obj.count);
152
143
153 trending_language.title = key + " " + nr_files;
144 trending_language.title = key + " " + nr_files;
154
145
@@ -168,7 +159,7 b' var showRepoStats = function(target, dat'
168 lnk = document.createElement('a');
159 lnk = document.createElement('a');
169
160
170 lnk.href = '#';
161 lnk.href = '#';
171 lnk.innerHTML = _tm('Show more');
162 lnk.innerHTML = _ngettext('Show more');
172 lnk.id = 'code_stats_show_more';
163 lnk.id = 'code_stats_show_more';
173 td.appendChild(lnk);
164 td.appendChild(lnk);
174
165
@@ -366,7 +366,7 b' var initCommentBoxCodeMirror = function('
366 var actions = [
366 var actions = [
367 {
367 {
368 text: "approve",
368 text: "approve",
369 displayText: _TM['Set status to Approved'],
369 displayText: _gettext('Set status to Approved'),
370 hint: function(CodeMirror, data, completion) {
370 hint: function(CodeMirror, data, completion) {
371 CodeMirror.replaceRange("", completion.from || data.from,
371 CodeMirror.replaceRange("", completion.from || data.from,
372 completion.to || data.to, "complete");
372 completion.to || data.to, "complete");
@@ -384,7 +384,7 b' var initCommentBoxCodeMirror = function('
384 },
384 },
385 {
385 {
386 text: "reject",
386 text: "reject",
387 displayText: _TM['Set status to Rejected'],
387 displayText: _gettext('Set status to Rejected'),
388 hint: function(CodeMirror, data, completion) {
388 hint: function(CodeMirror, data, completion) {
389 CodeMirror.replaceRange("", completion.from || data.from,
389 CodeMirror.replaceRange("", completion.from || data.from,
390 completion.to || data.to, "complete");
390 completion.to || data.to, "complete");
@@ -240,7 +240,7 b' var deleteComment = function(comment_id)'
240 };
240 };
241
241
242 var createInlineAddButton = function(tr){
242 var createInlineAddButton = function(tr){
243 var label = _TM['Add another comment'];
243 var label = _gettext('Add another comment');
244 var html_el = document.createElement('div');
244 var html_el = document.createElement('div');
245 $(html_el).addClass('add-comment');
245 $(html_el).addClass('add-comment');
246 html_el.innerHTML = '<span class="btn btn-secondary">{0}</span>'.format(label);
246 html_el.innerHTML = '<span class="btn btn-secondary">{0}</span>'.format(label);
@@ -458,7 +458,7 b' var CommentForm = (function() {'
458 };
458 };
459
459
460 $(this.submitForm).find(this.statusChange).select2({
460 $(this.submitForm).find(this.statusChange).select2({
461 placeholder: _TM['Status Review'],
461 placeholder: _gettext('Status Review'),
462 formatResult: formatResult,
462 formatResult: formatResult,
463 formatSelection: formatSelection,
463 formatSelection: formatSelection,
464 containerCssClass: "drop-menu status_box_menu",
464 containerCssClass: "drop-menu status_box_menu",
@@ -472,7 +472,7 b' var CommentForm = (function() {'
472 $(self.submitButton).prop('disabled', false);
472 $(self.submitButton).prop('disabled', false);
473 }
473 }
474 //todo, fix this name
474 //todo, fix this name
475 var placeholderText = _TM['Comment text will be set automatically based on currently selected status ({0}) ...'].format(status);
475 var placeholderText = _gettext('Comment text will be set automatically based on currently selected status ({0}) ...').format(status);
476 self.cm.setOption('placeholder', placeholderText);
476 self.cm.setOption('placeholder', placeholderText);
477 })
477 })
478 };
478 };
@@ -586,7 +586,7 b' var CommentForm = (function() {'
586 }
586 }
587 $(this.submitButton).prop('disabled', submitState);
587 $(this.submitButton).prop('disabled', submitState);
588 if (submitEvent) {
588 if (submitEvent) {
589 $(this.submitButton).val(_TM['Submitting...']);
589 $(this.submitButton).val(_gettext('Submitting...'));
590 } else {
590 } else {
591 $(this.submitButton).val(this.submitButtonText);
591 $(this.submitButton).val(this.submitButtonText);
592 }
592 }
@@ -636,7 +636,7 b' var CommentForm = (function() {'
636 self.setActionButtonsDisabled(true);
636 self.setActionButtonsDisabled(true);
637
637
638 $(self.previewBoxSelector).addClass('unloaded');
638 $(self.previewBoxSelector).addClass('unloaded');
639 $(self.previewBoxSelector).html(_TM['Loading ...']);
639 $(self.previewBoxSelector).html(_gettext('Loading ...'));
640 $(self.editContainer).hide();
640 $(self.editContainer).hide();
641 $(self.previewContainer).show();
641 $(self.previewContainer).show();
642
642
@@ -147,9 +147,9 b' var fileBrowserListeners = function(node'
147 if(results.length > limit){
147 if(results.length > limit){
148 var truncated_count = results.length - matches_max;
148 var truncated_count = results.length - matches_max;
149 if (truncated_count === 1) {
149 if (truncated_count === 1) {
150 match.push('<tr><td>{0} {1}</td><td colspan="5"></td></tr>'.format(truncated_count, _TM['truncated result']));
150 match.push('<tr><td>{0} {1}</td><td colspan="5"></td></tr>'.format(truncated_count, _gettext('truncated result')));
151 } else {
151 } else {
152 match.push('<tr><td>{0} {1}</td><td colspan="5"></td></tr>'.format(truncated_count, _TM['truncated results']));
152 match.push('<tr><td>{0} {1}</td><td colspan="5"></td></tr>'.format(truncated_count, _gettext('truncated results')));
153 }
153 }
154 }
154 }
155 }
155 }
@@ -158,7 +158,7 b' var fileBrowserListeners = function(node'
158 $('#tbody_filtered').show();
158 $('#tbody_filtered').show();
159
159
160 if (match.length === 0){
160 if (match.length === 0){
161 match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_TM['No matching files']));
161 match.push('<tr><td>{0}</td><td colspan="5"></td></tr>'.format(_gettext('No matching files')));
162 }
162 }
163 $('#tbody_filtered').html(match.join(""));
163 $('#tbody_filtered').html(match.join(""));
164 }
164 }
@@ -293,7 +293,7 b' var getSelectionLink = function(e) {'
293 anchor = '#L'+ranges[0]+'-'+ranges[1];
293 anchor = '#L'+ranges[0]+'-'+ranges[1];
294 var link = document.createElement('a');
294 var link = document.createElement('a');
295 link.href = location.href.substring(0,location.href.indexOf('#'))+anchor;
295 link.href = location.href.substring(0,location.href.indexOf('#'))+anchor;
296 link.innerHTML = _TM['Selection link'];
296 link.innerHTML = _gettext('Selection link');
297 hl_div.appendChild(link);
297 hl_div.appendChild(link);
298 $('#codeblock').append(hl_div);
298 $('#codeblock').append(hl_div);
299
299
@@ -23,8 +23,8 b' var onSuccessFollow = function(target){'
23 if(f.hasClass('follow')){
23 if(f.hasClass('follow')){
24 f.removeClass('follow');
24 f.removeClass('follow');
25 f.addClass('following');
25 f.addClass('following');
26 f.attr('title', _TM['Stop following this repository']);
26 f.attr('title', _gettext('Stop following this repository'));
27 $(f).html(_TM['Unfollow']);
27 $(f).html(_gettext('Unfollow'));
28 if(f_cnt.length){
28 if(f_cnt.length){
29 var cnt = Number(f_cnt.html())+1;
29 var cnt = Number(f_cnt.html())+1;
30 f_cnt.html(cnt);
30 f_cnt.html(cnt);
@@ -33,8 +33,8 b' var onSuccessFollow = function(target){'
33 else{
33 else{
34 f.removeClass('following');
34 f.removeClass('following');
35 f.addClass('follow');
35 f.addClass('follow');
36 f.attr('title', _TM['Start following this repository']);
36 f.attr('title', _gettext('Start following this repository'));
37 $(f).html(_TM['Follow']);
37 $(f).html(_gettext('Follow'));
38 if(f_cnt.length){
38 if(f_cnt.length){
39 var cnt = Number(f_cnt.html())-1;
39 var cnt = Number(f_cnt.html())-1;
40 f_cnt.html(cnt);
40 f_cnt.html(cnt);
@@ -116,7 +116,7 b' var show_changeset_tooltip = function(){'
116 }
116 }
117 if(rid && !$(target).hasClass('tooltip')){
117 if(rid && !$(target).hasClass('tooltip')){
118 $(target).attr('id', ttid);
118 $(target).attr('id', ttid);
119 $(target).attr('title', _TM['loading ...']);
119 $(target).attr('title', _gettext('loading ...'));
120 TTIP.main.set_listeners(target);
120 TTIP.main.set_listeners(target);
121 TTIP.main.show_tip(e, target);
121 TTIP.main.show_tip(e, target);
122 var url = pyroutes.url('changeset_info', {"repo_name":repo_name, "revision": rid});
122 var url = pyroutes.url('changeset_info', {"repo_name":repo_name, "revision": rid});
@@ -101,7 +101,7 b''
101 elems.splice(elems.indexOf(plugin_id), 1);
101 elems.splice(elems.indexOf(plugin_id), 1);
102 auth_plugins_input.val(elems.join(','));
102 auth_plugins_input.val(elems.join(','));
103 $(cur_button).removeClass('btn-success');
103 $(cur_button).removeClass('btn-success');
104 cur_button.innerHTML = _TM['disabled'];
104 cur_button.innerHTML = _gettext('disabled');
105 }
105 }
106 else{
106 else{
107 if(elems.indexOf(plugin_id) == -1){
107 if(elems.indexOf(plugin_id) == -1){
@@ -109,7 +109,7 b''
109 }
109 }
110 auth_plugins_input.val(elems.join(','));
110 auth_plugins_input.val(elems.join(','));
111 $(cur_button).addClass('btn-success');
111 $(cur_button).addClass('btn-success');
112 cur_button.innerHTML = _TM['enabled'];
112 cur_button.innerHTML = _gettext('enabled');
113 }
113 }
114 });
114 });
115 </script>
115 </script>
@@ -42,8 +42,8 b''
42 var api = datatable.api();
42 var api = datatable.api();
43 var total = api.page.info().recordsDisplay;
43 var total = api.page.info().recordsDisplay;
44 var active = datatable.fnGetFilteredData();
44 var active = datatable.fnGetFilteredData();
45
45 var _text = _gettext("{0} active out of {1} users").format(active, total);
46 $('#user_count').text(_TM["{0} active out of {1} users"].format(active, total));
46 $('#user_count').text(_text);
47 };
47 };
48
48
49 // custom filter that filters by username OR email
49 // custom filter that filters by username OR email
@@ -228,9 +228,9 b''
228 open_new_pull_request.hide();
228 open_new_pull_request.hide();
229 } else {
229 } else {
230 if (selected_changes == 1) {
230 if (selected_changes == 1) {
231 open_new_pull_request.html(_TM['Open new pull request for selected commit']);
231 open_new_pull_request.html(_gettext('Open new pull request for selected commit'));
232 } else if (selected_changes == 0) {
232 } else if (selected_changes == 0) {
233 open_new_pull_request.html(_TM['Open new pull request']);
233 open_new_pull_request.html(_gettext('Open new pull request'));
234 }
234 }
235 open_new_pull_request.show();
235 open_new_pull_request.show();
236 }
236 }
@@ -244,8 +244,8 b''
244 'revision': revStart+'...'+revEnd});
244 'revision': revStart+'...'+revEnd});
245
245
246 var link = (revStart == revEnd)
246 var link = (revStart == revEnd)
247 ? _TM['Show selected commit __S']
247 ? _gettext('Show selected commit __S')
248 : _TM['Show selected commits __S ... __E'];
248 : _gettext('Show selected commits __S ... __E');
249
249
250 link = link.replace('__S', revStart.substr(0,6));
250 link = link.replace('__S', revStart.substr(0,6));
251 link = link.replace('__E', revEnd.substr(0,6));
251 link = link.replace('__E', revEnd.substr(0,6));
@@ -96,7 +96,7 b''
96 });
96 });
97 //push the typed in changeset
97 //push the typed in changeset
98 data.results.push({
98 data.results.push({
99 'text': _TM['specify commit'],
99 'text': _gettext('specify commit'),
100 'children': [{
100 'children': [{
101 'id': query.term,
101 'id': query.term,
102 'text': query.term,
102 'text': query.term,
@@ -836,7 +836,7 b''
836 };
836 };
837 var previewbox = $('#preview-box');
837 var previewbox = $('#preview-box');
838 previewbox.addClass('unloaded');
838 previewbox.addClass('unloaded');
839 previewbox.html(_TM['Loading ...']);
839 previewbox.html(_gettext('Loading ...'));
840 $('#edit-container').hide();
840 $('#edit-container').hide();
841 $('#preview-container').show();
841 $('#preview-container').show();
842
842
@@ -233,7 +233,7 b''
233 {'repo_name': templateContext.repo_name,
233 {'repo_name': templateContext.repo_name,
234 'revision': state.rev, 'f_path': path, 'limit': 6});
234 'revision': state.rev, 'f_path': path, 'limit': 6});
235 $('#file_history_container').show();
235 $('#file_history_container').show();
236 $('#file_history_container').html('<div class="file-history-inner">{0}</div>'.format(_TM['Loading ...']));
236 $('#file_history_container').html('<div class="file-history-inner">{0}</div>'.format(_gettext('Loading ...')));
237
237
238 $.pjax({
238 $.pjax({
239 url: url,
239 url: url,
@@ -212,7 +212,7 b''
212 var _text = myCodeMirror.getValue();
212 var _text = myCodeMirror.getValue();
213 var _renderer = possible_renderer || DEFAULT_RENDERER;
213 var _renderer = possible_renderer || DEFAULT_RENDERER;
214 var post_data = {'text': _text, 'renderer': _renderer, 'csrf_token': CSRF_TOKEN};
214 var post_data = {'text': _text, 'renderer': _renderer, 'csrf_token': CSRF_TOKEN};
215 $('#editor_preview').html(_TM['Loading ...']);
215 $('#editor_preview').html(_gettext('Loading ...'));
216 var url = pyroutes.url('changeset_comment_preview', {'repo_name': '${c.repo_name}'});
216 var url = pyroutes.url('changeset_comment_preview', {'repo_name': '${c.repo_name}'});
217
217
218 ajaxPOST(url, post_data, function(o){
218 ajaxPOST(url, post_data, function(o){
@@ -173,7 +173,7 b''
173 var _text = myCodeMirror.getValue();
173 var _text = myCodeMirror.getValue();
174 var _renderer = possible_renderer || DEFAULT_RENDERER;
174 var _renderer = possible_renderer || DEFAULT_RENDERER;
175 var post_data = {'text': _text, 'renderer': _renderer, 'csrf_token': CSRF_TOKEN};
175 var post_data = {'text': _text, 'renderer': _renderer, 'csrf_token': CSRF_TOKEN};
176 $('#editor_preview').html(_TM['Loading ...']);
176 $('#editor_preview').html(_gettext('Loading ...'));
177 var url = pyroutes.url('changeset_comment_preview', {'repo_name': '${c.repo_name}'});
177 var url = pyroutes.url('changeset_comment_preview', {'repo_name': '${c.repo_name}'});
178
178
179 ajaxPOST(url, post_data, function(o){
179 ajaxPOST(url, post_data, function(o){
@@ -546,7 +546,7 b''
546
546
547 $('#update_commits').on('click', function(e){
547 $('#update_commits').on('click', function(e){
548 var isDisabled = !$(e.currentTarget).attr('disabled');
548 var isDisabled = !$(e.currentTarget).attr('disabled');
549 $(e.currentTarget).text(_TM['Updating...']);
549 $(e.currentTarget).text(_gettext('Updating...'));
550 $(e.currentTarget).attr('disabled', 'disabled');
550 $(e.currentTarget).attr('disabled', 'disabled');
551 if(isDisabled){
551 if(isDisabled){
552 updateCommits("${c.repo_name}", "${c.pull_request.pull_request_id}");
552 updateCommits("${c.repo_name}", "${c.pull_request.pull_request_id}");
General Comments 0
You need to be logged in to leave comments. Login now