Implemented Translator for LibreTranslate#739
Conversation
|
@dotnet-policy-service agree |
There was a problem hiding this comment.
Pull request overview
This PR implements a new translator for LibreTranslate, a free and open-source machine translation API that can be self-hosted. The implementation adds support for translating resources using either a local LibreTranslate instance or a remote one, with optional API key authentication.
Changes:
- Added
LibreTranslateTranslatorclass following the established translator patterns in the codebase - Included comprehensive unit and integration tests for the new translator
- Added XAML configuration files for UI integration
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ResXManager.Translators/LibreTranslateTranslator.cs | Core translator implementation with API integration, request/response models, and translation logic |
| src/ResXManager.Translators/LibreTranslateTranslatorConfiguration.xaml | UI configuration view (minimal, as no additional configuration is needed beyond credentials) |
| src/ResXManager.Translators/LibreTranslateTranslatorConfiguration.xaml.cs | Code-behind for configuration UI |
| src/ResXManager.Tests/Model/LibreTranslateTranslatorTests.cs | Comprehensive test suite including unit tests for response parsing and optional integration tests |
| src/ResXManager.Tests/Model/TranslatorTests.cs | Minor formatting adjustments to existing test strings (unrelated to LibreTranslate implementation) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The API offers the function to provide alternative translations, so it would make sense to offer this to the user as well.
| /// <summary> | ||
| /// The default URI of the LibreTranslate instance. | ||
| /// </summary> | ||
| private static readonly Uri _uri = new("http://localhost:5000/"); |
There was a problem hiding this comment.
The URL passed to the base class in the constructor is not the API url, but the link to the home page of the translator showing the instructions how to use it
There was a problem hiding this comment.
In this case I would point it to the GitHub repo
There was a problem hiding this comment.
Oh okay, I'll change it :)
I recently discovered LibreTranslate and thought it would be great to support it.
LibreTranslate can be run on your own computer and has an API.
See also: