Skip to content

Commit 6547c65

Browse files
committed
fix: correct reference parameter format in docs and tests
1 parent e29f6ba commit 6547c65

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
lingodotdev (0.2.0)
4+
lingodotdev (0.2.1)
55
json (~> 2.0)
66
nokogiri (~> 1.0)
77

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,12 @@ result = engine.localize_text(
210210

211211
### Reference context
212212

213-
Provide additional context to improve translation accuracy:
213+
Provide existing translations as reference to improve translation accuracy. The `reference` hash maps locale codes to key-value content objects:
214214

215215
```ruby
216216
reference = {
217-
context: 'greeting',
218-
tone: 'formal',
219-
domain: 'business'
217+
'es' => { 'greeting' => 'Hola', 'farewell' => 'Adiós' },
218+
'fr' => { 'greeting' => 'Bonjour', 'farewell' => 'Au revoir' }
220219
}
221220

222221
result = engine.localize_text(
@@ -314,7 +313,7 @@ Localizes a string to the target locale.
314313
- `text` (String): Text to localize
315314
- `target_locale` (String): Target locale code (e.g., 'es', 'fr', 'ja')
316315
- `source_locale` (String): Source locale code (e.g., 'en')
317-
- `reference` (Hash, optional): Additional context for translation
316+
- `reference` (Hash, optional): Existing translations keyed by locale code, e.g. `{ 'es' => { 'key' => 'valor' } }`
318317
- `on_progress` (Proc, optional): Progress callback
319318
- `concurrent` (Boolean): Enable concurrent processing
320319
- `&block`: Alternative progress callback
@@ -342,7 +341,7 @@ Localizes an HTML document while preserving structure and formatting. Handles bo
342341
- `html` (String): HTML document string to localize
343342
- `target_locale` (String): Target locale code (e.g., 'es', 'fr', 'ja')
344343
- `source_locale` (String): Source locale code (e.g., 'en')
345-
- `reference` (Hash, optional): Additional context for translation
344+
- `reference` (Hash, optional): Existing translations keyed by locale code, e.g. `{ 'es' => { 'key' => 'valor' } }`
346345
- `on_progress` (Proc, optional): Progress callback
347346
- `concurrent` (Boolean): Enable concurrent processing
348347
- `&block`: Alternative progress callback

lib/lingodotdev.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def initialize(api_key:, engine_id: nil, api_url: 'https://api.lingo.dev', batch
190190
# @param target_locale [String] the target locale code (e.g., 'es', 'fr', 'ja')
191191
# @param source_locale [String] the source locale code (e.g., 'en')
192192
# @param fast [Boolean, nil] enable fast mode for quicker results (optional)
193-
# @param reference [Hash, nil] additional context for translation (optional)
193+
# @param reference [Hash, nil] existing translations keyed by locale code, e.g. { 'es' => { 'key' => 'valor' } } (optional)
194194
# @param on_progress [Proc, nil] callback for progress updates (optional)
195195
# @param concurrent [Boolean] enable concurrent processing (default: false)
196196
#
@@ -237,7 +237,7 @@ def localize_text(text, target_locale:, source_locale:, fast: nil, reference: ni
237237
# @param target_locale [String] the target locale code (e.g., 'es', 'fr', 'ja')
238238
# @param source_locale [String] the source locale code (e.g., 'en')
239239
# @param fast [Boolean, nil] enable fast mode for quicker results (optional)
240-
# @param reference [Hash, nil] additional context for translation (optional)
240+
# @param reference [Hash, nil] existing translations keyed by locale code, e.g. { 'es' => { 'key' => 'valor' } } (optional)
241241
# @param on_progress [Proc, nil] callback for progress updates (optional)
242242
# @param concurrent [Boolean] enable concurrent processing (default: false)
243243
#
@@ -283,7 +283,7 @@ def localize_object(obj, target_locale:, source_locale:, fast: nil, reference: n
283283
# @param target_locale [String] the target locale code (e.g., 'es', 'fr', 'ja')
284284
# @param source_locale [String] the source locale code (e.g., 'en')
285285
# @param fast [Boolean, nil] enable fast mode for quicker results (optional)
286-
# @param reference [Hash, nil] additional context for translation (optional)
286+
# @param reference [Hash, nil] existing translations keyed by locale code, e.g. { 'es' => { 'key' => 'valor' } } (optional)
287287
# @param on_progress [Proc, nil] callback for progress updates (optional)
288288
# @param concurrent [Boolean] enable concurrent processing (default: false)
289289
#
@@ -341,7 +341,7 @@ def localize_chat(chat, target_locale:, source_locale:, fast: nil, reference: ni
341341
# @param target_locale [String] the target locale code (e.g., 'es', 'fr', 'ja')
342342
# @param source_locale [String] the source locale code (e.g., 'en')
343343
# @param fast [Boolean, nil] enable fast mode for quicker results (optional)
344-
# @param reference [Hash, nil] additional context for translation (optional)
344+
# @param reference [Hash, nil] existing translations keyed by locale code, e.g. { 'es' => { 'key' => 'valor' } } (optional)
345345
# @param on_progress [Proc, nil] callback for progress updates (optional)
346346
# @param concurrent [Boolean] enable concurrent processing (default: false)
347347
#
@@ -514,7 +514,7 @@ def localize_html(html, target_locale:, source_locale:, fast: nil, reference: ni
514514
# @param target_locales [Array<String>] array of target locale codes
515515
# @param source_locale [String] the source locale code (e.g., 'en')
516516
# @param fast [Boolean, nil] enable fast mode for quicker results (optional)
517-
# @param reference [Hash, nil] additional context for translation (optional)
517+
# @param reference [Hash, nil] existing translations keyed by locale code, e.g. { 'es' => { 'key' => 'valor' } } (optional)
518518
# @param concurrent [Boolean] enable concurrent processing (default: false)
519519
#
520520
# @return [Array<String>] array of localized strings in the same order as target_locales
@@ -565,7 +565,7 @@ def batch_localize_text(text, target_locales:, source_locale:, fast: nil, refere
565565
# @param target_locale [String] the target locale code (e.g., 'es', 'fr', 'ja')
566566
# @param source_locale [String] the source locale code (e.g., 'en')
567567
# @param fast [Boolean, nil] enable fast mode for quicker results (optional)
568-
# @param reference [Hash, nil] additional context for translation (optional)
568+
# @param reference [Hash, nil] existing translations keyed by locale code, e.g. { 'es' => { 'key' => 'valor' } } (optional)
569569
# @param concurrent [Boolean] enable concurrent processing (default: false)
570570
#
571571
# @return [Array<Hash>] array of localized Hash objects in the same order as input

lib/lingodotdev/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
# Ruby SDK for Lingo.dev localization and translation API.
44
module LingoDotDev
55
# Current version of the LingoDotDev SDK.
6-
VERSION = "0.2.0"
6+
VERSION = "0.2.1"
77
end
88

spec/lingo_dot_dev/engine_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969

7070
it 'localizes text with reference context' do
7171
engine = described_class.new(api_key: api_key, engine_id: engine_id)
72-
reference = { context: 'greeting' }
72+
reference = { 'es' => { 'text' => 'Hola' } }
7373
result = engine.localize_text(
7474
'Hello',
7575
target_locale: target_locale,

0 commit comments

Comments
 (0)