Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
0de4126
refactor: rename module to gopkg.gilang.dev/translator
gilang-as Feb 2, 2026
f399f19
refactor: rename api to gtranslate and add context support
gilang-as Feb 2, 2026
e851c0b
feat: add GoogleTranslate client with configurable options
gilang-as Feb 2, 2026
c30c5ba
refactor: move GoogleTranslate to separate package with concurrency s…
gilang-as Feb 2, 2026
324d918
test: add benchmark tests for googletranslate package
gilang-as Feb 2, 2026
f1f8cfe
feat: add DeepL support and multi-translator architecture
gilang-as Feb 2, 2026
7d0d591
refactor: standardize package structure and dependencies
gilang-as Feb 2, 2026
270ec96
ci: update GitHub Actions workflow
gilang-as Feb 2, 2026
c1047fe
docs: add benchmark results to README
gilang-as Feb 2, 2026
8e706f2
docs: add note for legacy v1 package users
gilang-as Feb 2, 2026
993db4b
Update readme.md
gilang-as Feb 2, 2026
e57a325
Update README.md
gilang-as Feb 2, 2026
619cb36
Update README.md
gilang-as Feb 2, 2026
b41cece
chore: align v2 module references
gilang-as Feb 2, 2026
194f91b
Initial plan
Copilot Feb 2, 2026
7e2e1a3
Initial plan
Copilot Feb 2, 2026
74a0eab
Initial plan
Copilot Feb 2, 2026
3fa7a44
Initial plan
Copilot Feb 2, 2026
d3748f8
Initial plan
Copilot Feb 2, 2026
e9b0334
Initial plan
Copilot Feb 2, 2026
d8d9f5a
Initial plan
Copilot Feb 2, 2026
ac27282
fix: correct typo in error messages (is't → isn't)
Copilot Feb 2, 2026
6bf5f38
Merge pull request #6 from gilang-as/copilot/sub-pr-5
gilang-as Feb 2, 2026
331208b
fix: correct typo "is't" to "isn't" in error messages
Copilot Feb 2, 2026
994e271
Merge pull request #13 from gilang-as/copilot/sub-pr-5-fad05c0b-b8e9-…
gilang-as Feb 2, 2026
cfc26d9
fix: correct typo "is't" to "isn't" in error messages
Copilot Feb 2, 2026
7f98e3b
Merge pull request #12 from gilang-as/copilot/sub-pr-5-3f94ec7d-147c-…
gilang-as Feb 2, 2026
97372ea
fix: replace b.Loop() with standard for loop in benchmarks
Copilot Feb 2, 2026
1786ea6
Update progress - all tasks complete
Copilot Feb 2, 2026
ed2bfc8
Update progress
Copilot Feb 2, 2026
b147922
Merge pull request #9 from gilang-as/copilot/sub-pr-5-yet-again
gilang-as Feb 2, 2026
03d960a
Merge pull request #8 from gilang-as/copilot/sub-pr-5-another-one
gilang-as Feb 2, 2026
65d61ae
Merge pull request #7 from gilang-as/copilot/sub-pr-5-again
gilang-as Feb 2, 2026
c3ec3d7
fix: correct typo in error messages - "is't" → "isn't"
Copilot Feb 2, 2026
801bba1
Update progress - all tasks completed
Copilot Feb 2, 2026
47084e7
Merge pull request #10 from gilang-as/copilot/sub-pr-5-one-more-time
gilang-as Feb 2, 2026
47e5631
Initial plan
Copilot Feb 2, 2026
e498e19
Initial plan
Copilot Feb 2, 2026
670cf88
fix: pass context through DeepL translation chain for proper cancella…
Copilot Feb 2, 2026
557cde3
Merge pull request #14 from gilang-as/copilot/sub-pr-5-7498da45-26e9-…
gilang-as Feb 2, 2026
f73bbb2
fix: use configured HTTP client in DeepL translator
Copilot Feb 2, 2026
a5860b3
fix: use NewClient to avoid shared req.Client instance
Copilot Feb 2, 2026
70e8b34
fix: copy additional HTTP client fields (CheckRedirect, Jar)
Copilot Feb 2, 2026
f418e07
docs: fix comment to reflect actual HTTP client fields copied
Copilot Feb 2, 2026
8237f1f
Merge branch 'feat/multi-translator-support' into copilot/sub-pr-5-80…
gilang-as Feb 2, 2026
b2b9489
Update deepl/translate.go
gilang-as Feb 2, 2026
ef66a7c
Update deepl/translate.go
gilang-as Feb 2, 2026
4cb6813
Update deepl/translate.go
gilang-as Feb 2, 2026
680b7aa
Update deepl/translate.go
gilang-as Feb 2, 2026
9185746
Merge pull request #15 from gilang-as/copilot/sub-pr-5-80ec5ee1-7a7e-…
gilang-as Feb 2, 2026
f616d11
ci: expand Go matrix and checks
gilang-as Feb 2, 2026
8f14d42
chore: gofmt
gilang-as Feb 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 49 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,59 @@ on:
branches: [ main ]

jobs:
build:
test:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.21', '1.22', '1.23', '1.24', '1.25']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: 1.25
go-version: ${{ matrix.go-version }}
cache: true

- name: Verify gofmt
run: test -z "$(gofmt -l .)"

- name: Vet
run: go vet ./...

- name: Tidy check
if: matrix.go-version == '1.25'
run: |
go mod tidy
git diff --exit-code

- name: Build
run: go build -v ./...

- name: Test
run: go test -v -run TestTranslator
run: go test -v ./...

- name: Race
if: matrix.go-version == '1.25'
run: go test -race ./...

- name: Govulncheck
if: matrix.go-version == '1.25'
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...

benchmark:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true

- name: Run Benchmarks
run: go test -bench=BenchmarkNew -benchmem ./...
185 changes: 0 additions & 185 deletions .idea/workspace.xml

This file was deleted.

90 changes: 90 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# CLAUDE.md

## Project

Go library for translation API wrapper supporting multiple backends (Google Translate, DeepL). Module: `gopkg.gilang.dev/translator/v2`

## Commands

```bash
go test -v ./... # Run tests
go test -bench=. ./... # Run benchmarks
go mod tidy # Tidy dependencies
```

## Structure

- `translate.go` - Public API with multi-translator support
- `googletranslate/` - Google Translate client (concurrency-safe)
- `deepl/` - DeepL client (concurrency-safe)
- `params/` - Parameter structs and language definitions
- `example/` - Usage examples

## API

### Package-level functions (use default translator)

```go
gt.Translate(ctx, text, toLanguage) // Auto-detect source
gt.TranslateWithParam(ctx, params.Translate{Text, From, To}) // Struct-based
gt.ManualTranslate(ctx, text, fromLanguage, toLanguage) // Explicit languages
```

### Switch default translator

```go
gt.UseGoogle() // Use Google (default)
gt.UseDeepL() // Use DeepL
gt.UseGoogle(googletranslate.WithHost("...")) // With options
gt.UseDeepL(deepl.WithDLSession("...")) // With options
```

### Use specific translator

```go
google := gt.NewGoogleTranslator(opts...)
deepl := gt.NewDeepLTranslator(opts...)
gt.TranslateWith(ctx, google, text, toLanguage)
```

### Google Translate client

```go
import "gopkg.gilang.dev/translator/v2/googletranslate"

client := googletranslate.New(
googletranslate.WithHost("google.co.id"),
googletranslate.WithHTTPClient(&http.Client{Timeout: 30*time.Second}),
googletranslate.WithProxyURL("http://proxy:8080"),
)
client.Translate(ctx, text, from, to)

// Runtime configuration (concurrency-safe)
client.SetHost("google.com")
client.SetProxyURL("http://proxy:8080")
```

### DeepL client

```go
import "gopkg.gilang.dev/translator/v2/deepl"

client := deepl.New(
deepl.WithProxyURL("http://proxy:8080"),
deepl.WithDLSession("session-token"), // For Pro features
)
client.Translate(ctx, text, from, to)

// Runtime configuration (concurrency-safe)
client.SetProxyURL("http://proxy:8080")
client.SetDLSession("new-session")
```

## Conventions

- Package imported as `gt`
- Language codes: ISO 639-1 (e.g., "en", "fr", "id")
- Use `"auto"` for automatic language detection
- All functions require `context.Context` as first parameter
- Both clients are concurrency-safe with mutex protection
- DeepL may rate limit requests; handle errors appropriately
Loading
Loading