eugene-erg / claude-icu-i18n-translator
Claude translation provider for eugene-erg/icu-i18n-translator: the Anthropic API or the claude command-line tool
Package info
github.com/EugeneErg/claude-icu-i18n-translator
pkg:composer/eugene-erg/claude-icu-i18n-translator
Requires
- php: ^8.2
- ext-json: *
- eugene-erg/llm-icu-i18n-translator: ^1.0
Requires (Dev)
- laravel/pint: ^1.32
- nyholm/psr7: ^1.8
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.2
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.1
- phpstan/phpstan-strict-rules: ^2.1
- phpunit/phpunit: ^12.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-30 18:12:21 UTC
README
Claude as a translation provider for eugene-erg/icu-i18n-translator. The translation itself (prompts, batches, checks) lives in eugene-erg/llm-icu-i18n-translator; this package adds two ways to reach Claude:
| Transport | Signs in with | Structured output |
|---|---|---|
AnthropicApi |
an API key from the Claude Console | output_config.format |
ClaudeCode |
the claude tool's own sign-in |
--json-schema |
Installation
composer require eugene-erg/claude-icu-i18n-translator
Requires PHP 8.2+. AnthropicApi needs any PSR-18 HTTP client; ClaudeCode needs
Claude Code installed and signed in.
Anthropic API
use EugeneErg\ClaudeIcuI18nTranslator\AnthropicApi; use EugeneErg\LlmIcuI18nTranslator\Http\HttpJsonClient; use EugeneErg\LlmIcuI18nTranslator\LlmTranslator; $claude = new AnthropicApi( new HttpJsonClient($psr18Client, $requestFactory, $streamFactory), apiKey: getenv('ANTHROPIC_API_KEY'), model: 'claude-sonnet-5-5', // default maxTokens: 8192, // default options: ['temperature' => 0], ); $translator = new LlmTranslator($claude, instructions: 'Address the user informally.');
Rate limits (429) and overload (529) are retried by HttpJsonClient, honouring Retry-After.
Claude Code (claude -p)
use EugeneErg\ClaudeIcuI18nTranslator\ClaudeCode; $translator = new LlmTranslator(new ClaudeCode(model: 'sonnet', timeoutSeconds: 300));
The texts to translate come from your users and translators, so the run is locked down: no tools (--tools ""),
no MCP servers, no slash commands, no saved session, the translation rules as the whole system prompt, and the texts
through stdin. Without --bare, claude loads hooks and MCP servers of the directory it runs in, so it runs in an
empty directory of its own (/tmp/claude-icu-i18n-translator by default).
bare: true skips all local configuration, but then claude accepts only ANTHROPIC_API_KEY, not a subscription
sign-in. Whether a subscription may be used for your workload is governed by Anthropic's terms for your plan.
Development
composer check # pint --test, phpstan (level max, strict rules) and phpunit
composer coverage
License
MIT