4 new commits in instantTranslate: https://bitbucket.org/nvdaaddonteam/instanttranslate/commits/bc1215eae10c/ Changeset: bc1215eae10c Branch: None User: beqa Date: 2013-05-14 20:32:36 Summary: increased number of characters to 1500 characters. Affected #: 1 file diff --git a/addon/globalPlugins/instantTranslate/__init__.py b/addon/globalPlugins/instantTranslate/__init__.py index c94ea68..3f946a6 100644 --- a/addon/globalPlugins/instantTranslate/__init__.py +++ b/addon/globalPlugins/instantTranslate/__init__.py @@ -33,12 +33,12 @@ import addonHandler addonHandler.initTranslation() config_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'instantTranslate.ini') +charslimit=1500 lo_lang = getdefaultlocale () # get a language of the OS localization. s = lo_lang[0] # get the first element of the tuplet. lo_lang = s[0:s.find("_")] # get the default language which is translated into. if not os.path.isfile(config_file): - config = ConfigObj() config.filename = config_file config ["translation"] = {"from": "auto", "into": lo_lang} @@ -80,14 +80,14 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin): # Translators: message presented when user presses the shortcut key for translating clipboard text but the clipboard is empty. ui.message(_("There is no text on the clipboard")) return - if len(text) < 351: + if len(text) < (charslimit): config = ConfigObj(config_file) lang_from = config["translation"]["from"] lang_to = config["translation"]["into"] threading.Thread(target=self.translate, args=(text,)).run() else: # Translators: Message presented when clipboard text (to be translated) is too long (more than a set limit). - ui.message(_("The clipboard contains a large portion of text. It is %s characters long. The limit is 350 characters.") % len(text)) + ui.message(_("The clipboard contains a large portion of text. It is %s characters long. The limit is 1500 characters.") % len(text)) # Translators: message presented in input help mode, when user presses the shortcut keys for this addon. script_translateClipboardText.__doc__=_("Translates clipboard text from one language to another using Google Translate.") @@ -105,14 +105,14 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin): # Translators: user has pressed the shortcut key for translating selected text, but no text was actually selected. ui.message(_("no selection")) else: - if len(info.text) < 351: + if len(info.text) < (charslimit): config = ConfigObj(config_file) lang_from = config["translation"]["from"] lang_to = config["translation"]["into"] threading.Thread(target=self.translate, args=(info.text,)).run() else: # Translators: Message presented when selected text (to be translated) is too long (more than a set limit). - ui.message(_("The selection contains a large portion of text. It is %s characters long. The limit is 350 characters.") % len(info.text)) + ui.message(_("The selection contains a large portion of text. It is %s characters long. The limit is 1500 characters.") % len(info.text)) # Translators: message presented in input help mode, when user presses the shortcut keys for this addon. script_translateSelection.__doc__=_("Translates selected text from one language to another using Google Translate.") https://bitbucket.org/nvdaaddonteam/instanttranslate/commits/725850f86be8/ Changeset: 725850f86be8 Branch: None User: beqa Date: 2013-05-14 20:44:06 Summary: added shortcut t to the Instant Translate Settings menu item Affected #: 1 file diff --git a/addon/globalPlugins/instantTranslate/__init__.py b/addon/globalPlugins/instantTranslate/__init__.py index 3f946a6..a9862aa 100644 --- a/addon/globalPlugins/instantTranslate/__init__.py +++ b/addon/globalPlugins/instantTranslate/__init__.py @@ -59,7 +59,7 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin): self.prefsMenu = gui.mainFrame.sysTrayIcon.menu.GetMenuItems()[0].GetSubMenu() self.instantTranslateSettingsItem = self.prefsMenu.Append(wx.ID_ANY, # Translators: name of the option in the menu. - _("Instant Translate Settings..."), + _("Instant &Translate Settings..."), # Translators: tooltip text for the menu item. _("Select languages to be used for translation.")) gui.mainFrame.sysTrayIcon.Bind(wx.EVT_MENU , lambda e : gui.mainFrame._popupSettingsDialog(InstantTranslateSettingsDialog), self.instantTranslateSettingsItem) https://bitbucket.org/nvdaaddonteam/instanttranslate/commits/ab02683e8fba/ Changeset: ab02683e8fba Branch: None User: beqa Date: 2013-05-14 21:55:42 Summary: added a checkbox for configuring copying translation results. Affected #: 2 files diff --git a/addon/globalPlugins/instantTranslate/__init__.py b/addon/globalPlugins/instantTranslate/__init__.py index a9862aa..98d48ea 100644 --- a/addon/globalPlugins/instantTranslate/__init__.py +++ b/addon/globalPlugins/instantTranslate/__init__.py @@ -39,9 +39,11 @@ s = lo_lang[0] # get the first element of the tuplet. lo_lang = s[0:s.find("_")] # get the default language which is translated into. if not os.path.isfile(config_file): + config = ConfigObj() config.filename = config_file config ["translation"] = {"from": "auto", "into": lo_lang} + config ["settings"] = {"CopyTranslatedText": "true"} config.write() @@ -71,7 +73,7 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin): pass def script_translateClipboardText(self,gesture): - global lang_from, lang_to + global lang_from, lang_to, copyTranslation try: text = api.getClipData() except: @@ -84,6 +86,7 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin): config = ConfigObj(config_file) lang_from = config["translation"]["from"] lang_to = config["translation"]["into"] + copyTranslation = config["settings"]["CopyTranslatedText"] threading.Thread(target=self.translate, args=(text,)).run() else: # Translators: Message presented when clipboard text (to be translated) is too long (more than a set limit). @@ -92,7 +95,7 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin): script_translateClipboardText.__doc__=_("Translates clipboard text from one language to another using Google Translate.") def script_translateSelection(self, gesture): - global lang_from, lang_to + global lang_from, lang_to, copyTranslation obj=api.getFocusObject() treeInterceptor=obj.treeInterceptor if hasattr(treeInterceptor,'TextInfo') and not treeInterceptor.passThrough: @@ -109,6 +112,7 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin): config = ConfigObj(config_file) lang_from = config["translation"]["from"] lang_to = config["translation"]["into"] + copyTranslation = config["settings"]["CopyTranslatedText"] threading.Thread(target=self.translate, args=(info.text,)).run() else: # Translators: Message presented when selected text (to be translated) is too long (more than a set limit). @@ -128,7 +132,8 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin): if 'dict' in response: translation += " | " + " | ".join((", ".join(w for w in d['terms'])) for d in response['dict']) queueHandler.queueFunction(queueHandler.eventQueue, ui.message, translation) - api.copyToClip(translation) + if copyTranslation == "true": + api.copyToClip(translation) __gestures = { "kb:NVDA+shift+t": "translateSelection", diff --git a/addon/globalPlugins/instantTranslate/interface.py b/addon/globalPlugins/instantTranslate/interface.py index e73b41d..fb7cf91 100644 --- a/addon/globalPlugins/instantTranslate/interface.py +++ b/addon/globalPlugins/instantTranslate/interface.py @@ -43,6 +43,15 @@ class InstantTranslateSettingsDialog(gui.SettingsDialog): intoSizer.Add(self._intoChoice) sizer.Add(fromSizer) sizer.Add(intoSizer) + config = ConfigObj(config_file) + CopyStateValue = 0 + if config["settings"]["CopyTranslatedText"] == "true": + CopyStateValue = 1 + else: + CopyStateValue = 0 + self.copyTranslationChk = wx.CheckBox(self, label=_("Copy translation result to clipboard")) + self.copyTranslationChk.SetValue(CopyStateValue) + sizer.Add(self.copyTranslationChk) def postInit(self): config = ConfigObj(config_file) @@ -60,6 +69,10 @@ class InstantTranslateSettingsDialog(gui.SettingsDialog): config = ConfigObj(config_file) config["translation"]["from"] = langslist[self._fromChoice.GetStringSelection()] config["translation"]["into"] = langslist[self._intoChoice.GetStringSelection()] + if self.copyTranslationChk.GetValue() == 1: + config["settings"]["CopyTranslatedText"] = "true" + else: + config["settings"]["CopyTranslatedText"] = "false" config.write() def getDictKey (self, currentValue): https://bitbucket.org/nvdaaddonteam/instanttranslate/commits/0ba211765843/ Changeset: 0ba211765843 Branch: master User: beqa Date: 2013-05-14 22:04:43 Summary: store config file in the settings root. Affected #: 2 files diff --git a/addon/globalPlugins/instantTranslate/__init__.py b/addon/globalPlugins/instantTranslate/__init__.py index 98d48ea..c1f872d 100644 --- a/addon/globalPlugins/instantTranslate/__init__.py +++ b/addon/globalPlugins/instantTranslate/__init__.py @@ -32,7 +32,7 @@ from interface import * import addonHandler addonHandler.initTranslation() -config_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'instantTranslate.ini') +config_file = os.path.join(config.getUserDefaultConfigPath(),"instantTranslate.ini") charslimit=1500 lo_lang = getdefaultlocale () # get a language of the OS localization. s = lo_lang[0] # get the first element of the tuplet. diff --git a/addon/globalPlugins/instantTranslate/interface.py b/addon/globalPlugins/instantTranslate/interface.py index fb7cf91..da8a3fe 100644 --- a/addon/globalPlugins/instantTranslate/interface.py +++ b/addon/globalPlugins/instantTranslate/interface.py @@ -15,7 +15,7 @@ from configobj import * import addonHandler addonHandler.initTranslation() -config_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'instantTranslate.ini') +config_file = os.path.join(config.getUserDefaultConfigPath(),"instantTranslate.ini") class InstantTranslateSettingsDialog(gui.SettingsDialog): # Translators: name of the dialog. Repository URL: https://bitbucket.org/nvdaaddonteam/instanttranslate/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. ---------------------------------------------------------------- NVDA add-ons Central: A list for discussing NVDA add-ons To post a message, send an email to nvda-addons@xxxxxxxxxxxxx. To unsubscribe, send an email with the subject line of "unsubscribe" (without quotes) to nvda-addons-request@xxxxxxxxxxxxx. If you have questions for list moderators, please send a message to nvda-addons-moderators@xxxxxxxxxxxxx.