Skip to content

Commit

Permalink
In keyboard help for emulated system keyboard keys, the translated ve…
Browse files Browse the repository at this point in the history
…rsion of a key is now spoken instead of the raw, untranslated version. Also, the script name for emulated system keyboard keys is now localized

Both changes are based on a new simple function called getKeyCombinationLabel in keyLabels in which you insert a raw key combination string, which is than converted to a localised key combination identifier. (Re nvaccess#6212)
  • Loading branch information
Leonard de Ruijter committed Sep 8, 2016
1 parent 624c018 commit d6da5ac
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions source/inputCore.py
Expand Up @@ -2,7 +2,7 @@
#A part of NonVisual Desktop Access (NVDA)
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.
#Copyright (C) 2010 James Teh <jamie@jantrid.net>
#Copyright (C) 2010-2016 NV Access Limited, Babbage B.V.

"""Core framework for handling input from the user.
Every piece of input from the user (e.g. a key press) is represented by an L{InputGesture}.
Expand All @@ -28,6 +28,7 @@
import globalVars
import languageHandler
import controlTypes
import keyLabels

#: Script category for emulated keyboard keys.
# Translators: The name of a category of NVDA commands.
Expand Down Expand Up @@ -613,7 +614,7 @@ def addGlobalMap(self, gmap):
def makeKbEmuScriptInfo(self, cls, scriptName):
info = AllGesturesScriptInfo(cls, scriptName)
info.category = SCRCAT_KBEMU
info.displayName = scriptName[3:]
info.displayName = keyLabels.getKeyCombinationLabel(scriptName[3:])
return info

def makeNormalScriptInfo(self, cls, scriptName, script):
Expand Down
5 changes: 4 additions & 1 deletion source/keyLabels.py
Expand Up @@ -2,7 +2,7 @@
#A part of NonVisual Desktop Access (NVDA)
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.
#Copyright (C) 2008-2010 James Teh <jamie@jantrid.net>, Aleksey Sadovoy <lex@onm.su>
#Copyright (C) 2008-2016 NV Access Limited, Aleksey Sadovoy, Babbage B.v.

localizedKeyLabels = {
# Translators: This is the name of the back key found on multimedia keyboards for controlling the web-browser.
Expand Down Expand Up @@ -162,3 +162,6 @@
# Translators: This is the name of a key on the keyboard.
'tab': pgettext("keyLabel", "tab"),
}

def getKeyCombinationLabel(keyCombination):
return "+".join(localizedKeyLabels[key.lower()] for key in keyCombination.split("+"))
5 changes: 3 additions & 2 deletions source/scriptHandler.py
@@ -1,6 +1,6 @@
#scriptHandler.py
#A part of NonVisual Desktop Access (NVDA)
#Copyright (C) 2006-2008 NVDA Contributors <http://www.nvda-project.org/>
#Copyright (C) 2006-2016 NVDA Contributors <http://www.nvda-project.org/>
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.

Expand All @@ -17,6 +17,7 @@
import inputCore
import globalPluginHandler
import braille
import keyLabels

_numScriptsQueued=0 #Number of scripts that are queued to be executed
#: Number of scripts that send their gestures on that are queued to be executed or are currently being executed.
Expand All @@ -35,7 +36,7 @@ def _makeKbEmulateScript(scriptName):
# __name__ must be str; i.e. can't be unicode.
scriptName = scriptName.encode("mbcs")
func.__name__ = "script_%s" % scriptName
func.__doc__ = _("Emulates pressing %s on the system keyboard") % keyName
func.__doc__ = _("Emulates pressing %s on the system keyboard") % keyLabels.getKeyCombinationLabel(keyName)
return func

def _getObjScript(obj, gesture, globalMapScripts):
Expand Down

0 comments on commit d6da5ac

Please sign in to comment.