Skip to content

Commit 8d7f3ba

Browse files
docs: update markdown API reference [skip ci]
1 parent 58d09ff commit 8d7f3ba

File tree

1 file changed

+54
-25
lines changed

1 file changed

+54
-25
lines changed

docs/classes/LingoDotDev/Sdk/LingoDotDevEngine.md

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,11 @@ to detect the locale of free-form text. The engine handles request batching,
66
progress reporting, and surfacing validation or transport errors.
77

88
Example (basic setup):
9-
<pre><code class="language-php">
10-
<?php
11-
$engine = new LingoDotDevEngine(['apiKey' => $_ENV['LINGODOTDEV_API_KEY']]);
12-
</code></pre>
9+
$engine = new LingoDotDevEngine(['apiKey' => $_ENV['LINGODOTDEV_API_KEY']]);
1310

1411
Example (Laravel integration):
15-
<pre><code class="language-php">
16-
<?php
17-
$engine = new LingoDotDevEngine(['apiKey' => config('services.lingodotdev.api_key')]);
18-
$engine->localizeText($request->message, ['sourceLocale' => 'en', 'targetLocale' => 'es']);
19-
</code></pre>
12+
$engine = new LingoDotDevEngine(['apiKey' => config('services.lingodotdev.api_key')]);
13+
$engine->localizeText($request->message, ['sourceLocale' => 'en', 'targetLocale' => 'es']);
2014

2115
***
2216

@@ -38,23 +32,20 @@ public __construct(array{apiKey: string, apiUrl?: string, batchSize?: int, ideal
3832

3933
**Parameters:**
4034

41-
| Parameter | Type | Description |
42-
|-----------|---------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
35+
| Parameter | Type | Description |
36+
|-----------|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
4337
| `$config` | **array{apiKey: string, apiUrl?: string, batchSize?: int, idealBatchItemSize?: int}** | Configuration options:
4438
- 'apiKey' (string, required): Your API token
4539
- 'apiUrl' (string): API base URL (default: https://engine.lingo.dev)
4640
- 'batchSize' (int): Records per request, 1-250 (default: 25)
4741
- 'idealBatchItemSize' (int): Max words per request, 1-2500 (default: 250)
4842

4943
Example:
50-
<pre><code class="language-php">
51-
<?php
52-
$engine = new LingoDotDevEngine([
53-
'apiKey' => $_ENV['LINGODOTDEV_API_KEY'],
54-
'batchSize' => 100,
55-
'idealBatchItemSize' => 1000,
56-
]);
57-
</code></pre> |
44+
$engine = new LingoDotDevEngine([
45+
'apiKey' => $_ENV['LINGODOTDEV_API_KEY'],
46+
'batchSize' => 100,
47+
'idealBatchItemSize' => 1000,
48+
]); |
5849

5950
**Throws:**
6051

@@ -87,6 +78,11 @@ public localizeObject(array<string,mixed> $obj, array{targetLocale: string, sour
8778

8879
Translated data preserving original structure and non-text values
8980

81+
Example:
82+
$content = ['greeting' => 'Hello'];
83+
$engine = new LingoDotDevEngine(['apiKey' => $_ENV['LINGODOTDEV_API_KEY']]);
84+
$engine->localizeObject($content, ['sourceLocale' => 'en', 'targetLocale' => 'fr']);
85+
9086
**Throws:**
9187

9288
When required params or reference data are invalid
@@ -120,6 +116,20 @@ public localizeText(string $text, array{targetLocale: string, sourceLocale?: str
120116

121117
Translated text, or empty string if translation unavailable
122118

119+
Examples:
120+
$engine = new LingoDotDevEngine(['apiKey' => $_ENV['LINGODOTDEV_API_KEY']]);
121+
$engine->localizeText('Hello, world!', ['sourceLocale' => 'en', 'targetLocale' => 'es']);
122+
123+
$engine->localizeText(
124+
'This is a very long text that needs translation...',
125+
['sourceLocale' => 'en', 'targetLocale' => 'es'],
126+
function (int $progress): void {
127+
echo 'Translation progress: ' . $progress . "%%\n";
128+
}
129+
);
130+
131+
$engine->localizeText('Bonjour le monde', ['sourceLocale' => null, 'targetLocale' => 'en']);
132+
123133
**Throws:**
124134

125135
When required params are missing or invalid
@@ -134,15 +144,15 @@ When API rejects or fails to process the request
134144
Localize a string into multiple languages and return texts in order.
135145

136146
```php
137-
public batchLocalizeText(string $text, array{sourceLocale: string, targetLocales: array<int,string>, fast?: bool} $params): string[]
147+
public batchLocalizeText(string $text, array{sourceLocale: string, targetLocales: string[], fast?: bool} $params): string[]
138148
```
139149

140150
**Parameters:**
141151

142-
| Parameter | Type | Description |
143-
|-----------|--------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
144-
| `$text` | **string** | Text content to translate into multiple languages |
145-
| `$params` | **array{sourceLocale: string, targetLocales: array<int,string>, fast?: bool}** | Batch translation options shared by all target locales:
152+
| Parameter | Type | Description |
153+
|-----------|-----------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
154+
| `$text` | **string** | Text content to translate into multiple languages |
155+
| `$params` | **array{sourceLocale: string, targetLocales: string[], fast?: bool}** | Batch translation options shared by all target locales:
146156
- 'sourceLocale' (string, required): Language code of the original text (e.g., 'en')
147157
- 'targetLocales' (string[], required): Array of language codes to translate into (e.g., ['es', 'fr', 'de'])
148158
- 'fast' (bool): Trade translation quality for speed |
@@ -151,6 +161,13 @@ public batchLocalizeText(string $text, array{sourceLocale: string, targetLocales
151161

152162
Array of translated texts in same order as targetLocales parameter
153163

164+
Example:
165+
$engine = new LingoDotDevEngine(['apiKey' => $_ENV['LINGODOTDEV_API_KEY']]);
166+
$engine->batchLocalizeText('Hello, world!', [
167+
'sourceLocale' => 'en',
168+
'targetLocales' => ['es', 'fr', 'de'],
169+
]);
170+
154171
**Throws:**
155172

156173
When required params are missing or invalid
@@ -165,7 +182,7 @@ When an individual localization request fails
165182
Localize a chat transcript while preserving speaker names.
166183

167184
```php
168-
public localizeChat(array<int,array{name: string, text: string}> $chat, array{targetLocale: string, sourceLocale?: string|null, fast?: bool, reference?: array<string,mixed>|null} $params, callable|null $progressCallback = null): array<int,array<string,string>>
185+
public localizeChat(array<int,array{name: string, text: string}> $chat, array{targetLocale: string, sourceLocale?: string|null, fast?: bool, reference?: array<string,mixed>|null} $params, callable|null $progressCallback = null): array<int,array{name: string, text: string}>
169186
```
170187

171188
**Parameters:**
@@ -186,6 +203,14 @@ public localizeChat(array<int,array{name: string, text: string}> $chat, array{ta
186203

187204
Translated messages keeping original speaker names unchanged
188205

206+
Example:
207+
$conversation = [
208+
['name' => 'Alice', 'text' => 'Hello, how are you?'],
209+
['name' => 'Bob', 'text' => 'I am fine, thank you!'],
210+
];
211+
$engine = new LingoDotDevEngine(['apiKey' => $_ENV['LINGODOTDEV_API_KEY']]);
212+
$engine->localizeChat($conversation, ['sourceLocale' => 'en', 'targetLocale' => 'de']);
213+
189214
**Throws:**
190215

191216
When chat entries or params are invalid
@@ -213,6 +238,10 @@ public recognizeLocale(string $text): string
213238

214239
ISO language code detected by the API (e.g., 'en', 'es', 'zh')
215240

241+
Example:
242+
$engine = new LingoDotDevEngine(['apiKey' => $_ENV['LINGODOTDEV_API_KEY']]);
243+
$engine->recognizeLocale('Bonjour le monde');
244+
216245
**Throws:**
217246

218247
When input text is blank after trimming

0 commit comments

Comments
 (0)