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.
This commit is contained in:
Calum Lind 2015-08-09 16:29:03 +01:00
parent 576df1f6e3
commit a391bbd67b
9 changed files with 33 additions and 35 deletions

View File

@ -39,12 +39,12 @@
*/ */
Deluge.Formatters = { Deluge.Formatters = {
/** /**
* Formats a date string in the locale's date representation based on the * Formats a date string in the date representation of the current locale,
* systems timezone. * based on the systems timezone.
* *
* @param {Number} timestamp time in seconds since the Epoch * @param {Number} timestamp time in seconds since the Epoch.
* @return {String} a string in the locale's date representation or "" * @return {String} a string in the date representation of the current locale
* if seconds < 0 * or "" if seconds < 0.
*/ */
date: function(timestamp) { date: function(timestamp) {
function zeroPad(num, count) { function zeroPad(num, count) {

View File

@ -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 * Lets the option manager know when a field is focused so if a value changing
* changing operation is performed it won't change the value of the * operation is performed it will not change the value of the field.
* field.
*/ */
onFieldFocus: function(field, event) { onFieldFocus: function(field, event) {
this.focused = field; 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 we don't have a bind there's nothing to do.
if (Ext.isEmpty(this.binds[option])) return; if (Ext.isEmpty(this.binds[option])) return;
Ext.each(this.binds[option], function(bind) { Ext.each(this.binds[option], function(bind) {
// The field is currently focused so we don't want to // The field is currently focused so we do not want to change it.
// change it.
if (bind == this.focused) return; if (bind == this.focused) return;
// Set the form field to the new value. // Set the form field to the new value.
bind.setValue(newValue); bind.setValue(newValue);

View File

@ -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) { Ext.each(Ext.keys(this.panels), function(filter) {
if (Ext.keys(filters).indexOf(filter) == -1) { if (Ext.keys(filters).indexOf(filter) == -1) {
// We need to remove the panel // We need to remove the panel

View File

@ -1,6 +1,6 @@
/*! /*!
* Deluge.StatusbarMenu.js * Deluge.StatusbarMenu.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -37,7 +37,7 @@ Ext.ns('Deluge');
* @extends Ext.menu.Menu * @extends Ext.menu.Menu
*/ */
Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, { Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
initComponent: function() { initComponent: function() {
Deluge.StatusbarMenu.superclass.initComponent.call(this); Deluge.StatusbarMenu.superclass.initComponent.call(this);
this.otherWin = new Deluge.OtherLimitWindow(this.initialConfig.otherWin || {}); this.otherWin = new Deluge.OtherLimitWindow(this.initialConfig.otherWin || {});
@ -51,7 +51,7 @@ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
} }
}, this); }, this);
}, },
setValue: function(value) { setValue: function(value) {
var beenSet = false; var beenSet = false;
// set the new value // set the new value
@ -67,12 +67,12 @@ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
beenSet = true; beenSet = true;
} else { } else {
item.setChecked(false); item.setChecked(false);
} }
item.resumeEvents(); item.resumeEvents();
} }
if (item.value == 'other') other = item; if (item.value == 'other') other = item;
}); });
if (beenSet) return; if (beenSet) return;
@ -82,7 +82,7 @@ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
}, },
onLimitChanged: function(item, checked) { 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 = {} var config = {}
config[item.group] = item.value config[item.group] = item.value
deluge.client.core.set_config(config, { deluge.client.core.set_config(config, {

View File

@ -1,6 +1,6 @@
/*! /*!
* Deluge.details.DetailsPanel.js * Deluge.details.DetailsPanel.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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.PeersTab());
this.add(new Deluge.details.OptionsTab()); this.add(new Deluge.details.OptionsTab());
}, },
clear: function() { clear: function() {
this.items.each(function(panel) { this.items.each(function(panel) {
if (panel.clear) { if (panel.clear) {
@ -56,42 +56,41 @@ Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, {
} }
}); });
}, },
update: function(tab) { update: function(tab) {
var torrent = deluge.torrents.getSelected(); var torrent = deluge.torrents.getSelected();
if (!torrent) { if (!torrent) {
this.clear(); this.clear();
return; return;
} }
this.items.each(function(tab) { this.items.each(function(tab) {
if (tab.disabled) tab.enable(); if (tab.disabled) tab.enable();
}); });
tab = tab || this.getActiveTab(); tab = tab || this.getActiveTab();
if (tab.update) tab.update(torrent.id); if (tab.update) tab.update(torrent.id);
}, },
/* Event Handlers */ /* Event Handlers */
// We need to add the events in onRender since Deluge.Torrents hasn't // We need to add the events in onRender since Deluge.Torrents has not been created yet.
// been created yet.
onRender: function(ct, position) { onRender: function(ct, position) {
Deluge.details.DetailsPanel.superclass.onRender.call(this, ct, position); Deluge.details.DetailsPanel.superclass.onRender.call(this, ct, position);
deluge.events.on('disconnect', this.clear, this); deluge.events.on('disconnect', this.clear, this);
deluge.torrents.on('rowclick', this.onTorrentsClick, this); deluge.torrents.on('rowclick', this.onTorrentsClick, this);
this.on('tabchange', this.onTabChange, this); this.on('tabchange', this.onTabChange, this);
deluge.torrents.getSelectionModel().on('selectionchange', function(selModel) { deluge.torrents.getSelectionModel().on('selectionchange', function(selModel) {
if (!selModel.hasSelection()) this.clear(); if (!selModel.hasSelection()) this.clear();
}, this); }, this);
}, },
onTabChange: function(panel, tab) { onTabChange: function(panel, tab) {
this.update(tab); this.update(tab);
}, },
onTorrentsClick: function(grid, rowIndex, e) { onTorrentsClick: function(grid, rowIndex, e) {
this.update(); this.update();
} }

View File

@ -106,7 +106,7 @@ Deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
}; };
for (var field in this.fields) { 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; if (data[field] == this.oldData[field]) continue;
this.fields[field].dom.innerHTML = Ext.escapeHTML(data[field]); this.fields[field].dom.innerHTML = Ext.escapeHTML(data[field]);
} }

View File

@ -375,7 +375,7 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
update: function(torrentId) { update: function(torrentId) {
if (this.torrentId && !torrentId) this.clear(); // we want to clear the pane if we get a null torrent torrentIds 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) { if (this.torrentId != torrentId) {
this.torrentId = torrentId; this.torrentId = torrentId;

View File

@ -150,7 +150,7 @@
}, this); }, this);
store.add(newPeers); 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) { store.each(function(record) {
if (!addresses[record.id]) { if (!addresses[record.id]) {
store.remove(record); store.remove(record);

View File

@ -75,8 +75,9 @@ with open(infiles_list, "wb") as f:
f.write(line + "\n") f.write(line + "\n")
# Force xgettext language to parse javascript and update pot file # 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"]) output = call(xgettext_cmd + ["--language=Python", "-j"])
print "====== Javascript 'unterminated string' warnings can be ignored ======"
# Replace YEAR and PACKAGE in the copyright message # Replace YEAR and PACKAGE in the copyright message
with open(pot_filepath, "r") as f: with open(pot_filepath, "r") as f: