Integrate with Native Messaging (Python/Browser)
masterThe translateLocally NativeMessaging interface allows integration with browser extensions (Firefox/Chrome) or other applications using JSON-formatted messages over stdin/stdout.
Key Constraints:
- Incoming message limit: 10MB (matches Firefox limits).
- Response limit: ~4GB.
Using with Python:
Start translateLocally as a subprocess using the -p option. Pass JSON messages to its stdin. For a complete implementation, refer to the scripts/native_client.py example which demonstrates an async Python API.
Using with Browser Extensions:
- Firefox:
translateLocallyautomatically registers with Firefox when run in GUI mode. Install the Firefox translation addon and select "translateLocally" as the provider. - Chrome: Functionality is automatically available.
- Custom Extensions: To develop your own, you must add your extension ID to
src/constants.hin the source code and rebuildtranslateLocallybefore it will accept messages from your extension.
# Start in subprocess mode for Native Messaging
./translateLocally -p