Helpviewer/HelpBrowserWV.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3190
a9a94491c4fd
child 3539
0c2dc1446ebf
--- a/Helpviewer/HelpBrowserWV.py	Sun Mar 30 22:00:14 2014 +0200
+++ b/Helpviewer/HelpBrowserWV.py	Thu Apr 03 23:05:31 2014 +0200
@@ -10,8 +10,8 @@
 
 from __future__ import unicode_literals
 try:
-    str = unicode    # __IGNORE_WARNING__
-except (NameError):
+    str = unicode
+except NameError:
     pass
 
 from PyQt4.QtCore import pyqtSlot, pyqtSignal, QObject, QT_TRANSLATE_NOOP, \
@@ -124,7 +124,7 @@
             else:
                 return "RTL"
         
-        return self.trUtf8(trans)
+        return self.tr(trans)
     
     @pyqtSlot(result=str)
     def providerString(self):
@@ -133,7 +133,7 @@
         
         @return string for the search provider (string)
         """
-        return self.trUtf8("Search results provided by {0}")\
+        return self.tr("Search results provided by {0}")\
             .format(self.__mw.openSearchManager().currentEngineName())
     
     @pyqtSlot(str, result=str)
@@ -207,8 +207,8 @@
         if type_ == QWebPage.NavigationTypeFormResubmitted:
             res = E5MessageBox.yesNo(
                 self.view(),
-                self.trUtf8("Resending POST request"),
-                self.trUtf8(
+                self.tr("Resending POST request"),
+                self.tr(
                     """In order to display the site, the request along with"""
                     """ all the data must be sent once again, which may lead"""
                     """ to some unexpected behaviour of the site e.g. the"""
@@ -288,7 +288,7 @@
             
             files.fileNames = E5FileDialog.getOpenFileNames(
                 None,
-                self.trUtf8("Select files to upload..."),
+                self.tr("Select files to upload..."),
                 suggestedFileName)
             return True
         
@@ -317,8 +317,8 @@
                 else:
                     # the whole page is blocked
                     rule = info.errorString.replace("AdBlockRule:", "")
-                    title = self.trUtf8("Content blocked by AdBlock Plus")
-                    message = self.trUtf8(
+                    title = self.tr("Content blocked by AdBlock Plus")
+                    message = self.tr(
                         "Blocked by rule: <i>{0}</i>").format(rule)
                     
                     htmlFile = QFile(":/html/adblockPage.html")
@@ -338,7 +338,7 @@
                info.errorString == "eric5:No Error":
                 return False
             
-            title = self.trUtf8("Error loading page: {0}").format(urlString)
+            title = self.tr("Error loading page: {0}").format(urlString)
             htmlFile = QFile(":/html/notFoundPage.html")
             htmlFile.open(QFile.ReadOnly)
             html = htmlFile.readAll()
@@ -358,31 +358,31 @@
             html = html.replace("@TITLE@", title.encode("utf8"))
             html = html.replace("@H1@", info.errorString.encode("utf8"))
             html = html.replace(
-                "@H2@", self.trUtf8("When connecting to: {0}.")
+                "@H2@", self.tr("When connecting to: {0}.")
                 .format(urlString).encode("utf8"))
             html = html.replace(
                 "@LI-1@",
-                self.trUtf8("Check the address for errors such as "
-                            "<b>ww</b>.example.org instead of "
-                            "<b>www</b>.example.org").encode("utf8"))
+                self.tr("Check the address for errors such as "
+                        "<b>ww</b>.example.org instead of "
+                        "<b>www</b>.example.org").encode("utf8"))
             html = html.replace(
                 "@LI-2@",
-                self.trUtf8(
+                self.tr(
                     "If the address is correct, try checking the network "
                     "connection.").encode("utf8"))
             html = html.replace(
                 "@LI-3@",
-                self.trUtf8(
+                self.tr(
                     "If your computer or network is protected by a firewall "
                     "or proxy, make sure that the browser is permitted to "
                     "access the network.").encode("utf8"))
             html = html.replace(
                 "@LI-4@",
-                self.trUtf8("If your cache policy is set to offline browsing,"
-                            "only pages in the local cache are available.")
+                self.tr("If your cache policy is set to offline browsing,"
+                        "only pages in the local cache are available.")
                 .encode("utf8"))
             html = html.replace(
-                "@BUTTON@", self.trUtf8("Try Again").encode("utf8"))
+                "@BUTTON@", self.tr("Try Again").encode("utf8"))
             errorPage.content = html
             return True
         
@@ -548,8 +548,8 @@
         else:
             E5MessageBox.warning(
                 self.view(),
-                self.trUtf8("SSL Info"),
-                self.trUtf8("""This site does not contain SSL information."""))
+                self.tr("SSL Info"),
+                self.tr("""This site does not contain SSL information."""))
     
     def hasValidSslInfo(self):
         """
@@ -654,7 +654,7 @@
         """
         super(HelpBrowser, self).__init__(parent)
         self.setObjectName(name)
-        self.setWhatsThis(self.trUtf8(
+        self.setWhatsThis(self.tr(
             """<b>Help Window</b>"""
             """<p>This window displays the selected help information.</p>"""
         ))
@@ -828,8 +828,8 @@
             if not QFileInfo(name.toLocalFile()).exists():
                 E5MessageBox.critical(
                     self,
-                    self.trUtf8("eric5 Web Browser"),
-                    self.trUtf8(
+                    self.tr("eric5 Web Browser"),
+                    self.tr(
                         """<p>The file <b>{0}</b> does not exist.</p>""")
                     .format(name.toLocalFile()))
                 return
@@ -842,8 +842,8 @@
                 if not started:
                     E5MessageBox.critical(
                         self,
-                        self.trUtf8("eric5 Web Browser"),
-                        self.trUtf8(
+                        self.tr("eric5 Web Browser"),
+                        self.tr(
                             """<p>Could not start a viewer"""
                             """ for file <b>{0}</b>.</p>""")
                         .format(name.path()))
@@ -853,8 +853,8 @@
             if not started:
                 E5MessageBox.critical(
                     self,
-                    self.trUtf8("eric5 Web Browser"),
-                    self.trUtf8(
+                    self.tr("eric5 Web Browser"),
+                    self.tr(
                         """<p>Could not start an application"""
                         """ for URL <b>{0}</b>.</p>""")
                     .format(name.toString()))
@@ -873,8 +873,8 @@
                 if not started:
                     E5MessageBox.critical(
                         self,
-                        self.trUtf8("eric5 Web Browser"),
-                        self.trUtf8(
+                        self.tr("eric5 Web Browser"),
+                        self.tr(
                             """<p>Could not start a viewer"""
                             """ for file <b>{0}</b>.</p>""")
                         .format(name.path()))
@@ -1083,29 +1083,29 @@
         if not hit.linkUrl().isEmpty():
             menu.addAction(
                 UI.PixmapCache.getIcon("openNewTab.png"),
-                self.trUtf8("Open Link in New Tab\tCtrl+LMB"),
+                self.tr("Open Link in New Tab\tCtrl+LMB"),
                 self.__openLinkInNewTab).setData(hit.linkUrl())
             menu.addSeparator()
             menu.addAction(
                 UI.PixmapCache.getIcon("download.png"),
-                self.trUtf8("Save Lin&k"), self.__downloadLink)
+                self.tr("Save Lin&k"), self.__downloadLink)
             menu.addAction(
                 UI.PixmapCache.getIcon("bookmark22.png"),
-                self.trUtf8("Bookmark this Link"), self.__bookmarkLink)\
+                self.tr("Bookmark this Link"), self.__bookmarkLink)\
                 .setData(hit.linkUrl())
             menu.addSeparator()
             menu.addAction(
                 UI.PixmapCache.getIcon("editCopy.png"),
-                self.trUtf8("Copy Link to Clipboard"), self.__copyLink)
+                self.tr("Copy Link to Clipboard"), self.__copyLink)
             menu.addAction(
                 UI.PixmapCache.getIcon("mailSend.png"),
-                self.trUtf8("Send Link"),
+                self.tr("Send Link"),
                 self.__sendLink).setData(hit.linkUrl())
             if Preferences.getHelp("VirusTotalEnabled") and \
                Preferences.getHelp("VirusTotalServiceKey") != "":
                 menu.addAction(
                     UI.PixmapCache.getIcon("virustotal.png"),
-                    self.trUtf8("Scan Link with VirusTotal"),
+                    self.tr("Scan Link with VirusTotal"),
                     self.__virusTotal).setData(hit.linkUrl())
         
         if not hit.imageUrl().isEmpty():
@@ -1113,32 +1113,32 @@
                 menu.addSeparator()
             menu.addAction(
                 UI.PixmapCache.getIcon("openNewTab.png"),
-                self.trUtf8("Open Image in New Tab"),
+                self.tr("Open Image in New Tab"),
                 self.__openLinkInNewTab).setData(hit.imageUrl())
             menu.addSeparator()
             menu.addAction(
                 UI.PixmapCache.getIcon("download.png"),
-                self.trUtf8("Save Image"), self.__downloadImage)
+                self.tr("Save Image"), self.__downloadImage)
             menu.addAction(
-                self.trUtf8("Copy Image to Clipboard"), self.__copyImage)
+                self.tr("Copy Image to Clipboard"), self.__copyImage)
             menu.addAction(
                 UI.PixmapCache.getIcon("editCopy.png"),
-                self.trUtf8("Copy Image Location to Clipboard"),
+                self.tr("Copy Image Location to Clipboard"),
                 self.__copyLocation).setData(hit.imageUrl().toString())
             menu.addAction(
                 UI.PixmapCache.getIcon("mailSend.png"),
-                self.trUtf8("Send Image Link"),
+                self.tr("Send Image Link"),
                 self.__sendLink).setData(hit.imageUrl())
             menu.addSeparator()
             menu.addAction(
                 UI.PixmapCache.getIcon("adBlockPlus.png"),
-                self.trUtf8("Block Image"), self.__blockImage)\
+                self.tr("Block Image"), self.__blockImage)\
                 .setData(hit.imageUrl().toString())
             if Preferences.getHelp("VirusTotalEnabled") and \
                Preferences.getHelp("VirusTotalServiceKey") != "":
                 menu.addAction(
                     UI.PixmapCache.getIcon("virustotal.png"),
-                    self.trUtf8("Scan Image with VirusTotal"),
+                    self.tr("Scan Image with VirusTotal"),
                     self.__virusTotal).setData(hit.imageUrl())
         
         element = hit.element()
@@ -1156,31 +1156,31 @@
                 if paused:
                     menu.addAction(
                         UI.PixmapCache.getIcon("mediaPlaybackStart.png"),
-                        self.trUtf8("Play"), self.__pauseMedia)
+                        self.tr("Play"), self.__pauseMedia)
                 else:
                     menu.addAction(
                         UI.PixmapCache.getIcon("mediaPlaybackPause.png"),
-                        self.trUtf8("Pause"), self.__pauseMedia)
+                        self.tr("Pause"), self.__pauseMedia)
                 if muted:
                     menu.addAction(
                         UI.PixmapCache.getIcon("audioVolumeHigh.png"),
-                        self.trUtf8("Unmute"), self.__muteMedia)
+                        self.tr("Unmute"), self.__muteMedia)
                 else:
                     menu.addAction(
                         UI.PixmapCache.getIcon("audioVolumeMuted.png"),
-                        self.trUtf8("Mute"), self.__muteMedia)
+                        self.tr("Mute"), self.__muteMedia)
                 menu.addSeparator()
                 menu.addAction(
                     UI.PixmapCache.getIcon("editCopy.png"),
-                    self.trUtf8("Copy Media Address to Clipboard"),
+                    self.tr("Copy Media Address to Clipboard"),
                     self.__copyLocation).setData(videoUrl.toString())
                 menu.addAction(
                     UI.PixmapCache.getIcon("mailSend.png"),
-                    self.trUtf8("Send Media Address"), self.__sendLink)\
+                    self.tr("Send Media Address"), self.__sendLink)\
                     .setData(videoUrl)
                 menu.addAction(
                     UI.PixmapCache.getIcon("download.png"),
-                    self.trUtf8("Save Media"), self.__downloadMedia)\
+                    self.tr("Save Media"), self.__downloadMedia)\
                     .setData(videoUrl)
             
             if element.tagName().lower() in ["input", "textarea"]:
@@ -1221,39 +1221,39 @@
         
         if frameAtPos and self.page().mainFrame() != frameAtPos:
             self.__clickedFrame = frameAtPos
-            fmenu = QMenu(self.trUtf8("This Frame"))
+            fmenu = QMenu(self.tr("This Frame"))
             frameUrl = self.__clickedFrame.url()
             if frameUrl.isValid():
                 fmenu.addAction(
-                    self.trUtf8("Show &only this frame"),
+                    self.tr("Show &only this frame"),
                     self.__loadClickedFrame)
                 fmenu.addAction(
                     UI.PixmapCache.getIcon("openNewTab.png"),
-                    self.trUtf8("Show in new &tab"),
+                    self.tr("Show in new &tab"),
                     self.__openLinkInNewTab).setData(self.__clickedFrame.url())
                 fmenu.addSeparator()
             fmenu.addAction(
                 UI.PixmapCache.getIcon("print.png"),
-                self.trUtf8("&Print"), self.__printClickedFrame)
+                self.tr("&Print"), self.__printClickedFrame)
             fmenu.addAction(
                 UI.PixmapCache.getIcon("printPreview.png"),
-                self.trUtf8("Print Preview"), self.__printPreviewClickedFrame)
+                self.tr("Print Preview"), self.__printPreviewClickedFrame)
             fmenu.addAction(
                 UI.PixmapCache.getIcon("printPdf.png"),
-                self.trUtf8("Print as PDF"), self.__printPdfClickedFrame)
+                self.tr("Print as PDF"), self.__printPdfClickedFrame)
             fmenu.addSeparator()
             fmenu.addAction(
                 UI.PixmapCache.getIcon("zoomIn.png"),
-                self.trUtf8("Zoom &in"), self.__zoomInClickedFrame)
+                self.tr("Zoom &in"), self.__zoomInClickedFrame)
             fmenu.addAction(
                 UI.PixmapCache.getIcon("zoomReset.png"),
-                self.trUtf8("Zoom &reset"), self.__zoomResetClickedFrame)
+                self.tr("Zoom &reset"), self.__zoomResetClickedFrame)
             fmenu.addAction(
                 UI.PixmapCache.getIcon("zoomOut.png"),
-                self.trUtf8("Zoom &out"), self.__zoomOutClickedFrame)
+                self.tr("Zoom &out"), self.__zoomOutClickedFrame)
             fmenu.addSeparator()
             fmenu.addAction(
-                self.trUtf8("Show frame so&urce"),
+                self.tr("Show frame so&urce"),
                 self.__showClickedFrameSource)
             
             menu.addMenu(fmenu)
@@ -1261,12 +1261,12 @@
         
         menu.addAction(
             UI.PixmapCache.getIcon("bookmark22.png"),
-            self.trUtf8("Bookmark this Page"), self.addBookmark)
+            self.tr("Bookmark this Page"), self.addBookmark)
         menu.addAction(
             UI.PixmapCache.getIcon("mailSend.png"),
-            self.trUtf8("Send Page Link"), self.__sendLink).setData(self.url())
+            self.tr("Send Page Link"), self.__sendLink).setData(self.url())
         menu.addSeparator()
-        self.__userAgentMenu = UserAgentMenu(self.trUtf8("User Agent"),
+        self.__userAgentMenu = UserAgentMenu(self.tr("User Agent"),
                                              url=self.url())
         menu.addMenu(self.__userAgentMenu)
         menu.addSeparator()
@@ -1282,12 +1282,12 @@
             menu.addAction(self.mw.copyAct)
             menu.addAction(
                 UI.PixmapCache.getIcon("mailSend.png"),
-                self.trUtf8("Send Text"),
+                self.tr("Send Text"),
                 self.__sendLink).setData(self.selectedText())
         menu.addAction(self.mw.findAct)
         menu.addSeparator()
         if self.selectedText():
-            self.__searchMenu = menu.addMenu(self.trUtf8("Search with..."))
+            self.__searchMenu = menu.addMenu(self.tr("Search with..."))
             
             from .OpenSearch.OpenSearchEngineAction import \
                 OpenSearchEngineAction
@@ -1314,21 +1314,21 @@
                         langCode, self.selectedText()))
                 menu.addAction(
                     UI.PixmapCache.getIcon("translate.png"),
-                    self.trUtf8("Google Translate"), self.__openLinkInNewTab)\
+                    self.tr("Google Translate"), self.__openLinkInNewTab)\
                     .setData(googleTranslatorUrl)
                 wiktionaryUrl = QUrl(
                     "http://{0}.wiktionary.org/wiki/Special:Search?search={1}"
                     .format(langCode, self.selectedText()))
                 menu.addAction(
                     UI.PixmapCache.getIcon("wikipedia.png"),
-                    self.trUtf8("Dictionary"), self.__openLinkInNewTab)\
+                    self.tr("Dictionary"), self.__openLinkInNewTab)\
                     .setData(wiktionaryUrl)
                 menu.addSeparator()
             
             guessedUrl = QUrl.fromUserInput(self.selectedText().strip())
             if self.__isUrlValid(guessedUrl):
                 menu.addAction(
-                    self.trUtf8("Go to web address"),
+                    self.tr("Go to web address"),
                     self.__openLinkInNewTab).setData(guessedUrl)
                 menu.addSeparator()
         
@@ -1336,13 +1336,13 @@
         if not element.isNull() and \
            element.tagName().lower() == "input" and \
            element.attribute("type", "text") == "text":
-            menu.addAction(self.trUtf8("Add to web search toolbar"),
+            menu.addAction(self.tr("Add to web search toolbar"),
                            self.__addSearchEngine).setData(element)
             menu.addSeparator()
         
         menu.addAction(
             UI.PixmapCache.getIcon("webInspector.png"),
-            self.trUtf8("Web Inspector..."), self.__webInspector)
+            self.tr("Web Inspector..."), self.__webInspector)
         
         menu.exec_(evt.globalPos())
     
@@ -1517,8 +1517,8 @@
         if method != "get":
             E5MessageBox.warning(
                 self,
-                self.trUtf8("Method not supported"),
-                self.trUtf8(
+                self.tr("Method not supported"),
+                self.tr(
                     """{0} method is not supported.""").format(method.upper()))
             return
         
@@ -1562,8 +1562,8 @@
         if len(searchEngines) > 1:
             searchEngine, ok = QInputDialog.getItem(
                 self,
-                self.trUtf8("Search engine"),
-                self.trUtf8("Choose the desired search engine"),
+                self.tr("Search engine"),
+                self.tr("Choose the desired search engine"),
                 sorted(searchEngines.keys()), 0, False)
             
             if not ok:
@@ -1580,8 +1580,8 @@
         
         engineName, ok = QInputDialog.getText(
             self,
-            self.trUtf8("Engine name"),
-            self.trUtf8("Enter a name for the engine"),
+            self.tr("Engine name"),
+            self.tr("Enter a name for the engine"),
             QLineEdit.Normal,
             engineName)
         if not ok:
@@ -1940,7 +1940,7 @@
                 return
         
         urlString = bytes(replyUrl.toEncoded()).decode()
-        title = self.trUtf8("Error loading page: {0}").format(urlString)
+        title = self.tr("Error loading page: {0}").format(urlString)
         htmlFile = QFile(":/html/notFoundPage.html")
         htmlFile.open(QFile.ReadOnly)
         html = htmlFile.readAll()
@@ -1959,30 +1959,30 @@
         html = html.replace("@TITLE@", title.encode("utf8"))
         html = html.replace("@H1@", reply.errorString().encode("utf8"))
         html = html.replace(
-            "@H2@", self.trUtf8("When connecting to: {0}.")
+            "@H2@", self.tr("When connecting to: {0}.")
             .format(urlString).encode("utf8"))
         html = html.replace(
             "@LI-1@",
-            self.trUtf8("Check the address for errors such as "
-                        "<b>ww</b>.example.org instead of "
-                        "<b>www</b>.example.org").encode("utf8"))
+            self.tr("Check the address for errors such as "
+                    "<b>ww</b>.example.org instead of "
+                    "<b>www</b>.example.org").encode("utf8"))
         html = html.replace(
             "@LI-2@",
-            self.trUtf8("If the address is correct, try checking the network "
-                        "connection.").encode("utf8"))
+            self.tr("If the address is correct, try checking the network "
+                    "connection.").encode("utf8"))
         html = html.replace(
             "@LI-3@",
-            self.trUtf8(
+            self.tr(
                 "If your computer or network is protected by a firewall "
                 "or proxy, make sure that the browser is permitted to "
                 "access the network.").encode("utf8"))
         html = html.replace(
             "@LI-4@",
-            self.trUtf8("If your cache policy is set to offline browsing,"
-                        "only pages in the local cache are available.")
+            self.tr("If your cache policy is set to offline browsing,"
+                    "only pages in the local cache are available.")
             .encode("utf8"))
         html = html.replace(
-            "@BUTTON@", self.trUtf8("Try Again").encode("utf8"))
+            "@BUTTON@", self.tr("Try Again").encode("utf8"))
         notFoundFrame.setHtml(bytes(html).decode("utf8"), replyUrl)
         self.mw.historyManager().removeHistoryEntry(replyUrl, self.title())
         self.loadFinished.emit(False)
@@ -2011,8 +2011,8 @@
         
         res = E5MessageBox.yesNo(
             self,
-            self.trUtf8("Web Database Quota"),
-            self.trUtf8(
+            self.tr("Web Database Quota"),
+            self.tr(
                 """<p>The database quota of <strong>{0}</strong> has"""
                 """ been exceeded while accessing database <strong>{1}"""
                 """</strong>.</p><p>Shall it be changed?</p>""")
@@ -2022,8 +2022,8 @@
         if res:
             newQuota, ok = QInputDialog.getInt(
                 self,
-                self.trUtf8("New Web Database Quota"),
-                self.trUtf8(
+                self.tr("New Web Database Quota"),
+                self.tr(
                     "Enter the new quota in MB (current = {0}, used = {1}; "
                     "step size = 5 MB):"
                     .format(
@@ -2043,13 +2043,13 @@
         """
         unit = ""
         if size < 1024:
-            unit = self.trUtf8("bytes")
+            unit = self.tr("bytes")
         elif size < 1024 * 1024:
             size /= 1024
-            unit = self.trUtf8("kB")
+            unit = self.tr("kB")
         else:
             size /= 1024 * 1024
-            unit = self.trUtf8("MB")
+            unit = self.tr("MB")
         return "{0:.1f} {1}".format(size, unit)
     
     ###########################################################################
@@ -2326,8 +2326,8 @@
             except AttributeError:
                 E5MessageBox.critical(
                     self,
-                    self.trUtf8("eric5 Web Browser"),
-                    self.trUtf8(
+                    self.tr("eric5 Web Browser"),
+                    self.tr(
                         """<p>Printing is not available due to a bug in"""
                         """ PyQt4. Please upgrade.</p>"""))
     
@@ -2372,8 +2372,8 @@
         except AttributeError:
             E5MessageBox.critical(
                 self,
-                self.trUtf8("eric5 Web Browser"),
-                self.trUtf8(
+                self.tr("eric5 Web Browser"),
+                self.tr(
                     """<p>Printing is not available due to a bug in PyQt4."""
                     """Please upgrade.</p>"""))
             return
@@ -2404,8 +2404,8 @@
             except AttributeError:
                 E5MessageBox.critical(
                     self,
-                    self.trUtf8("eric5 Web Browser"),
-                    self.trUtf8(
+                    self.tr("eric5 Web Browser"),
+                    self.tr(
                         """<p>Printing is not available due to a bug in"""
                         """ PyQt4. Please upgrade.</p>"""))
                 return

eric ide

mercurial