瀏覽代碼

Version 1.0

Ernesto Blanco 6 年之前
父節點
當前提交
ddb42d3d7c
共有 8 個文件被更改,包括 131 次插入0 次删除
  1. 2 0
      .gitignore
  2. 50 0
      globalPlugins/defineSelectedWord.py
  3. 33 0
      locale/en/LC_MESSAGES/nvda.po
  4. 二進制
      locale/es/LC_MESSAGES/nvda.mo
  5. 34 0
      locale/es/LC_MESSAGES/nvda.po
  6. 3 0
      locale/es/manifest.ini
  7. 9 0
      manifest.ini
  8. 二進制
      wordDefinition.nvda-addon

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+*.pyo
+potfiles.sh

+ 50 - 0
globalPlugins/defineSelectedWord.py

@@ -0,0 +1,50 @@
+import urllib
+import json
+import globalPluginHandler
+import scriptHandler
+import api
+import textInfos
+from ui import message, browseableMessage
+import addonHandler
+addonHandler.initTranslation()
+
+class GlobalPlugin(globalPluginHandler.GlobalPlugin):
+    def define(self, word, lang='es'):
+        link='https://googledictionaryapi.eu-gb.mybluemix.net/?define='+word+'&lang='+lang
+        output=''
+        f = urllib.urlopen(link)
+        myfile = f.read().decode("utf-8")
+        jsonDict=json.loads(myfile)
+        meaning=jsonDict[0]['meaning']
+        for k, v in meaning.items():
+            if k!=u'':
+                output+=k
+            for d in v['definitions']:
+                if d['definition']!=u'':
+                    output+='\n'+d['definition']
+        return output
+
+    def script_defineSelectedWord(self,gesture):
+        obj = api.getFocusObject()
+        treeInterceptor = obj.treeInterceptor
+        if hasattr(treeInterceptor,'TextInfo') and not treeInterceptor.passThrough:
+            obj = treeInterceptor
+        try:
+            info = obj.makeTextInfo(textInfos.POSITION_SELECTION)
+        except (RuntimeError, NotImplementedError):
+            info = None
+        if not info or info.isCollapsed:
+            # TRANSLATORS: Error message when there aren't any selected word
+            message(_("Please select some word first."))
+        else:
+            browseableMessage(self.define(info.text.encode("utf-8")))
+
+    # TRANSLATORS: Script __doc__
+    script_defineSelectedWord.__doc__ = _("Defines selected word.")
+
+    # TRANSLATORS: Script category
+    script_defineSelectedWord.category = _("Text editing")
+
+    __gestures = {
+        "kb:control+shift+f11": "defineSelectedWord",
+    }

+ 33 - 0
locale/en/LC_MESSAGES/nvda.po

@@ -0,0 +1,33 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR All rights reserved
+# This file is distributed under the same license as the wordDefinition package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: wordDefinition 1.0\n"
+"Report-Msgid-Bugs-To: mail@ernestoblanco.mx\n"
+"POT-Creation-Date: 2019-12-09 09:57+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. TRANSLATORS: Error message when there aren't any selected word
+#: globalPlugins/defineSelectedWord.py:38
+msgid "Please select some word first."
+msgstr ""
+
+#. TRANSLATORS: Script __doc__
+#: globalPlugins/defineSelectedWord.py:43
+msgid "Defines selected word."
+msgstr ""
+
+#. TRANSLATORS: Script category
+#: globalPlugins/defineSelectedWord.py:46
+msgid "Text editing"
+msgstr ""

二進制
locale/es/LC_MESSAGES/nvda.mo


+ 34 - 0
locale/es/LC_MESSAGES/nvda.po

@@ -0,0 +1,34 @@
+# Word definition NVDA addon
+# Copyright (C) 2019, by Ernesto Blanco. All rights reserved
+# This file is distributed under the same license as the wordDefinition package.
+# Ernesto Blanco <mail@ernestoblanco.mx>, 2019.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: wordDefinition 1.0\n"
+"Report-Msgid-Bugs-To: mail@ernestoblanco.mx\n"
+"POT-Creation-Date: 2019-12-09 09:57+0100\n"
+"PO-Revision-Date: 2019-12-09 10:05+0100\n"
+"Language: es\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Last-Translator: Ernesto Blanco <mail@ernestoblanco.mx>\n"
+"Language-Team: Ernesto Blanco\n"
+"X-Generator: Poedit 2.2.4\n"
+"X-Poedit-SourceCharset: UTF-8\n"
+
+#. TRANSLATORS: Error message when there aren't any selected word
+#: globalPlugins/defineSelectedWord.py:38
+msgid "Please select some word first."
+msgstr "Por favor, seleccione una palabra primero."
+
+#. TRANSLATORS: Script __doc__
+#: globalPlugins/defineSelectedWord.py:43
+msgid "Defines selected word."
+msgstr "Define la palabra seleccionada."
+
+#. TRANSLATORS: Script category
+#: globalPlugins/defineSelectedWord.py:46
+msgid "Text editing"
+msgstr "Edición de texto"

+ 3 - 0
locale/es/manifest.ini

@@ -0,0 +1,3 @@
+name = wordDefinition
+summary = Define la palabra seleccionada
+description = Muestra un diálogo navegable con definiciones cuando selecciona una palabra y pulsa CTRL+Shift+F11."

+ 9 - 0
manifest.ini

@@ -0,0 +1,9 @@
+name = wordDefinition
+summary = Define any selected word"
+description = "Show a browseable dialog with definitions when you select some word and press Control+Shift+F11."
+author = "Ernesto Blanco <mail@ernestoblanco.mx>"
+url = https://github.com/bc_ernesto/wordDefinition
+version = 1.0
+minimumNVDAVersion = 2017.2.0
+lastTestedNVDAVersion = 2019.2.1
+updateChannel = None

二進制
wordDefinition.nvda-addon