From be707071496353a3b2e1fd2d8b2157fe41cd17ca Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Sun, 2 Nov 2008 22:30:39 +0000 Subject: [PATCH] move deluge-strings.js to gettext.js --- deluge/ui/webui/templates/ajax/gettext.js | 70 +++++++++++++++++++ deluge/ui/webui/templates/ajax/index.html | 2 +- .../ajax/render/js/deluge-strings.js | 68 ------------------ .../templates/ajax/static/js/deluge-add.js | 10 +-- .../ajax/static/js/deluge-details.js | 10 +-- .../templates/ajax/static/js/deluge-menus.js | 58 +++++++-------- 6 files changed, 110 insertions(+), 108 deletions(-) create mode 100644 deluge/ui/webui/templates/ajax/gettext.js delete mode 100644 deluge/ui/webui/templates/ajax/render/js/deluge-strings.js diff --git a/deluge/ui/webui/templates/ajax/gettext.js b/deluge/ui/webui/templates/ajax/gettext.js new file mode 100644 index 000000000..832c4b4a9 --- /dev/null +++ b/deluge/ui/webui/templates/ajax/gettext.js @@ -0,0 +1,70 @@ +/* + * Script: gettext.js + * A script file that is run through the template renderer in order for + * translated strings to be retrieved. + * + * Copyright: + * Damien Churchill (c) 2008 + */ + +GetText = { + maps: {}, + add: function(string, translation) { + this.maps[string] = translation; + }, + get: function(string) { + if (this.maps[string]) { + return this.maps[string]; + } else { + return string; + } + } +} + +// Torrent Menu Strings // +GetText.add('Pause', '$_('Pause')'); +GetText.add('Resume', '$_('Resume')'); +GetText.add('Options', '$_('Options')'); +GetText.add('D/L Speed Limit', '$_('D/L Speed Limit')'); +GetText.add('U/L Speed Limit', '$_('U/L Speed Limit')'); +GetText.add('Unlimited', '$_('Unlimited')'); +GetText.add('Connection Limit', '$_('Connection Limit')'); +GetText.add('Upload Slot Limit', '$_('Upload Slot Limit')'); +GetText.add('Auto Managed', '$_('Auto Managed')'); +GetText.add('Queue', '$_('Queue')'); +GetText.add('Top', '$_('Top')'); +GetText.add('Up', '$_('Up')'); +GetText.add('Down', '$_('Down')'); +GetText.add('Bottom', '$_('Bottom')'); +GetText.add('Update Tracker', '$_('Update Tracker')'); +GetText.add('Edit Trackers', '$_('Edit Trackers')'); +GetText.add('Remove Torrent', '$_('Remove Torrent')'); +GetText.add('From Session', '$_('From Session')'); +GetText.add('... and delete Torrent file', + '$_('... and delete Torrent file')'); +GetText.add('... and delete Downloaded files', + '$_('... and delete Downloaded files')'); +GetText.add('... and delete All files', + '$_('... and delete All files')'); +GetText.add('Force Recheck', '$_('Force Recheck')'); +GetText.add('Move Storage', '$_('Move Storage')'); + +// Add Torrents Window // +GetText.add('Add Torrents', '$_('Add Torrents')'); +GetText.add('Create Torrent', '$_('Create Torrent')'); +GetText.add('Torrents Window', '$_('Torrents Window')'); +GetText.add('From Url', '$_('From Url')'); +GetText.add('Ok', '$_('Ok')'); +GetText.add('Cancel', '$_('Cancel')'); + + +// Details // +GetText.add('Statistics', '$_('Statistics')'); +GetText.add('Details', '$_('Details')'); +GetText.add('Files', '$_('Files')'); +GetText.add('Peers', '$_('Peers')'); +GetText.add('Options', '$_('Options')'); + +function _(string) { + return GetText.get(string); +} diff --git a/deluge/ui/webui/templates/ajax/index.html b/deluge/ui/webui/templates/ajax/index.html index 6b0103bd5..63bbb577d 100644 --- a/deluge/ui/webui/templates/ajax/index.html +++ b/deluge/ui/webui/templates/ajax/index.html @@ -11,8 +11,8 @@ + - diff --git a/deluge/ui/webui/templates/ajax/render/js/deluge-strings.js b/deluge/ui/webui/templates/ajax/render/js/deluge-strings.js deleted file mode 100644 index 1d1d715bb..000000000 --- a/deluge/ui/webui/templates/ajax/render/js/deluge-strings.js +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Script: deluge-strings.js - * A script file that is run through the template renderer in order for - * translated strings to be retrieved. - * - * Copyright: - * Damien Churchill (c) 2008 - */ - -Deluge.Strings = { - maps: {}, - add: function(string, translation) { - this.maps[string] = translation; - }, - get: function(string) { - if (this.maps[string]) { - return this.maps[string]; - } else { - return string; - } - } -} - -// Torrent Menu Strings // -Deluge.Strings.add('Pause', '$_('Pause')'); -Deluge.Strings.add('Resume', '$_('Resume')'); -Deluge.Strings.add('Options', '$_('Options')'); -Deluge.Strings.add('D/L Speed Limit', '$_('D/L Speed Limit')'); -Deluge.Strings.add('U/L Speed Limit', '$_('U/L Speed Limit')'); -Deluge.Strings.add('Unlimited', '$_('Unlimited')'); -Deluge.Strings.add('Connection Limit', '$_('Connection Limit')'); -Deluge.Strings.add('Upload Slot Limit', '$_('Upload Slot Limit')'); -Deluge.Strings.add('Auto Managed', '$_('Auto Managed')'); -Deluge.Strings.add('Queue', '$_('Queue')'); -Deluge.Strings.add('Top', '$_('Top')'); -Deluge.Strings.add('Up', '$_('Up')'); -Deluge.Strings.add('Down', '$_('Down')'); -Deluge.Strings.add('Bottom', '$_('Bottom')'); -Deluge.Strings.add('Update Tracker', '$_('Update Tracker')'); -Deluge.Strings.add('Edit Trackers', '$_('Edit Trackers')'); -Deluge.Strings.add('Remove Torrent', '$_('Remove Torrent')'); -Deluge.Strings.add('From Session', '$_('From Session')'); -Deluge.Strings.add('... and delete Torrent file', - '$_('... and delete Torrent file')'); -Deluge.Strings.add('... and delete Downloaded files', - '$_('... and delete Downloaded files')'); -Deluge.Strings.add('... and delete All files', - '$_('... and delete All files')'); -Deluge.Strings.add('Force Recheck', '$_('Force Recheck')'); -Deluge.Strings.add('Move Storage', '$_('Move Storage')'); - -// Add Torrents Window // -Deluge.Strings.add('Add Torrents', '$_('Add Torrents')'); -Deluge.Strings.add('Create Torrent', '$_('Create Torrent')'); -Deluge.Strings.add('Torrents Window', '$_('Torrents Window')'); -Deluge.Strings.add('From Url', '$_('From Url')'); -Deluge.Strings.add('Ok', '$_('Ok')'); -Deluge.Strings.add('Cancel', '$_('Cancel')'); - - -// Details // -Deluge.Strings.add('Statistics', '$_('Statistics')'); -Deluge.Strings.add('Details', '$_('Details')'); -Deluge.Strings.add('Files', '$_('Files')'); -Deluge.Strings.add('Peers', '$_('Peers')'); -Deluge.Strings.add('Options', '$_('Options')'); - -_ = Deluge.Strings.get; diff --git a/deluge/ui/webui/templates/ajax/static/js/deluge-add.js b/deluge/ui/webui/templates/ajax/static/js/deluge-add.js index 4b8dadd26..655c50640 100644 --- a/deluge/ui/webui/templates/ajax/static/js/deluge-add.js +++ b/deluge/ui/webui/templates/ajax/static/js/deluge-add.js @@ -11,7 +11,7 @@ Deluge.Widgets.AddWindow = new Class({ options: { width: 550, height: 500, - title: Deluge.Strings.get('Add Torrents'), + title: _('Add Torrents'), url: '/template/render/html/window_add_torrent.html' }, @@ -93,7 +93,7 @@ Deluge.Widgets.AddTorrent.Url = new Class({ options: { width: 300, height: 100, - title: Deluge.Strings.get('From Url') + title: _('From Url') }, initialize: function() { @@ -110,9 +110,9 @@ Deluge.Widgets.AddTorrent.Url = new Class({ type: 'text' }); this.okButton = new Element('button'); - this.okButton.set('text', Deluge.Strings.get('Ok')); + this.okButton.set('text', _('Ok')); this.cancelButton = new Element('button'); - this.cancelButton.set('text', Deluge.Strings.get('Cancel')); + this.cancelButton.set('text', _('Cancel')); this.form.grab(new Element('label').set('text', 'Url').addClass('fluid')); this.form.grab(this.urlInput).grab(new Element('br')); this.form.grab(this.okButton).grab(this.cancelButton); @@ -182,7 +182,7 @@ Deluge.Widgets.CreateTorrent = new Class({ options: { width: 400, height: 400, - title: Deluge.Strings.get('Create Torrent'), + title: _('Create Torrent'), url: '/template/render/html/window_create_torrent.html' }, diff --git a/deluge/ui/webui/templates/ajax/static/js/deluge-details.js b/deluge/ui/webui/templates/ajax/static/js/deluge-details.js index 98c23989c..eeeb51996 100644 --- a/deluge/ui/webui/templates/ajax/static/js/deluge-details.js +++ b/deluge/ui/webui/templates/ajax/static/js/deluge-details.js @@ -92,7 +92,7 @@ Deluge.Widgets.StatisticsPage = new Class({ }, initialize: function() { - this.parent(Deluge.Strings.get('Statistics')); + this.parent(_('Statistics')); this.addEvent('loaded', this.onLoad.bindWithEvent(this)); }, @@ -155,7 +155,7 @@ Deluge.Widgets.DetailsPage = new Class({ }, initialize: function() { - this.parent(Deluge.Strings.get('Details')); + this.parent(_('Details')); }, clear: function() { @@ -278,7 +278,7 @@ Deluge.Widgets.FilesPage = new Class({ }, initialize: function(el) { - this.parent(Deluge.Strings.get('Files')); + this.parent(_('Files')); this.torrentId = -1; this.addEvent('loaded', this.loaded.bindWithEvent(this)); this.addEvent('resize', this.resized.bindWithEvent(this)); @@ -333,7 +333,7 @@ Deluge.Widgets.PeersPage = new Class({ }, initialize: function(el) { - this.parent(Deluge.Strings.get('Peers')); + this.parent(_('Peers')); this.addEvent('resize', this.resized.bindWithEvent(this)); this.addEvent('loaded', this.loaded.bindWithEvent(this)); }, @@ -422,7 +422,7 @@ Deluge.Widgets.OptionsPage = new Class({ initialize: function() { if (!this.element) - this.parent(Deluge.Strings.get('Options')); + this.parent(_('Options')); this.addEvent('loaded', function(event) { this.loaded(event); }.bindWithEvent(this)); diff --git a/deluge/ui/webui/templates/ajax/static/js/deluge-menus.js b/deluge/ui/webui/templates/ajax/static/js/deluge-menus.js index 3df411695..a84e0887d 100644 --- a/deluge/ui/webui/templates/ajax/static/js/deluge-menus.js +++ b/deluge/ui/webui/templates/ajax/static/js/deluge-menus.js @@ -11,24 +11,24 @@ Deluge.Menus = { { type:'text', action:'pause', - text: Deluge.Strings.get('Pause'), + text: _('Pause'), icon:'/static/images/tango/pause.png' }, { type: 'text', action: 'resume', - text: Deluge.Strings.get('Resume'), + text: _('Resume'), icon: '/static/images/tango/start.png' }, { type: 'seperator' }, { type:'submenu', - text: Deluge.Strings.get('Options'), + text: _('Options'), icon:'/static/images/tango/preferences-system.png', items: [ { type: 'submenu', - text: Deluge.Strings.get('D/L Speed Limit'), + text: _('D/L Speed Limit'), icon: '/pixmaps/downloading16.png', items: [ { @@ -65,13 +65,13 @@ Deluge.Menus = { type: 'text', action: 'max_download_speed', value: -1, - text: Deluge.Strings.get('Unlimited') + text: _('Unlimited') } ] }, { type: 'submenu', - text: Deluge.Strings.get('U/L Speed Limit'), + text: _('U/L Speed Limit'), icon: '/pixmaps/seeding16.png', items: [ { @@ -108,13 +108,13 @@ Deluge.Menus = { type: 'text', action: 'max_upload_speed', value: -1, - text: Deluge.Strings.get('Unlimited') + text: _('Unlimited') } ] }, { type: 'submenu', - text: Deluge.Strings.get('Connection Limit'), + text: _('Connection Limit'), icon: '/static/images/tango/connections.png', items: [ { @@ -151,13 +151,13 @@ Deluge.Menus = { type: 'text', action: 'max_connections', value: -1, - text: Deluge.Strings.get('Unlimited') + text: _('Unlimited') } ] }, { type: 'submenu', - text: Deluge.Strings.get('Upload Slot Limit'), + text: _('Upload Slot Limit'), icon: '/template/static/icons/16/view-sort-ascending.png', items: [ { @@ -194,45 +194,45 @@ Deluge.Menus = { type: 'text', action: 'max_upload_slots', value: -1, - text: Deluge.Strings.get('Unlimited')} + text: _('Unlimited')} ] }, { type: 'toggle', action: 'auto_managed', value: false, - text: Deluge.Strings.get('Auto Managed') + text: _('Auto Managed') } ] }, {type:'seperator'}, { type: 'submenu', - text: Deluge.Strings.get('Queue'), + text: _('Queue'), icon: '/template/static/icons/16/view-sort-descending.png', items: [ { type: 'text', action: 'top', - text: Deluge.Strings.get('Top'), + text: _('Top'), icon: '/static/images/tango/go-top.png' }, { type: 'text', action: 'up', - text: Deluge.Strings.get('Up'), + text: _('Up'), icon: '/static/images/tango/queue-up.png' }, { type: 'text', action: 'down', - text: Deluge.Strings.get('Down'), + text: _('Down'), icon: '/static/images/tango/queue-down.png' }, { type: 'text', action: 'bottom', - text: Deluge.Strings.get('Bottom'), + text: _('Bottom'), icon: '/static/images/tango/go-bottom.png' } ] @@ -241,13 +241,13 @@ Deluge.Menus = { { type: 'text', action: 'update_tracker', - text: Deluge.Strings.get('Update Tracker'), + text: _('Update Tracker'), icon: '/template/static/icons/16/view-refresh.png' }, { type: 'text', action: 'edit_trackers', - text: Deluge.Strings.get('Edit Trackers'), + text: _('Edit Trackers'), icon: '/template/static/icons/16/gtk-edit.png' }, {type:'seperator'}, @@ -255,32 +255,32 @@ Deluge.Menus = { type: 'submenu', action: 'remove', value: 0, - text: Deluge.Strings.get('Remove Torrent'), + text: _('Remove Torrent'), icon: '/static/images/tango/list-remove.png', items: [ { type: 'text', action: 'remove', value: 0, - text: Deluge.Strings.get('From Session') + text: _('From Session') }, { type: 'text', action: 'remove', value: 1, - text: Deluge.Strings.get('... and delete Torrent file') + text: _('... and delete Torrent file') }, { type: 'text', action: 'remove', value: 2, - text: Deluge.Strings.get('... and delete Downloaded files') + text: _('... and delete Downloaded files') }, { type: 'text', action: 'remove', value: 3, - text: Deluge.Strings.get('... and delete All files') + text: _('... and delete All files') } ] }, @@ -288,13 +288,13 @@ Deluge.Menus = { { type: 'text', action: 'force_recheck', - text: Deluge.Strings.get('Force Recheck'), + text: _('Force Recheck'), icon: '/static/images/tango/edit-redo.png' }, { type: 'text', action: 'move_storage', - text: Deluge.Strings.get('Move Storage'), + text: _('Move Storage'), icon: '/static/images/tango/move.png' } ], @@ -334,7 +334,7 @@ Deluge.Menus = { type: 'text', action: 'max_connections', value: -1, - text: Deluge.Strings.get('Unlimited') + text: _('Unlimited') } ], @@ -373,7 +373,7 @@ Deluge.Menus = { type: 'text', action: 'max_download_speed', value: -1, - text: Deluge.Strings.get('Unlimited') + text: _('Unlimited') } ], @@ -412,7 +412,7 @@ Deluge.Menus = { type: 'text', action: 'max_upload_speed', value: -1, - text: Deluge.Strings.get('Unlimited') + text: _('Unlimited') } ] };