Skip to content

Commit 0262814

Browse files
committed
docs: changes
1 parent 8f7decc commit 0262814

File tree

1 file changed

+43
-35
lines changed

1 file changed

+43
-35
lines changed

src/LingoDotDevEngine.php

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ class LingoDotDevEngine
9393
* Build an engine with your API key and optional batching limits.
9494
*
9595
* @param array<string, mixed> $config Configuration options:
96-
* - 'apiKey' (string, required): Your API token
97-
* - 'apiUrl' (string): API base URL (default: https://engine.lingo.dev)
98-
* - 'batchSize' (int): Records per request, 1-250 (default: 25)
99-
* - 'idealBatchItemSize' (int): Max words per request, 1-2500 (default: 250)
96+
* - 'apiKey' (string, required): Your API token
97+
* - 'apiUrl' (string): API base URL (default: https://engine.lingo.dev)
98+
* - 'batchSize' (int): Records per request, 1-250 (default: 25)
99+
* - 'idealBatchItemSize' (int): Max words per request, 1-2500 (default: 250)
100100
*
101101
* @example Configuration
102102
* ```php
@@ -163,7 +163,11 @@ public function __construct(array $config = [])
163163
* Localize content using the Lingo.dev API.
164164
*
165165
* @param array<string, mixed> $payload Content to translate, structured as key-value pairs
166-
* @param array<string, mixed> $params Translation configuration options
166+
* @param array<string, mixed> $params Translation configuration options:
167+
* - 'targetLocale' (string, required): Language code to translate into (e.g., 'es', 'fr')
168+
* - 'sourceLocale' (string|null): Language code of original text, null for auto-detection
169+
* - 'fast' (bool): Trade translation quality for speed
170+
* - 'reference' (array<string, mixed>|null): Context or glossary terms to guide translation
167171
* @param null|callable(int, mixed, mixed): void $progressCallback Callback invoked with completion percentage (0-100), current chunk, and processed chunk
168172
*
169173
* @return array<string, mixed> Translated content maintaining original structure
@@ -217,11 +221,13 @@ protected function localizeRaw(array $payload, array $params, ?callable $progres
217221
/**
218222
* Localize a single chunk of content.
219223
*
220-
* @param string|null $sourceLocale Language code of the original text (e.g., 'en', 'es'), null for auto-detection
221-
* @param string $targetLocale Language code to translate into (e.g., 'fr', 'de')
222-
* @param array<string, mixed> $payload Content chunk with optional reference data for context
223-
* @param string $workflowId Unique identifier for tracking related translation requests
224-
* @param bool $fast Enable faster translation at potential quality tradeoff
224+
* @param string|null $sourceLocale Language code of the original text (e.g., 'en', 'es'), null for auto-detection
225+
* @param string $targetLocale Language code to translate into (e.g., 'fr', 'de')
226+
* @param array<string, mixed> $payload Content chunk with optional reference data for context:
227+
* - 'data' (array<string, mixed>): Chunk data submitted for translation
228+
* - 'reference' (array<string, mixed>|null): Additional context for the translation request
229+
* @param string $workflowId Unique identifier for tracking related translation requests
230+
* @param bool $fast Enable faster translation at potential quality tradeoff
225231
*
226232
* @return array<string, mixed> Translated chunk maintaining original structure
227233
*
@@ -361,12 +367,12 @@ private function _createId(): string
361367
/**
362368
* Localize every string in a nested array while keeping its shape intact.
363369
*
364-
* @param array<string, mixed> $obj Nested data structure containing text to translate
365-
* @param array<string, mixed> $params Parameters:
366-
* - 'targetLocale' (string, required): Language code to translate into (e.g., 'es', 'fr')
367-
* - 'sourceLocale' (string|null): Language code of original text, null for auto-detection
368-
* - 'fast' (bool): Trade translation quality for speed
369-
* - 'reference' (array): Context or glossary terms to guide translation
370+
* @param array<string, mixed> $obj Nested data structure containing text to translate
371+
* @param array<string, mixed> $params Translation options controlling locale, speed, and contextual reference data:
372+
* - 'targetLocale' (string, required): Language code to translate into (e.g., 'es', 'fr')
373+
* - 'sourceLocale' (string|null): Language code of original text, null for auto-detection
374+
* - 'fast' (bool): Trade translation quality for speed
375+
* - 'reference' (array<string, mixed>|null): Context or glossary terms to guide translation
370376
* @param null|callable(int, mixed, mixed): void $progressCallback Invoked per batch with (percentage complete, current batch, translated batch)
371377
*
372378
* @return array<string, mixed> Translated data preserving original structure and non-text values
@@ -419,12 +425,12 @@ public function localizeObject(array $obj, array $params, ?callable $progressCal
419425
/**
420426
* Localize a single string and return the translated text.
421427
*
422-
* @param string $text Text content to translate
423-
* @param array<string, mixed> $params Parameters:
424-
* - 'targetLocale' (string, required): Language code to translate into (e.g., 'es', 'fr')
425-
* - 'sourceLocale' (string|null): Language code of original text, null for auto-detection
426-
* - 'fast' (bool): Prioritize speed over translation quality
427-
* - 'reference' (array): Context, terminology, or style guidelines for translation
428+
* @param string $text Text content to translate
429+
* @param array<string, mixed> $params Translation options such as locale hints, speed preference, and contextual references:
430+
* - 'targetLocale' (string, required): Language code to translate into (e.g., 'es', 'fr')
431+
* - 'sourceLocale' (string|null): Language code of original text, null for auto-detection
432+
* - 'fast' (bool): Trade translation quality for speed
433+
* - 'reference' (array<string, mixed>|null): Context, terminology, or style guidelines
428434
* @param null|callable(int): void $progressCallback Called with completion percentage (0-100) during processing
429435
*
430436
* @return string Translated text, or empty string if translation unavailable
@@ -561,11 +567,11 @@ public function localizeText(string $text, array $params, ?callable $progressCal
561567
/**
562568
* Localize a string into multiple languages and return texts in order.
563569
*
564-
* @param string $text Text content to translate into multiple languages
565-
* @param array<string, mixed> $params Parameters:
566-
* - 'sourceLocale' (string, required): Language code of the original text (e.g., 'en')
567-
* - 'targetLocales' (string[], required): Array of language codes to translate into (e.g., ['es', 'fr', 'de'])
568-
* - 'fast' (bool): Apply speed optimization to all translations
570+
* @param string $text Text content to translate into multiple languages
571+
* @param array<string, mixed> $params Batch translation options shared by all target locales:
572+
* - 'sourceLocale' (string, required): Language code of the original text (e.g., 'en')
573+
* - 'targetLocales' (string[], required): Array of language codes to translate into (e.g., ['es', 'fr', 'de'])
574+
* - 'fast' (bool): Apply speed optimization to all translations
569575
*
570576
* @return string[] Array of translated texts in same order as targetLocales parameter
571577
*
@@ -619,15 +625,17 @@ public function batchLocalizeText(string $text, array $params): array
619625
/**
620626
* Localize a chat transcript while preserving speaker names.
621627
*
622-
* @param array<int, array{name: string, text: string}> $chat Conversation history with speaker names and their messages
623-
* @param array<string, mixed> $params Parameters:
624-
* - 'targetLocale' (string, required): Language code to translate messages into (e.g., 'es', 'fr')
625-
* - 'sourceLocale' (string|null): Language of original messages, null for auto-detection
626-
* - 'fast' (bool): Optimize for speed over translation quality
627-
* - 'reference' (array): Conversation context or domain-specific terminology
628-
* @param null|callable(int): void $progressCallback Called with completion percentage (0-100) during processing
628+
* @param array<int, array<string, string>> $chat Conversation history with speaker names and their messages. Each entry must include:
629+
* - 'name' (string): Speaker label to preserve
630+
* - 'text' (string): Message content to translate
631+
* @param array<string, mixed> $params Chat translation options defining locale behavior and context:
632+
* - 'targetLocale' (string, required): Language code to translate messages into (e.g., 'es', 'fr')
633+
* - 'sourceLocale' (string|null): Language code of original messages, null for auto-detection
634+
* - 'fast' (bool): Optimize for speed over translation quality
635+
* - 'reference' (array<string, mixed>|null): Conversation context or domain-specific terminology
636+
* @param null|callable(int): void $progressCallback Called with completion percentage (0-100) during processing
629637
*
630-
* @return array<int, array{name: string, text: string}> Translated messages keeping original speaker names unchanged
638+
* @return array<int, array<string, string>> Translated messages keeping original speaker names unchanged
631639
*
632640
* @example Chat translation
633641
* ```php

0 commit comments

Comments
 (0)