feat: add detect_language and get_languages functions#1
Conversation
- Add `detect_language` for single and multiple texts using the translate endpoint - Add `get_languages` to list supported source/target languages via GET request - Add `get_request` HTTP helper and `AUTH_HEADERS` constant - Update README with documentation and usage examples - Add CLAUDE.md with project conventions - Add tests for new functions - Bump version to 0.3.0
There was a problem hiding this comment.
Pull request overview
Adds new public API surface to the DeepL.jl SDK for language detection and language listing, plus supporting HTTP helper(s) and documentation updates.
Changes:
- Add
detect_language(single and vector overloads) implemented via the/translateendpoint. - Add
get_languagesimplemented via a newget_requesthelper for/languages. - Update exports, tests, README, changelog, and add
CLAUDE.mdconventions doc.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/detect.jl |
New detect_language API (String + Vector dispatch) using /translate. |
src/languages.jl |
New get_languages API using /languages via GET. |
src/client.jl |
Add AUTH_HEADERS and get_request helper for GET calls. |
src/DeepL.jl |
Include new source files and export new public APIs. |
test/runtests.jl |
Add integration tests for detect_language and get_languages. |
README.md |
Document new functions and provide usage examples. |
CHANGELOG.md |
Document the 0.3.0 release additions. |
CLAUDE.md |
Add repository conventions / contributor reference. |
Project.toml |
Bump version to 0.3.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/languages.jl
Outdated
| response = get_request("/languages"; params=Dict("type" => type)) | ||
| error_message = handle_api_error(response) | ||
| if !isempty(error_message) | ||
| return error_message |
There was a problem hiding this comment.
get_languages returns error_message (a String) when the API request fails, but on success it returns a parsed JSON array (a Vector). This makes the function’s return type inconsistent with its docstring (Vector{Dict{String,Any}}) and will break callers that expect an iterable list. Consider keeping the return type consistent by throwing an exception on API errors (or returning an empty Vector plus logging) instead of returning a String.
| return error_message | |
| throw(ErrorException(error_message)) |
New features
detect_languagefor single and multiple texts using the translate endpointget_languagesto list supported source/target languages via GET requestget_requestHTTP helper andAUTH_HEADERSconstantChanges
Documentation