From a391bbd67bcfb2f8be9b726753f047009b52d244 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sun, 9 Aug 2015 16:29:03 +0100 Subject: [PATCH] Workaround for js files generating warnings with generate_pot script With xgettext set to python it will parse the comments in javascript files, so single apostrophes or quotes are flagged as 'warning: untermined string'. This change just rewrites js comments to not use apostrophes. --- deluge/ui/web/js/deluge-all/Formatters.js | 10 ++++---- deluge/ui/web/js/deluge-all/OptionsManager.js | 8 +++--- deluge/ui/web/js/deluge-all/Sidebar.js | 2 +- deluge/ui/web/js/deluge-all/StatusbarMenu.js | 14 +++++------ .../web/js/deluge-all/details/DetailsPanel.js | 25 +++++++++---------- .../web/js/deluge-all/details/DetailsTab.js | 2 +- .../web/js/deluge-all/details/OptionsTab.js | 2 +- .../ui/web/js/deluge-all/details/PeersTab.js | 2 +- generate_pot.py | 3 ++- 9 files changed, 33 insertions(+), 35 deletions(-) diff --git a/deluge/ui/web/js/deluge-all/Formatters.js b/deluge/ui/web/js/deluge-all/Formatters.js index f7b9fcdc5..36b168ae3 100644 --- a/deluge/ui/web/js/deluge-all/Formatters.js +++ b/deluge/ui/web/js/deluge-all/Formatters.js @@ -39,12 +39,12 @@ */ Deluge.Formatters = { /** - * Formats a date string in the locale's date representation based on the - * systems timezone. + * Formats a date string in the date representation of the current locale, + * based on the systems timezone. * - * @param {Number} timestamp time in seconds since the Epoch - * @return {String} a string in the locale's date representation or "" - * if seconds < 0 + * @param {Number} timestamp time in seconds since the Epoch. + * @return {String} a string in the date representation of the current locale + * or "" if seconds < 0. */ date: function(timestamp) { function zeroPad(num, count) { diff --git a/deluge/ui/web/js/deluge-all/OptionsManager.js b/deluge/ui/web/js/deluge-all/OptionsManager.js index 2dde514f4..7d48aaa71 100644 --- a/deluge/ui/web/js/deluge-all/OptionsManager.js +++ b/deluge/ui/web/js/deluge-all/OptionsManager.js @@ -267,9 +267,8 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { }, /** - * Lets the option manager know when a field is focused so if a value - * changing operation is performed it won't change the value of the - * field. + * Lets the option manager know when a field is focused so if a value changing + * operation is performed it will not change the value of the field. */ onFieldFocus: function(field, event) { this.focused = field; @@ -279,8 +278,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { // If we don't have a bind there's nothing to do. if (Ext.isEmpty(this.binds[option])) return; Ext.each(this.binds[option], function(bind) { - // The field is currently focused so we don't want to - // change it. + // The field is currently focused so we do not want to change it. if (bind == this.focused) return; // Set the form field to the new value. bind.setValue(newValue); diff --git a/deluge/ui/web/js/deluge-all/Sidebar.js b/deluge/ui/web/js/deluge-all/Sidebar.js index 4f120ec1b..c5f3e5139 100644 --- a/deluge/ui/web/js/deluge-all/Sidebar.js +++ b/deluge/ui/web/js/deluge-all/Sidebar.js @@ -149,7 +149,7 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, { } } - // Perform a cleanup of fitlers that aren't enabled any more + // Perform a cleanup of fitlers that are not enabled any more. Ext.each(Ext.keys(this.panels), function(filter) { if (Ext.keys(filters).indexOf(filter) == -1) { // We need to remove the panel diff --git a/deluge/ui/web/js/deluge-all/StatusbarMenu.js b/deluge/ui/web/js/deluge-all/StatusbarMenu.js index 939318ade..054ae5333 100644 --- a/deluge/ui/web/js/deluge-all/StatusbarMenu.js +++ b/deluge/ui/web/js/deluge-all/StatusbarMenu.js @@ -1,6 +1,6 @@ /*! * Deluge.StatusbarMenu.js - * + * * Copyright (c) Damien Churchill 2009-2010 * * This program is free software; you can redistribute it and/or modify @@ -37,7 +37,7 @@ Ext.ns('Deluge'); * @extends Ext.menu.Menu */ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, { - + initComponent: function() { Deluge.StatusbarMenu.superclass.initComponent.call(this); this.otherWin = new Deluge.OtherLimitWindow(this.initialConfig.otherWin || {}); @@ -51,7 +51,7 @@ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, { } }, this); }, - + setValue: function(value) { var beenSet = false; // set the new value @@ -67,12 +67,12 @@ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, { beenSet = true; } else { item.setChecked(false); - } + } item.resumeEvents(); - } + } if (item.value == 'other') other = item; - }); + }); if (beenSet) return; @@ -82,7 +82,7 @@ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, { }, onLimitChanged: function(item, checked) { - if (!checked || item.value == 'other') return; // we don't care about unchecks or other + if (!checked || item.value == 'other') return; // We do not care about unchecked or other. var config = {} config[item.group] = item.value deluge.client.core.set_config(config, { diff --git a/deluge/ui/web/js/deluge-all/details/DetailsPanel.js b/deluge/ui/web/js/deluge-all/details/DetailsPanel.js index 629278329..134c0d7b0 100644 --- a/deluge/ui/web/js/deluge-all/details/DetailsPanel.js +++ b/deluge/ui/web/js/deluge-all/details/DetailsPanel.js @@ -1,6 +1,6 @@ /*! * Deluge.details.DetailsPanel.js - * + * * Copyright (c) Damien Churchill 2009-2010 * * This program is free software; you can redistribute it and/or modify @@ -47,7 +47,7 @@ Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, { this.add(new Deluge.details.PeersTab()); this.add(new Deluge.details.OptionsTab()); }, - + clear: function() { this.items.each(function(panel) { if (panel.clear) { @@ -56,42 +56,41 @@ Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, { } }); }, - - + + update: function(tab) { var torrent = deluge.torrents.getSelected(); if (!torrent) { this.clear(); return; } - + this.items.each(function(tab) { if (tab.disabled) tab.enable(); }); - + tab = tab || this.getActiveTab(); if (tab.update) tab.update(torrent.id); }, - + /* Event Handlers */ - - // We need to add the events in onRender since Deluge.Torrents hasn't - // been created yet. + + // We need to add the events in onRender since Deluge.Torrents has not been created yet. onRender: function(ct, position) { Deluge.details.DetailsPanel.superclass.onRender.call(this, ct, position); deluge.events.on('disconnect', this.clear, this); deluge.torrents.on('rowclick', this.onTorrentsClick, this); this.on('tabchange', this.onTabChange, this); - + deluge.torrents.getSelectionModel().on('selectionchange', function(selModel) { if (!selModel.hasSelection()) this.clear(); }, this); }, - + onTabChange: function(panel, tab) { this.update(tab); }, - + onTorrentsClick: function(grid, rowIndex, e) { this.update(); } diff --git a/deluge/ui/web/js/deluge-all/details/DetailsTab.js b/deluge/ui/web/js/deluge-all/details/DetailsTab.js index 3cd5b2382..2d78b88c9 100644 --- a/deluge/ui/web/js/deluge-all/details/DetailsTab.js +++ b/deluge/ui/web/js/deluge-all/details/DetailsTab.js @@ -106,7 +106,7 @@ Deluge.details.DetailsTab = Ext.extend(Ext.Panel, { }; for (var field in this.fields) { - if (!Ext.isDefined(data[field])) continue; // this is a field we aren't responsible for. + if (!Ext.isDefined(data[field])) continue; // This is a field we are not responsible for. if (data[field] == this.oldData[field]) continue; this.fields[field].dom.innerHTML = Ext.escapeHTML(data[field]); } diff --git a/deluge/ui/web/js/deluge-all/details/OptionsTab.js b/deluge/ui/web/js/deluge-all/details/OptionsTab.js index 4a6294f80..cc273605d 100644 --- a/deluge/ui/web/js/deluge-all/details/OptionsTab.js +++ b/deluge/ui/web/js/deluge-all/details/OptionsTab.js @@ -375,7 +375,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, { update: function(torrentId) { if (this.torrentId && !torrentId) this.clear(); // we want to clear the pane if we get a null torrent torrentIds - if (!torrentId) return; // we don't care about null torrentIds + if (!torrentId) return; // We do not care about null torrentIds. if (this.torrentId != torrentId) { this.torrentId = torrentId; diff --git a/deluge/ui/web/js/deluge-all/details/PeersTab.js b/deluge/ui/web/js/deluge-all/details/PeersTab.js index c5a1dee0c..6ac742337 100644 --- a/deluge/ui/web/js/deluge-all/details/PeersTab.js +++ b/deluge/ui/web/js/deluge-all/details/PeersTab.js @@ -150,7 +150,7 @@ }, this); store.add(newPeers); - // Remove any peers that shouldn't be left in the store + // Remove any peers that should not be left in the store. store.each(function(record) { if (!addresses[record.id]) { store.remove(record); diff --git a/generate_pot.py b/generate_pot.py index 5d3b24c62..0de2e636e 100755 --- a/generate_pot.py +++ b/generate_pot.py @@ -75,8 +75,9 @@ with open(infiles_list, "wb") as f: f.write(line + "\n") # Force xgettext language to parse javascript and update pot file +# Note: For javascript files xgettext will parse comments, so single apostrophes or quotes are +# flagged as a 'warning: untermined string'. Either ignore warning or edit javascript comment. output = call(xgettext_cmd + ["--language=Python", "-j"]) -print "====== Javascript 'unterminated string' warnings can be ignored ======" # Replace YEAR and PACKAGE in the copyright message with open(pot_filepath, "r") as f: