Skip to main content

A flexible macOS utility that retroactively fixes text typed in the wrong keyboard layout with support for multiple languages

Project description

Language Fixer

A flexible macOS utility that retroactively fixes text typed in the wrong keyboard layout. Supports multiple language pairs with configurable hotkeys.

Features

  • Multiple Language Support: Hebrew, Arabic, Russian, or create your own
  • Configurable Hotkeys: Each language pair can have its own hotkey
  • Toggle-Back: Press hotkey again to revert the conversion
  • Smart Detection: Automatically detects the source language
  • Seamless Integration: Runs quietly in the background
  • Configurable Buffer: Adjust how long typed text is remembered
  • RTL Support: Properly handles right-to-left text

Requirements

  • macOS (tested on macOS 10.14+)
  • Python 3.12+

Installation

Option 1: Install from PyPI (Recommended)

One-command installation:

pipx install language-fixer

Or with pip:

pip install language-fixer

Setup as background service:

language-fixer-install-service

Grant accessibility permissions:

  • Go to System Preferences → Security & Privacy → Privacy → Accessibility
  • Add Terminal (or your terminal app) to the list of allowed apps
  • This is required for the keyboard listener to work

Option 2: Install from Source

  1. Clone the repository:

    git clone https://github.com/yourusername/language-fixer.git
    cd language-fixer
    
  2. Install with uv:

    uv sync
    
  3. Grant accessibility permissions (same as above)

  4. Install as service (optional):

    ./scripts/install.sh
    

Quick Start

Default Mode (Hebrew-English)

uv run python -m language_fixer

Press Cmd+Shift+H to convert between Hebrew and English.

With Configuration

  1. Copy the example config:

    cp config.example.yaml config.yaml
    
  2. Edit config.yaml to enable/disable language pairs and customize hotkeys

  3. Run:

    uv run python -m language_fixer
    

Configuration

Create a config.yaml file in the project root to customize behavior:

# Buffer timeout in seconds
buffer_timeout: 10.0

# Language pairs
language_pairs:
  - name: "Hebrew-English"
    mapping_file: "mappings/hebrew-english.json"
    hotkey: "cmd+shift+h"
    enabled: true

  - name: "Arabic-English"
    mapping_file: "mappings/arabic-english.json"
    hotkey: "cmd+shift+a"
    enabled: true

  - name: "Russian-English"
    mapping_file: "mappings/russian-english.json"
    hotkey: "cmd+shift+r"
    enabled: true

Built-in Language Mappings

  • Hebrew-English: mappings/hebrew-english.json
  • Arabic-English: mappings/arabic-english.json
  • Russian-English: mappings/russian-english.json

Creating Custom Language Mappings

Use the built-in mapping generator:

uv run language-fixer-generate-mapping

The tool will:

  1. Ask for language pair details
  2. Guide you through mapping each key
  3. Save the mapping file in the mappings/ directory
  4. Show you how to add it to your config

Usage Examples

Basic Usage

  1. Type text in wrong language: akuo (meant to type שלום)
  2. Press Cmd+Shift+H
  3. Text converts to: שלום

Toggle Back

  1. Type: hello → Press Cmd+Shift+H → Converts to: יקךךם
  2. Press Cmd+Shift+H again (immediately) → Reverts to: hello

Multiple Languages

With config enabled for multiple languages:

  • Cmd+Shift+H for Hebrew-English
  • Cmd+Shift+A for Arabic-English
  • Cmd+Shift+R for Russian-English

Running as Background Service

To have Language Fixer start automatically when you log in, use the provided management scripts:

Install as Service

./scripts/install.sh

Management Commands

# Check if running
./scripts/is_running.sh

# View logs
./scripts/view_logs.sh
./scripts/view_logs.sh -f    # Follow logs in real-time

# Restart service
./scripts/restart.sh

# Uninstall service
./scripts/uninstall.sh

Manual Service Control

# Stop the service
launchctl unload ~/Library/LaunchAgents/com.languagefixer.plist

# Start the service
launchctl load ~/Library/LaunchAgents/com.languagefixer.plist

How It Works

Language Fixer monitors your keyboard input and maintains a buffer of recently typed characters. When you press a hotkey:

  1. Detects the source language of the buffered text
  2. Maps each character to its equivalent on the target keyboard layout
  3. Deletes the original text
  4. Pastes the converted text

The conversion is based on physical keyboard positions, so each key maps to its equivalent character in the other language.

Uninstallation

  1. Stop and remove the LaunchAgent (if installed):

    launchctl unload ~/Library/LaunchAgents/com.languagefixer.plist
    rm ~/Library/LaunchAgents/com.languagefixer.plist
    
  2. Remove the project:

    cd ..
    rm -rf language-fixer
    

Development

Running tests

uv run pytest

Project structure

language-fixer/
├── src/language_fixer/
│   ├── __init__.py
│   ├── __main__.py           # Entry point
│   ├── config.py             # Configuration management
│   ├── converter.py          # Text conversion logic
│   ├── listener.py           # Keyboard listener
│   └── generate_mapping.py   # Mapping generator tool
├── mappings/
│   ├── hebrew-english.json
│   ├── arabic-english.json
│   └── russian-english.json
├── scripts/
│   ├── install.sh            # Install as service
│   ├── uninstall.sh          # Uninstall service
│   ├── restart.sh            # Restart service
│   ├── is_running.sh         # Check status
│   └── view_logs.sh          # View logs
├── tests/
│   └── test_converter.py
├── config.example.yaml
├── pyproject.toml
└── README.md

License

MIT License - see LICENSE file for details

Troubleshooting

The hotkey doesn't work:

  • Make sure you've granted Accessibility permissions to your terminal app
  • Try restarting the application
  • Check that your hotkey doesn't conflict with other apps

Text isn't converting correctly:

  • The buffer has a timeout (default 10 seconds) - press the hotkey within this window
  • The converter works on buffered text only - if you've pressed Enter, Tab, or arrow keys, the buffer is cleared

Service won't start:

  • Check the error logs: cat /tmp/languagefixer.err
  • Make sure uv is installed and in your PATH
  • Verify the paths in ~/Library/LaunchAgents/com.languagefixer.plist are correct

Config file errors:

  • Make sure PyYAML is installed: uv sync
  • Check your config.yaml syntax is valid YAML
  • Verify mapping file paths are correct and files exist

Custom mapping not working:

  • Ensure the mapping file is valid JSON
  • Check that the mapping file path in config.yaml is correct
  • Make sure the language pair is enabled in config

Contributing

Contributions are welcome! Feel free to:

  • Add new language mappings
  • Report bugs
  • Suggest features
  • Submit pull requests

Roadmap

Future improvements:

  • Visual feedback when conversion happens
  • App-specific exclusions
  • Smart word boundary detection
  • Additional platform support

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

language_fixer-0.2.1.tar.gz (31.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

language_fixer-0.2.1-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file language_fixer-0.2.1.tar.gz.

File metadata

  • Download URL: language_fixer-0.2.1.tar.gz
  • Upload date:
  • Size: 31.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for language_fixer-0.2.1.tar.gz
Algorithm Hash digest
SHA256 de910ce9d3778d04904f4bf23d9cfcc1d37f8b0e3e8cf15174fd3a2f58745036
MD5 49332373c11dde8f3eb3582bfb23c7ab
BLAKE2b-256 7a9a3816fd9018f7d688aaf4c812e63abbc93b4544ef15c67e1ea4c0132e6711

See more details on using hashes here.

File details

Details for the file language_fixer-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: language_fixer-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for language_fixer-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f3cec10c85fde49a5bdf9c125bfcbceffd0be7cfccb5dbf3f93ff3fb70ae6c62
MD5 d2c0bfa82217d476f5f2a0b8fa140d1f
BLAKE2b-256 f3ab24d865957ff87fde93068b503e23aede5269568bd8d67c747726d5594552

See more details on using hashes here.

Supported by

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