diff --git a/rhodecode/public/js/rhodecode/i18n/select2/translations.js b/rhodecode/public/js/rhodecode/i18n/select2/translations.js --- a/rhodecode/public/js/rhodecode/i18n/select2/translations.js +++ b/rhodecode/public/js/rhodecode/i18n/select2/translations.js @@ -1,33 +1,42 @@ // translate select2 components select2Locales = { formatLoadMore: function(pageNumber) { - return _TM["Loading more results..."]; + return _gettext("Loading more results..."); }, formatSearching: function() { - return _TM["Searching..."]; + return _gettext("Searching..."); }, formatNoMatches: function() { - return _TM["No matches found"]; + return _gettext("No matches found"); }, formatAjaxError: function(jqXHR, textStatus, errorThrown) { - return _TM["Loading failed"]; + return _gettext("Loading failed"); }, formatMatches: function(matches) { if (matches === 1) { - return _TM["One result is available, press enter to select it."]; + return _gettext("One result is available, press enter to select it."); } - return _TM["{0} results are available, use up and down arrow keys to navigate."].format(matches); + return _gettext("{0} results are available, use up and down arrow keys to navigate.").format(matches); }, formatInputTooShort: function(input, min) { var n = min - input.length; - return "Please enter {0} or more character".format(n) + (n === 1 ? "" : "s"); + if (n === 1) { + return _gettext("Please enter {0} or more character").format(n); + } + return _gettext("Please enter {0} or more characters").format(n); }, formatInputTooLong: function(input, max) { var n = input.length - max; - return "Please delete {0} character".format(n) + (n === 1 ? "" : "s"); + if (n === 1) { + return _gettext("Please delete {0} character").format(n); + } + return _gettext("Please delete {0} characters").format(n); }, formatSelectionTooBig: function(limit) { - return "You can only select {0} item".format(limit) + (limit === 1 ? "" : "s"); + if (limit === 1) { + return _gettext("You can only select {0} item").format(limit); + } + return _gettext("You can only select {0} items").format(limit); } }; diff --git a/rhodecode/public/js/src/plugins/jquery.autocomplete.js b/rhodecode/public/js/src/plugins/jquery.autocomplete.js --- a/rhodecode/public/js/src/plugins/jquery.autocomplete.js +++ b/rhodecode/public/js/src/plugins/jquery.autocomplete.js @@ -84,7 +84,7 @@ return typeof response === 'string' ? $.parseJSON(response) : response; }, showNoSuggestionNotice: false, - noSuggestionNotice: _TM['No results'], + noSuggestionNotice: _gettext('No results'), orientation: 'bottom', forceFixPosition: false, replaceOnArrowKey: true diff --git a/rhodecode/public/js/src/plugins/jquery.timeago-extension.js b/rhodecode/public/js/src/plugins/jquery.timeago-extension.js --- a/rhodecode/public/js/src/plugins/jquery.timeago-extension.js +++ b/rhodecode/public/js/src/plugins/jquery.timeago-extension.js @@ -10,21 +10,6 @@ var AgeModule = (function () { var show_suffix = show_suffix || true; var short_format = short_format || false; - // alias for backward compat - var _ = function(s) { - if (_TM.hasOwnProperty(s)) { - return _TM[s]; - } - return s - }; - - var ungettext = function (singular, plural, n) { - if (n === 1){ - return _(singular) - } - return _(plural) - }; - var _get_relative_delta = function(now, prevdate) { var duration = moment.duration(moment(now).diff(prevdate)); @@ -121,12 +106,12 @@ var AgeModule = (function () { } else { var fmt_funcs = { - 'year': function(d) {return ungettext('{0} year', '{0} years', d).format(d)}, - 'month': function(d) {return ungettext('{0} month', '{0} months', d).format(d)}, - 'day': function(d) {return ungettext('{0} day', '{0} days', d).format(d)}, - 'hour': function(d) {return ungettext('{0} hour', '{0} hours', d).format(d)}, - 'minute': function(d) {return ungettext('{0} min', '{0} min', d).format(d)}, - 'second': function(d) {return ungettext('{0} sec', '{0} sec', d).format(d)} + 'year': function(d) {return _ngettext('{0} year', '{0} years', d).format(d)}, + 'month': function(d) {return _ngettext('{0} month', '{0} months', d).format(d)}, + 'day': function(d) {return _ngettext('{0} day', '{0} days', d).format(d)}, + 'hour': function(d) {return _ngettext('{0} hour', '{0} hours', d).format(d)}, + 'minute': function(d) {return _ngettext('{0} min', '{0} min', d).format(d)}, + 'second': function(d) {return _ngettext('{0} sec', '{0} sec', d).format(d)} } } @@ -146,7 +131,7 @@ var AgeModule = (function () { var _val = fmt_funcs[part](value); if (future) { if (show_suffix) { - return _('in {0}').format(_val) + return _gettext('in {0}').format(_val) } else { return _val } @@ -154,7 +139,7 @@ var AgeModule = (function () { } else { if (show_suffix) { - return _('{0} ago').format(_val) + return _gettext('{0} ago').format(_val) } else { return _val } @@ -166,17 +151,17 @@ var AgeModule = (function () { if (short_format) { var datetime_tmpl = '{0}, {1}'; if (show_suffix) { - datetime_tmpl = _('{0}, {1} ago'); + datetime_tmpl = _gettext('{0}, {1} ago'); if (future) { - datetime_tmpl = _('in {0}, {1}'); + datetime_tmpl = _gettext('in {0}, {1}'); } } } else { - var datetime_tmpl = _('{0} and {1}'); + var datetime_tmpl = _gettext('{0} and {1}'); if (show_suffix) { - datetime_tmpl = _('{0} and {1} ago'); + datetime_tmpl = _gettext('{0} and {1} ago'); if (future) { - datetime_tmpl = _('in {0} and {1}') + datetime_tmpl = _gettext('in {0} and {1}') } } } @@ -186,7 +171,7 @@ var AgeModule = (function () { i += 1; } - return _('just now') + return _gettext('just now') }, createTimeComponent: function(dateTime, text) { diff --git a/rhodecode/public/js/src/rhodecode.js b/rhodecode/public/js/src/rhodecode.js --- a/rhodecode/public/js/src/rhodecode.js +++ b/rhodecode/public/js/src/rhodecode.js @@ -24,15 +24,6 @@ if (typeof console == "undefined" || typ console = { log: function() {} } } - -// alias for backward compat -var _tm = function(s) { - if (_TM.hasOwnProperty(s)) { - return _TM[s]; - } - return s -}; - // TODO: move the following function to submodules /** @@ -148,7 +139,7 @@ var showRepoStats = function(target, dat var td2 = document.createElement('td'); var trending_language = document.createElement('div'); - var nr_files = obj.count +" "+ (obj.count === 1 ? _tm('file'): _tm('files')); + var nr_files = obj.count +" "+ _ngettext('file', 'files', obj.count); trending_language.title = key + " " + nr_files; @@ -168,7 +159,7 @@ var showRepoStats = function(target, dat lnk = document.createElement('a'); lnk.href = '#'; - lnk.innerHTML = _tm('Show more'); + lnk.innerHTML = _ngettext('Show more'); lnk.id = 'code_stats_show_more'; td.appendChild(lnk); diff --git a/rhodecode/public/js/src/rhodecode/codemirror.js b/rhodecode/public/js/src/rhodecode/codemirror.js --- a/rhodecode/public/js/src/rhodecode/codemirror.js +++ b/rhodecode/public/js/src/rhodecode/codemirror.js @@ -366,7 +366,7 @@ var initCommentBoxCodeMirror = function( var actions = [ { text: "approve", - displayText: _TM['Set status to Approved'], + displayText: _gettext('Set status to Approved'), hint: function(CodeMirror, data, completion) { CodeMirror.replaceRange("", completion.from || data.from, completion.to || data.to, "complete"); @@ -384,7 +384,7 @@ var initCommentBoxCodeMirror = function( }, { text: "reject", - displayText: _TM['Set status to Rejected'], + displayText: _gettext('Set status to Rejected'), hint: function(CodeMirror, data, completion) { CodeMirror.replaceRange("", completion.from || data.from, completion.to || data.to, "complete"); diff --git a/rhodecode/public/js/src/rhodecode/comments.js b/rhodecode/public/js/src/rhodecode/comments.js --- a/rhodecode/public/js/src/rhodecode/comments.js +++ b/rhodecode/public/js/src/rhodecode/comments.js @@ -240,7 +240,7 @@ var deleteComment = function(comment_id) }; var createInlineAddButton = function(tr){ - var label = _TM['Add another comment']; + var label = _gettext('Add another comment'); var html_el = document.createElement('div'); $(html_el).addClass('add-comment'); html_el.innerHTML = '{0}'.format(label); @@ -458,7 +458,7 @@ var CommentForm = (function() { }; $(this.submitForm).find(this.statusChange).select2({ - placeholder: _TM['Status Review'], + placeholder: _gettext('Status Review'), formatResult: formatResult, formatSelection: formatSelection, containerCssClass: "drop-menu status_box_menu", @@ -472,7 +472,7 @@ var CommentForm = (function() { $(self.submitButton).prop('disabled', false); } //todo, fix this name - var placeholderText = _TM['Comment text will be set automatically based on currently selected status ({0}) ...'].format(status); + var placeholderText = _gettext('Comment text will be set automatically based on currently selected status ({0}) ...').format(status); self.cm.setOption('placeholder', placeholderText); }) }; @@ -586,7 +586,7 @@ var CommentForm = (function() { } $(this.submitButton).prop('disabled', submitState); if (submitEvent) { - $(this.submitButton).val(_TM['Submitting...']); + $(this.submitButton).val(_gettext('Submitting...')); } else { $(this.submitButton).val(this.submitButtonText); } @@ -636,7 +636,7 @@ var CommentForm = (function() { self.setActionButtonsDisabled(true); $(self.previewBoxSelector).addClass('unloaded'); - $(self.previewBoxSelector).html(_TM['Loading ...']); + $(self.previewBoxSelector).html(_gettext('Loading ...')); $(self.editContainer).hide(); $(self.previewContainer).show(); diff --git a/rhodecode/public/js/src/rhodecode/files.js b/rhodecode/public/js/src/rhodecode/files.js --- a/rhodecode/public/js/src/rhodecode/files.js +++ b/rhodecode/public/js/src/rhodecode/files.js @@ -147,9 +147,9 @@ var fileBrowserListeners = function(node if(results.length > limit){ var truncated_count = results.length - matches_max; if (truncated_count === 1) { - match.push('