[WebUI] Handle missing gettext.js file

Removed the creation code of `gettext.js` and now it will just mock
the `_` function by being the identity function.
This commit is contained in:
DjLegolas 2018-07-13 21:45:44 +03:00 committed by Calum Lind
parent 8bfa2cacbb
commit b2e1f850d8
2 changed files with 21 additions and 319 deletions

View File

@ -1,318 +0,0 @@
GetText={maps:{},add:function(string,translation){this.maps[string]=translation},get:function(string){if (this.maps[string]){string=this.maps[string]} return string}};function _(string){return GetText.get(string)}GetText.add('10 KiB/s','${escape(_("10 KiB/s"))}')
GetText.add('30 KiB/s','${escape(_("30 KiB/s"))}')
GetText.add('300 KiB/s','${escape(_("300 KiB/s"))}')
GetText.add('5 KiB/s','${escape(_("5 KiB/s"))}')
GetText.add('80 KiB/s','${escape(_("80 KiB/s"))}')
GetText.add('<b>IP</b> {0}','${escape(_("<b>IP</b> {0}"))}')
GetText.add('Active','${escape(_("Active"))}')
GetText.add('Active Torrents','${escape(_("Active Torrents"))}')
GetText.add('Add','${escape(_("Add"))}')
GetText.add('Add Connection','${escape(_("Add Connection"))}')
GetText.add('Add In Paused State','${escape(_("Add In Paused State"))}')
GetText.add('Add Torrents','${escape(_("Add Torrents"))}')
GetText.add('Add Tracker','${escape(_("Add Tracker"))}')
GetText.add('Add from Url','${escape(_("Add from Url"))}')
GetText.add('Add torrents in Paused state','${escape(_("Add torrents in Paused state"))}')
GetText.add('Added','${escape(_("Added"))}')
GetText.add('Address','${escape(_("Address"))}')
GetText.add('All','${escape(_("All"))}')
GetText.add('Allocating','${escape(_("Allocating"))}')
GetText.add('Allow Remote Connections','${escape(_("Allow Remote Connections"))}')
GetText.add('Allow the use of multiple filters at once','${escape(_("Allow the use of multiple filters at once"))}')
GetText.add('Announce OK','${escape(_("Announce OK"))}')
GetText.add('Announce Sent','${escape(_("Announce Sent"))}')
GetText.add('Apply','${escape(_("Apply"))}')
GetText.add('Author Email:','${escape(_("Author Email:"))}')
GetText.add('Author:','${escape(_("Author:"))}')
GetText.add('Auto Managed','${escape(_("Auto Managed"))}')
GetText.add('Avail','${escape(_("Avail"))}')
GetText.add('Back','${escape(_("Back"))}')
GetText.add('Bandwidth','${escape(_("Bandwidth"))}')
GetText.add('Be alerted about new releases','${escape(_("Be alerted about new releases"))}')
GetText.add('Bottom','${escape(_("Bottom"))}')
GetText.add('Browse','${escape(_("Browse"))}')
GetText.add('Browse...','${escape(_("Browse..."))}')
GetText.add('Cache','${escape(_("Cache"))}')
GetText.add('Cache Expiry (seconds):','${escape(_("Cache Expiry (seconds):"))}')
GetText.add('Cache Size (16 KiB Blocks):','${escape(_("Cache Size (16 KiB Blocks):"))}')
GetText.add('Cancel','${escape(_("Cancel"))}')
GetText.add('Certificate:','${escape(_("Certificate:"))}')
GetText.add('Change Default Password','${escape(_("Change Default Password"))}')
GetText.add('Change Successful','${escape(_("Change Successful"))}')
GetText.add('Checking','${escape(_("Checking"))}')
GetText.add('Client','${escape(_("Client"))}')
GetText.add('Close','${escape(_("Close"))}')
GetText.add('Comment:','${escape(_("Comment:"))}')
GetText.add('Complete Seen','${escape(_("Complete Seen"))}')
GetText.add('Completed','${escape(_("Completed"))}')
GetText.add('Confirm:','${escape(_("Confirm:"))}')
GetText.add('Connect','${escape(_("Connect"))}')
GetText.add('Connected','${escape(_("Connected"))}')
GetText.add('Connection Limit','${escape(_("Connection Limit"))}')
GetText.add('Connection Manager','${escape(_("Connection Manager"))}')
GetText.add('Connection restored','${escape(_("Connection restored"))}')
GetText.add('Connections','${escape(_("Connections"))}')
GetText.add('Cookies','${escape(_("Cookies"))}')
GetText.add('Copy of .torrent files to:','${escape(_("Copy of .torrent files to:"))}')
GetText.add('Create','${escape(_("Create"))}')
GetText.add('Created By:','${escape(_("Created By:"))}')
GetText.add('D/L Speed Limit','${escape(_("D/L Speed Limit"))}')
GetText.add('DHT','${escape(_("DHT"))}')
GetText.add('DHT Nodes','${escape(_("DHT Nodes"))}')
GetText.add('Daemon','${escape(_("Daemon"))}')
GetText.add('Daemon port:','${escape(_("Daemon port:"))}')
GetText.add('Deluge','${escape(_("Deluge"))}')
GetText.add('Details','${escape(_("Details"))}')
GetText.add('Details:','${escape(_("Details:"))}')
GetText.add('Disabled','${escape(_("Disabled"))}')
GetText.add('Disconnect','${escape(_("Disconnect"))}')
GetText.add('Do you want to refresh the page now to use the new language?','${escape(_("Do you want to refresh the page now to use the new language?"))}')
GetText.add('Down','${escape(_("Down"))}')
GetText.add('Down Limit','${escape(_("Down Limit"))}')
GetText.add('Down Speed','${escape(_("Down Speed"))}')
GetText.add('Download','${escape(_("Download"))}')
GetText.add('Download Folder','${escape(_("Download Folder"))}')
GetText.add('Download Folder:','${escape(_("Download Folder:"))}')
GetText.add('Download Speed','${escape(_("Download Speed"))}')
GetText.add('Download to:','${escape(_("Download to:"))}')
GetText.add('Downloaded','${escape(_("Downloaded"))}')
GetText.add('Downloading','${escape(_("Downloading"))}')
GetText.add('Downloading:','${escape(_("Downloading:"))}')
GetText.add('Downloads','${escape(_("Downloads"))}')
GetText.add('ETA','${escape(_("ETA"))}')
GetText.add('Edit','${escape(_("Edit"))}')
GetText.add('Edit Connection','${escape(_("Edit Connection"))}')
GetText.add('Edit Tracker','${escape(_("Edit Tracker"))}')
GetText.add('Edit Trackers','${escape(_("Edit Trackers"))}')
GetText.add('Either','${escape(_("Either"))}')
GetText.add('Enable SSL (paths relative to Deluge config folder)','${escape(_("Enable SSL (paths relative to Deluge config folder)"))}')
GetText.add('Enabled','${escape(_("Enabled"))}')
GetText.add('Encryption','${escape(_("Encryption"))}')
GetText.add('Error','${escape(_("Error"))}')
GetText.add('Expand All','${escape(_("Expand All"))}')
GetText.add('External IP Address','${escape(_("External IP Address"))}')
GetText.add('File','${escape(_("File"))}')
GetText.add('File Browser','${escape(_("File Browser"))}')
GetText.add('Filename','${escape(_("Filename"))}')
GetText.add('Files','${escape(_("Files"))}')
GetText.add('Filters','${escape(_("Filters"))}')
GetText.add('Find More','${escape(_("Find More"))}')
GetText.add('Folders','${escape(_("Folders"))}')
GetText.add('Force Proxy','${escape(_("Force Proxy"))}')
GetText.add('Force Recheck','${escape(_("Force Recheck"))}')
GetText.add('Force Use of Proxy','${escape(_("Force Use of Proxy"))}')
GetText.add('Forced','${escape(_("Forced"))}')
GetText.add('Forward','${escape(_("Forward"))}')
GetText.add('Freespace in download folder','${escape(_("Freespace in download folder"))}')
GetText.add('From:','${escape(_("From:"))}')
GetText.add('Full Stream','${escape(_("Full Stream"))}')
GetText.add('General','${escape(_("General"))}')
GetText.add('GeoIP Database','${escape(_("GeoIP Database"))}')
GetText.add('Global Bandwidth Usage','${escape(_("Global Bandwidth Usage"))}')
GetText.add('HTTP','${escape(_("HTTP"))}')
GetText.add('HTTP Auth','${escape(_("HTTP Auth"))}')
GetText.add('Handshake','${escape(_("Handshake"))}')
GetText.add('Hash:','${escape(_("Hash:"))}')
GetText.add('Help','${escape(_("Help"))}')
GetText.add('Help us improve Deluge by sending us your Python version, PyGTK version, OS and processor types. Absolutely no other information is sent.','${escape(_("Help us improve Deluge by sending us your Python version, PyGTK version, OS and processor types. Absolutely no other information is sent."))}')
GetText.add('Hide Client Identity','${escape(_("Hide Client Identity"))}')
GetText.add('High','${escape(_("High"))}')
GetText.add('Home','${escape(_("Home"))}')
GetText.add('Homepage:','${escape(_("Homepage:"))}')
GetText.add('Host','${escape(_("Host"))}')
GetText.add('Host:','${escape(_("Host:"))}')
GetText.add('I2P','${escape(_("I2P"))}')
GetText.add('Ignore','${escape(_("Ignore"))}')
GetText.add('Ignore limits on local network','${escape(_("Ignore limits on local network"))}')
GetText.add('Ignore slow torrents','${escape(_("Ignore slow torrents"))}')
GetText.add('Incoming Address','${escape(_("Incoming Address"))}')
GetText.add('Incoming Port','${escape(_("Incoming Port"))}')
GetText.add('Incoming:','${escape(_("Incoming:"))}')
GetText.add('Infohash','${escape(_("Infohash"))}')
GetText.add('Install','${escape(_("Install"))}')
GetText.add('Install Plugin','${escape(_("Install Plugin"))}')
GetText.add('Interface','${escape(_("Interface"))}')
GetText.add('Invalid Password','${escape(_("Invalid Password"))}')
GetText.add('KiB/s','${escape(_("KiB/s"))}')
GetText.add('LSD','${escape(_("LSD"))}')
GetText.add('Labels','${escape(_("Labels"))}')
GetText.add('Language','${escape(_("Language"))}')
GetText.add('Last Transfer','${escape(_("Last Transfer"))}')
GetText.add('Level:','${escape(_("Level:"))}')
GetText.add('Loading','${escape(_("Loading"))}')
GetText.add('Login','${escape(_("Login"))}')
GetText.add('Login Failed','${escape(_("Login Failed"))}')
GetText.add('Logout','${escape(_("Logout"))}')
GetText.add('Lost Connection','${escape(_("Lost Connection"))}')
GetText.add('Lost connection to webserver','${escape(_("Lost connection to webserver"))}')
GetText.add('Low','${escape(_("Low"))}')
GetText.add('Max Connections','${escape(_("Max Connections"))}')
GetText.add('Max Connections:','${escape(_("Max Connections:"))}')
GetText.add('Max Down Speed','${escape(_("Max Down Speed"))}')
GetText.add('Max Download Speed:','${escape(_("Max Download Speed:"))}')
GetText.add('Max Up Speed','${escape(_("Max Up Speed"))}')
GetText.add('Max Upload Slots','${escape(_("Max Upload Slots"))}')
GetText.add('Max Upload Slots:','${escape(_("Max Upload Slots:"))}')
GetText.add('Max Upload Speed:','${escape(_("Max Upload Speed:"))}')
GetText.add('Maximum Connection Attempts per Second:','${escape(_("Maximum Connection Attempts per Second:"))}')
GetText.add('Maximum Connections:','${escape(_("Maximum Connections:"))}')
GetText.add('Maximum Download Speed (KiB/s):','${escape(_("Maximum Download Speed (KiB/s):"))}')
GetText.add('Maximum Half-Open Connections:','${escape(_("Maximum Half-Open Connections:"))}')
GetText.add('Maximum Upload Slots','${escape(_("Maximum Upload Slots"))}')
GetText.add('Maximum Upload Slots:','${escape(_("Maximum Upload Slots:"))}')
GetText.add('Maximum Upload Speed (KiB/s):','${escape(_("Maximum Upload Speed (KiB/s):"))}')
GetText.add('Move','${escape(_("Move"))}')
GetText.add('Move Completed Folder','${escape(_("Move Completed Folder"))}')
GetText.add('Move Completed:','${escape(_("Move Completed:"))}')
GetText.add('Move Download Folder','${escape(_("Move Download Folder"))}')
GetText.add('Move completed to:','${escape(_("Move completed to:"))}')
GetText.add('NAT-PMP','${escape(_("NAT-PMP"))}')
GetText.add('Name','${escape(_("Name"))}')
GetText.add('Name:','${escape(_("Name:"))}')
GetText.add('Network','${escape(_("Network"))}')
GetText.add('Network Extras','${escape(_("Network Extras"))}')
GetText.add('Never','${escape(_("Never"))}')
GetText.add('New Torrents','${escape(_("New Torrents"))}')
GetText.add('New:','${escape(_("New:"))}')
GetText.add('None','${escape(_("None"))}')
GetText.add('Normal','${escape(_("Normal"))}')
GetText.add('Not Connected','${escape(_("Not Connected"))}')
GetText.add('Not a valid torrent','${escape(_("Not a valid torrent"))}')
GetText.add('OK','${escape(_("OK"))}')
GetText.add('Off','${escape(_("Off"))}')
GetText.add('Offline','${escape(_("Offline"))}')
GetText.add('Old:','${escape(_("Old:"))}')
GetText.add('On','${escape(_("On"))}')
GetText.add('Online','${escape(_("Online"))}')
GetText.add('Options','${escape(_("Options"))}')
GetText.add('Other','${escape(_("Other"))}')
GetText.add('Outgoing Interface','${escape(_("Outgoing Interface"))}')
GetText.add('Outgoing Ports','${escape(_("Outgoing Ports"))}')
GetText.add('Outgoing:','${escape(_("Outgoing:"))}')
GetText.add('Owner','${escape(_("Owner"))}')
GetText.add('Password','${escape(_("Password"))}')
GetText.add('Password:','${escape(_("Password:"))}')
GetText.add('Path:','${escape(_("Path:"))}')
GetText.add('Pause','${escape(_("Pause"))}')
GetText.add('Pause torrent','${escape(_("Pause torrent"))}')
GetText.add('Paused','${escape(_("Paused"))}')
GetText.add('Peer Exchange','${escape(_("Peer Exchange"))}')
GetText.add('Peer TOS Byte:','${escape(_("Peer TOS Byte:"))}')
GetText.add('Peers','${escape(_("Peers"))}')
GetText.add('Per Torrent Bandwidth Usage','${escape(_("Per Torrent Bandwidth Usage"))}')
GetText.add('Periodically check the website for new releases','${escape(_("Periodically check the website for new releases"))}')
GetText.add('Plugin','${escape(_("Plugin"))}')
GetText.add('Plugin Egg','${escape(_("Plugin Egg"))}')
GetText.add('Plugins','${escape(_("Plugins"))}')
GetText.add('Port','${escape(_("Port"))}')
GetText.add('Port:','${escape(_("Port:"))}')
GetText.add('Pre-allocate disk space','${escape(_("Pre-allocate disk space"))}')
GetText.add('Preallocate Disk Space','${escape(_("Preallocate Disk Space"))}')
GetText.add('Prefer seeding torrents','${escape(_("Prefer seeding torrents"))}')
GetText.add('Preferences','${escape(_("Preferences"))}')
GetText.add('Prioritize First/Last','${escape(_("Prioritize First/Last"))}')
GetText.add('Prioritize First/Last Pieces','${escape(_("Prioritize First/Last Pieces"))}')
GetText.add('Prioritize first and last pieces of torrent','${escape(_("Prioritize first and last pieces of torrent"))}')
GetText.add('Priority','${escape(_("Priority"))}')
GetText.add('Private','${escape(_("Private"))}')
GetText.add('Private Key:','${escape(_("Private Key:"))}')
GetText.add('Progress','${escape(_("Progress"))}')
GetText.add('Protocol Traffic Download/Upload','${escape(_("Protocol Traffic Download/Upload"))}')
GetText.add('Proxy','${escape(_("Proxy"))}')
GetText.add('Proxy Hostnames','${escape(_("Proxy Hostnames"))}')
GetText.add('Proxy Peers','${escape(_("Proxy Peers"))}')
GetText.add('Proxy Trackers','${escape(_("Proxy Trackers"))}')
GetText.add('Public','${escape(_("Public"))}')
GetText.add('Queue','${escape(_("Queue"))}')
GetText.add('Queue to top','${escape(_("Queue to top"))}')
GetText.add('Queued','${escape(_("Queued"))}')
GetText.add('Rate limit IP overhead','${escape(_("Rate limit IP overhead"))}')
GetText.add('Ratio','${escape(_("Ratio"))}')
GetText.add('Refresh','${escape(_("Refresh"))}')
GetText.add('Remaining','${escape(_("Remaining"))}')
GetText.add('Remove','${escape(_("Remove"))}')
GetText.add('Remove Torrent','${escape(_("Remove Torrent"))}')
GetText.add('Remove With Data','${escape(_("Remove With Data"))}')
GetText.add('Remove at ratio','${escape(_("Remove at ratio"))}')
GetText.add('Remove torrent','${escape(_("Remove torrent"))}')
GetText.add('Resume','${escape(_("Resume"))}')
GetText.add('Save','${escape(_("Save"))}')
GetText.add('Seeding','${escape(_("Seeding"))}')
GetText.add('Seeding Rotation','${escape(_("Seeding Rotation"))}')
GetText.add('Seeding:','${escape(_("Seeding:"))}')
GetText.add('Seeds','${escape(_("Seeds"))}')
GetText.add('Seeds:Peers','${escape(_("Seeds:Peers"))}')
GetText.add('Select an egg','${escape(_("Select an egg"))}')
GetText.add('Sequential Download','${escape(_("Sequential Download"))}')
GetText.add('Sequential download','${escape(_("Sequential download"))}')
GetText.add('Server','${escape(_("Server"))}')
GetText.add('Session Timeout:','${escape(_("Session Timeout:"))}')
GetText.add('Set Maximum Connections','${escape(_("Set Maximum Connections"))}')
GetText.add('Set Maximum Download Speed','${escape(_("Set Maximum Download Speed"))}')
GetText.add('Set Maximum Upload Speed','${escape(_("Set Maximum Upload Speed"))}')
GetText.add('Settings','${escape(_("Settings"))}')
GetText.add('Share Ratio Reached','${escape(_("Share Ratio Reached"))}')
GetText.add('Share Ratio:','${escape(_("Share Ratio:"))}')
GetText.add('Shared','${escape(_("Shared"))}')
GetText.add('Show filters with zero torrents','${escape(_("Show filters with zero torrents"))}')
GetText.add('Show session speed in titlebar','${escape(_("Show session speed in titlebar"))}')
GetText.add('Size','${escape(_("Size"))}')
GetText.add('Skip File Hash Check','${escape(_("Skip File Hash Check"))}')
GetText.add('Socks4','${escape(_("Socks4"))}')
GetText.add('Socks5','${escape(_("Socks5"))}')
GetText.add('Socks5 Auth','${escape(_("Socks5 Auth"))}')
GetText.add('Start Daemon','${escape(_("Start Daemon"))}')
GetText.add('State','${escape(_("State"))}')
GetText.add('States','${escape(_("States"))}')
GetText.add('Status','${escape(_("Status"))}')
GetText.add('Status:','${escape(_("Status:"))}')
GetText.add('Stop Daemon','${escape(_("Stop Daemon"))}')
GetText.add('Stop seed at ratio:','${escape(_("Stop seed at ratio:"))}')
GetText.add('System Default','${escape(_("System Default"))}')
GetText.add('System Information','${escape(_("System Information"))}')
GetText.add('The connection to the webserver has been lost!','${escape(_("The connection to the webserver has been lost!"))}')
GetText.add('Tier','${escape(_("Tier"))}')
GetText.add('Time (m):','${escape(_("Time (m):"))}')
GetText.add('Time Ratio:','${escape(_("Time Ratio:"))}')
GetText.add('To:','${escape(_("To:"))}')
GetText.add('Top','${escape(_("Top"))}')
GetText.add('Total Files:','${escape(_("Total Files:"))}')
GetText.add('Total Size:','${escape(_("Total Size:"))}')
GetText.add('Total:','${escape(_("Total:"))}')
GetText.add('Tracker','${escape(_("Tracker"))}')
GetText.add('Tracker Host','${escape(_("Tracker Host"))}')
GetText.add('Tracker:','${escape(_("Tracker:"))}')
GetText.add('Trackers','${escape(_("Trackers"))}')
GetText.add('Trackers:','${escape(_("Trackers:"))}')
GetText.add('Type Of Service','${escape(_("Type Of Service"))}')
GetText.add('Type:','${escape(_("Type:"))}')
GetText.add('U/L Speed Limit','${escape(_("U/L Speed Limit"))}')
GetText.add('UPnP','${escape(_("UPnP"))}')
GetText.add('Unable to add host: {0}','${escape(_("Unable to add host: {0}"))}')
GetText.add('Unable to edit host','${escape(_("Unable to edit host"))}')
GetText.add('Unlimited','${escape(_("Unlimited"))}')
GetText.add('Up','${escape(_("Up"))}')
GetText.add('Up Limit','${escape(_("Up Limit"))}')
GetText.add('Up Speed','${escape(_("Up Speed"))}')
GetText.add('Update Tracker','${escape(_("Update Tracker"))}')
GetText.add('Updates','${escape(_("Updates"))}')
GetText.add('Upload Slot Limit','${escape(_("Upload Slot Limit"))}')
GetText.add('Upload Speed','${escape(_("Upload Speed"))}')
GetText.add('Uploaded','${escape(_("Uploaded"))}')
GetText.add('Uploading your plugin...','${escape(_("Uploading your plugin..."))}')
GetText.add('Uploading your torrent...','${escape(_("Uploading your torrent..."))}')
GetText.add('Url','${escape(_("Url"))}')
GetText.add('Use Random Port','${escape(_("Use Random Port"))}')
GetText.add('Use Random Ports','${escape(_("Use Random Ports"))}')
GetText.add('Username:','${escape(_("Username:"))}')
GetText.add('Version','${escape(_("Version"))}')
GetText.add('Version:','${escape(_("Version:"))}')
GetText.add('Warning','${escape(_("Warning"))}')
GetText.add('We recommend changing the default password.<br><br>Would you like to change it now?','${escape(_("We recommend changing the default password.<br><br>Would you like to change it now?"))}')
GetText.add('WebUI Language Changed','${escape(_("WebUI Language Changed"))}')
GetText.add('WebUI Password','${escape(_("WebUI Password"))}')
GetText.add('Yes, please send anonymous statistics','${escape(_("Yes, please send anonymous statistics"))}')
GetText.add('You entered an incorrect password','${escape(_("You entered an incorrect password"))}')
GetText.add('Your old password was incorrect!','${escape(_("Your old password was incorrect!"))}')
GetText.add('Your password was successfully changed!','${escape(_("Your password was successfully changed!"))}')
GetText.add('Your passwords don\'t match!','${escape(_("Your passwords don\'t match!"))}')

View File

@ -83,6 +83,19 @@ class GetText(resource.Resource):
return compress(template.render(), request) return compress(template.render(), request)
class MockGetText(resource.Resource):
"""GetText Mocking class
This class will mock the file `gettext.js` in case it does not exists.
It will be used to define the `_` (underscore) function for translations,
and will return the string to translate, as is.
"""
def render(self, request):
request.setHeader(b'content-type', b'text/javascript; encoding=utf-8')
data = 'function _(string) { return string; }'
return compress(data, request)
class Upload(resource.Resource): class Upload(resource.Resource):
""" """
Twisted Web resource to handle file uploads Twisted Web resource to handle file uploads
@ -431,8 +444,15 @@ class TopLevel(resource.Resource):
def __init__(self): def __init__(self):
resource.Resource.__init__(self) resource.Resource.__init__(self)
self.putChild('css', LookupResource('Css', rpath('css'))) self.putChild('css', LookupResource('Css', rpath('css')))
self.putChild('gettext.js', GetText()) if os.path.isfile(rpath('js', 'gettext.js')):
self.putChild('gettext.js', GetText())
else:
log.warning(
'Cannot find "gettext.js" translation file!'
' Text will only be available in English.')
self.putChild('gettext.js', MockGetText())
self.putChild('flag', Flag()) self.putChild('flag', Flag())
self.putChild('icons', LookupResource('Icons', rpath('icons'))) self.putChild('icons', LookupResource('Icons', rpath('icons')))
self.putChild('images', LookupResource('Images', rpath('images'))) self.putChild('images', LookupResource('Images', rpath('images')))