Skip to main content

Define multiple platform (OS) specific translations in a single steno outline.

Project description

Plover Platform Specific Translation

Build Status PyPI - Version PyPI - Downloads linting: pylint

This Plover extension plugin contains a meta that allows you to specify different outline translation values depending on what operating system (platform) you are using.

This can be helpful in times where if you use the same dictionaries with Plover across, say, Windows and macOS, and want to have a single outline for "copy" to translate as Control-C on Windows, but Command-C on macOS.

Install

Pre-Plover Plugin Registry inclusion (Current)

git clone git@github.com:paulfioravanti/plover-platform-specific-translation.git
cd plover-platform-specific-translation
plover --script plover_plugins install --editable .

Where plover in the command is a reference to your locally installed version of Plover. See the Invoke Plover from the command line page for details on how to create that reference.

Then:

  1. When it finishes installing, restart Plover
  2. After re-opening Plover, open the Configuration screen (either click the Configuration icon, or from the main Plover application menu, select Preferences...)
  3. Open the Plugins tab
  4. Check the box next to plover_platform_specific_translation to activate the plugin

Post-Plover Plugin Registry inclusion (Future)

  1. In the Plover application, open the Plugins Manager (either click the Plugins Manager icon, or from the Tools menu, select Plugins Manager).
  2. From the list of plugins, find plover-platform-specific-translation
  3. Click "Install/Update"
  4. When it finishes installing, restart Plover
  5. After re-opening Plover, open the Configuration screen (either click the Configuration icon, or from the main Plover application menu, select Preferences...)
  6. Open the Plugins tab
  7. Check the box next to plover_platform_specific_translation to activate the plugin

How To Use

Using the example of an outline for "copy", here are the different ways you can create a platform-specific translation in your steno dictionaries.

Specify a translation for all possible (and unknown) platforms:

"KP*EU": "{:PLATFORM:WINDOWS:#CONTROL(C):MAC:#SUPER(C):LINUX:#CONTROL(C):OTHER:#CONTROL(C)}"

Specify a translation for only some platforms, and provide a default fallback translation for any other platform:

"KP*EU": "{:PLATFORM:MAC:#SUPER(C):OTHER:#CONTROL(C)}"

Specify a translation for only some platforms, but without a fallback for other platforms (will show an error if current platform is not found, but if you are confident you know what platforms you work with, this should be fine):

"KP*EU": "{:PLATFORM:WINDOWS:#CONTROL(C):MAC:#SUPER(C)}"

Specify only a default fallback for other platforms (pointless, but supported):

"KP*EU": "{:PLATFORM:OTHER:#CONTROL(C)}"

Note that the translation values are not limited to keyboard shortcuts, but can contain any text to be output:

"H-L": "{:PLATFORM:WINDOWS:Hello:MAC:Hi:LINUX:Good day:OTHER:Whassup}"

Configuration

When a platform-specific translation is successfully determined from an outline, the result is stored in the local Plover configuration directory on your machine in a file called platform_specific_translation.json. This is done in order to prevent determination actions from being done multiple times for the same outline, and hence speed up lookups for already known translations.

You should not need to manually add any entries to the configuration, but if you find any obsolete entries, feel free to delete them.

Technical Details

The heart of this plugin is essentially Python's platform.system() function, which will tell you what operating system you are running Plover on. It will return one of the following values:

  • "Windows"
  • "Darwin" (macOS)
  • "Linux"
  • "Java" (this looks like a value for potentially deprecated Jython environments, in which Plover will very likely never run in, so it is not supported in this plugin)
  • "" (unknown platform)

When the extension starts, the value returned from platform.system() gets cached to avoid checking it every time an outline is stroked.

All the platform-specific translations also get cached, so subsequent stroking of outlines that contain them should feel snappier than the first time they are used.

Pressing the "Disconnect and reconnect the machine" button on the Plover UI resets the translation cache. If you make any changes to a specific platform-specific translation in an outline, make sure to press it so it can be re-read in again properly.

Development

Clone from GitHub with git:

git clone git@github.com:paulfioravanti/plover-platform-specific-translation.git
cd plover-platform-specific-translation

Python Version

Plover's Python environment currently uses version 3.9 (see Plover's workflow_context.yml to confirm the current version).

So, in order to avoid unexpected issues, use your runtime version manager to make sure your local development environment also uses Python 3.9.x.

Testing

  • Pytest is used for testing in this plugin.
  • Coverage.py and pytest-cov are used for test coverage, and to run coverage within Pytest
  • Pylint is used for code quality
  • Mypy is used for static type checking

Currently, the only parts able to be tested are ones that do not rely directly on Plover.

Run tests, coverage, and linting with the following commands:

pytest --cov --cov-report=term-missing
pylint plover_local_env_var
mypy plover_local_env_var

To get a HTML test coverage report:

coverage run --module pytest
coverage html
open htmlcov/index.html

Deploying Changes

After making any code changes, deploy the plugin into Plover with the following command:

plover --script plover_plugins install --editable .

Where plover in the command is a reference to your locally installed version of Plover. See the Invoke Plover from the command line page for details on how to create that reference.

When necessary, the plugin can be uninstalled via the command line with the following command:

plover --script plover_plugins uninstall plover-platform-specific-translation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file plover_platform_specific_translation-0.1.1.tar.gz.

File metadata

File hashes

Hashes for plover_platform_specific_translation-0.1.1.tar.gz
Algorithm Hash digest
SHA256 82a3da97598e131547c44adc30d3c2c76f9018c2438f955daa05ae47b4869cd8
MD5 b1dcf0ecde84df20c60e494dc547cd2c
BLAKE2b-256 5bfaa7d0443868e1ce6b90a1f39f8e362cc5468ca54b2165acca035378ceef49

See more details on using hashes here.

File details

Details for the file plover_platform_specific_translation-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for plover_platform_specific_translation-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 35d60bfae90e3b8dc1ee1bf5e179e1aec6d74080a6ea5be06fdb34973adf40bf
MD5 3c6eb901d81e839017ba047cbedcfd7b
BLAKE2b-256 1fb854f023bdf8ab6c615fa28baa4d7cd2b9d0be0c4609813861673dc1da12fd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page