Claude ICU i18n Translator
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-translatorRequires 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 coverageLicense
MIT
From the README.md of EugeneErg/claude-icu-i18n-translator · composer require eugene-erg/claude-icu-i18n-translator