deepl-rb 3.5.1 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -1
- data/README.md +13 -0
- data/VERSION +1 -1
- data/deepl-rb.gemspec +3 -2
- data/lib/deepl/requests/base.rb +1 -1
- data/lib/deepl/requests/translate.rb +1 -1
- data/lib/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/translate_texts.yml +172 -0
- data/spec/requests/extra_body_parameters_types_spec.rb +82 -0
- data/spec/requests/translate_spec.rb +34 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ea8e9d6cc6601abfadddf2b0b70169a7449e71434a8b695c534789d2263d681
|
|
4
|
+
data.tar.gz: '029b836b133bbf60d9b4a8acecf90b89d969d991e793db1bf5643f5633895282'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 83070b04ae93261b4524cb5353bdb888c2b9f5a98c9314239ed4ae8c76a53182363bb31ba31f7468a7a5d705162c09fbb69fb0f4a71bc802d8b373d97c46aeaa
|
|
7
|
+
data.tar.gz: 8ac545b8fb392b31a0e3fa00f4ed7f556bcf92304d8852226e57d099d365554c6eb5f510fe76891c329bdf89851c2bff217417f157947ffb96e41e50ef58b562
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [3.6.1] - 2025-12-19
|
|
10
|
+
### Fixed
|
|
11
|
+
- Fixed broken 3.6.0 release
|
|
12
|
+
|
|
13
|
+
## [3.6.0] - 2025-12-10
|
|
14
|
+
### Added
|
|
15
|
+
- Added `tag_handling_version` parameter to `translate()` to specify which version of the tag handling algorithm to use. Options are `v1` and `v2`.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- `extra_body_parameters` will no longer cast values to string, as this library sends JSON-encoded requests
|
|
19
|
+
(allows e.g. sending booleans)
|
|
20
|
+
|
|
7
21
|
## [3.5.1] - 2025-12-19
|
|
8
22
|
### Fixed
|
|
9
23
|
- Fixed broken 3.5.0 release
|
|
@@ -17,6 +31,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
17
31
|
model type as the default. Requests combining `custom_instructions` and the
|
|
18
32
|
`latency_optimized` model type will be rejected.
|
|
19
33
|
|
|
34
|
+
## [3.4.1] - 2025-12-19
|
|
35
|
+
### Fixed
|
|
36
|
+
- Fixed broken 3.4.0 release
|
|
37
|
+
|
|
20
38
|
## [3.4.0] - 2025-11-17
|
|
21
39
|
### Added
|
|
22
40
|
- Added support for the `GET /v3/style_rules` endpoint in the client library, the
|
|
@@ -84,8 +102,12 @@ The change in major version is only due to the change in maintainership, there i
|
|
|
84
102
|
### Fixed
|
|
85
103
|
- Make RequestEntityTooLarge error message more clear
|
|
86
104
|
|
|
105
|
+
[Unreleased]: https://github.com/DeepLcom/deepl-rb/compare/v3.6.1...HEAD
|
|
106
|
+
[3.6.1]: https://github.com/DeepLcom/deepl-rb/compare/v3.6.0...v3.6.1
|
|
107
|
+
[3.6.0]: https://github.com/DeepLcom/deepl-rb/compare/v3.5.1...v3.6.0
|
|
87
108
|
[3.5.1]: https://github.com/DeepLcom/deepl-rb/compare/v3.5.0...v3.5.1
|
|
88
|
-
[3.5.0]: https://github.com/DeepLcom/deepl-rb/compare/v3.4.
|
|
109
|
+
[3.5.0]: https://github.com/DeepLcom/deepl-rb/compare/v3.4.1...v3.5.0
|
|
110
|
+
[3.4.1]: https://github.com/DeepLcom/deepl-rb/compare/v3.4.0...v3.4.1
|
|
89
111
|
[3.4.0]: https://github.com/DeepLcom/deepl-rb/compare/v3.3.0...v3.4.0
|
|
90
112
|
[3.3.0]: https://github.com/DeepLcom/deepl-rb/compare/v3.2.0...v3.3.0
|
|
91
113
|
[3.2.0]: https://github.com/DeepLcom/deepl-rb/compare/v3.1.0...v3.2.0
|
data/README.md
CHANGED
|
@@ -127,6 +127,18 @@ puts translation.text
|
|
|
127
127
|
# => "<p>Una muestra</p>"
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
+
To specify which version of the tag handling algorithm to use, you can use the `tag_handling_version` parameter:
|
|
131
|
+
|
|
132
|
+
```rb
|
|
133
|
+
translation = DeepL.translate '<p>A sample</p>', 'EN', 'ES',
|
|
134
|
+
tag_handling: 'xml', tag_handling_version: 'v2'
|
|
135
|
+
|
|
136
|
+
puts translation.text
|
|
137
|
+
# => "<p>Una muestra</p>"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The available values are `'v1'` and `'v2'`.
|
|
141
|
+
|
|
130
142
|
To translate with context, simply supply the `context` parameter:
|
|
131
143
|
|
|
132
144
|
```rb
|
|
@@ -183,6 +195,7 @@ The following parameters will be automatically converted:
|
|
|
183
195
|
| `style_rule` | No conversion applied (can be a string ID or a StyleRule object)
|
|
184
196
|
| `context` | No conversion applied
|
|
185
197
|
| `custom_instructions` | No conversion applied
|
|
198
|
+
| `tag_handling_version` | No conversion applied
|
|
186
199
|
| `extra_body_parameters` | Hash of extra parameters to pass in the body of the HTTP request. Can be used to access beta features, or to override built-in parameters for testing purposes. Extra parameters can override keys explicitly set by the client.
|
|
187
200
|
|
|
188
201
|
### Rephrase Text
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.6.1
|
data/deepl-rb.gemspec
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
|
-
# stub: deepl-rb 3.
|
|
5
|
+
# stub: deepl-rb 3.6.1 ruby lib
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
8
|
s.name = "deepl-rb".freeze
|
|
9
|
-
s.version = "3.
|
|
9
|
+
s.version = "3.6.1"
|
|
10
10
|
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
12
12
|
s.metadata = { "bug_tracker_uri" => "https://github.com/DeepLcom/deepl-rb/issues", "changelog_uri" => "https://github.com/DeepLcom/deepl-rb/blob/main/CHANGELOG.md", "documentation_uri" => "https://github.com/DeepLcom/deepl-rb/blob/main/README.md", "homepage_uri" => "https://github.com/DeepLcom/deepl-rb" } if s.respond_to? :metadata=
|
|
@@ -109,6 +109,7 @@ Gem::Specification.new do |s|
|
|
|
109
109
|
"spec/integration_tests/document_api_spec.rb",
|
|
110
110
|
"spec/integration_tests/integration_test_utils.rb",
|
|
111
111
|
"spec/integration_tests/style_rule_api_spec.rb",
|
|
112
|
+
"spec/requests/extra_body_parameters_types_spec.rb",
|
|
112
113
|
"spec/requests/glossary/create_spec.rb",
|
|
113
114
|
"spec/requests/glossary/destroy_spec.rb",
|
|
114
115
|
"spec/requests/glossary/entries_spec.rb",
|
data/lib/deepl/requests/base.rb
CHANGED
|
@@ -28,7 +28,7 @@ module DeepL
|
|
|
28
28
|
}.freeze
|
|
29
29
|
|
|
30
30
|
attr_reader :text, :source_lang, :target_lang, :ignore_tags, :splitting_tags,
|
|
31
|
-
:non_splitting_tags, :model_type, :custom_instructions
|
|
31
|
+
:non_splitting_tags, :model_type, :custom_instructions, :tag_handling_version
|
|
32
32
|
|
|
33
33
|
def initialize(api, text, source_lang, target_lang, options = {})
|
|
34
34
|
super(api, options)
|
data/lib/version.rb
CHANGED
|
@@ -10455,4 +10455,176 @@ http_interactions:
|
|
|
10455
10455
|
encoding: ASCII-8BIT
|
|
10456
10456
|
string: '{"translations":[{"text":"Sehr geehrte Damen und Herren","detected_source_language":"EN"}]}'
|
|
10457
10457
|
recorded_at: Wed, 03 Dec 2025 06:07:36 GMT
|
|
10458
|
+
- request:
|
|
10459
|
+
method: post
|
|
10460
|
+
uri: https://api.deepl.com/v2/translate
|
|
10461
|
+
body:
|
|
10462
|
+
encoding: UTF-8
|
|
10463
|
+
string: text=%3Cp%3EHello+world%3C%2Fp%3E&source_lang=EN&target_lang=DE&tag_handling=html&tag_handling_version=v1
|
|
10464
|
+
headers:
|
|
10465
|
+
Authorization:
|
|
10466
|
+
- DeepL-Auth-Key VALID_TOKEN
|
|
10467
|
+
User-Agent:
|
|
10468
|
+
- deepl-ruby/3.5.0 (darwin24) ruby/3.2.2
|
|
10469
|
+
Content-Type:
|
|
10470
|
+
- application/x-www-form-urlencoded
|
|
10471
|
+
Accept-Encoding:
|
|
10472
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
10473
|
+
Accept:
|
|
10474
|
+
- "*/*"
|
|
10475
|
+
response:
|
|
10476
|
+
status:
|
|
10477
|
+
code: 200
|
|
10478
|
+
message: OK
|
|
10479
|
+
headers:
|
|
10480
|
+
Content-Type:
|
|
10481
|
+
- application/json
|
|
10482
|
+
Date:
|
|
10483
|
+
- Tue, 10 Dec 2025 12:00:00 GMT
|
|
10484
|
+
X-Trace-Id:
|
|
10485
|
+
- a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
|
|
10486
|
+
Access-Control-Expose-Headers:
|
|
10487
|
+
- Server-Timing, X-Trace-ID
|
|
10488
|
+
Server-Timing:
|
|
10489
|
+
- l7_lb_tls;dur=80, l7_lb_idle;dur=3, l7_lb_receive;dur=0, l7_lb_total;dur=150
|
|
10490
|
+
Strict-Transport-Security:
|
|
10491
|
+
- max-age=63072000; includeSubDomains; preload
|
|
10492
|
+
Transfer-Encoding:
|
|
10493
|
+
- chunked
|
|
10494
|
+
Vary:
|
|
10495
|
+
- Accept-Encoding
|
|
10496
|
+
body:
|
|
10497
|
+
encoding: UTF-8
|
|
10498
|
+
string: '{"translations":[{"detected_source_language":"EN","text":"<p>Hallo Welt</p>"}]}'
|
|
10499
|
+
recorded_at: Tue, 10 Dec 2025 12:00:00 GMT
|
|
10500
|
+
- request:
|
|
10501
|
+
method: post
|
|
10502
|
+
uri: https://api.deepl.com/v2/translate
|
|
10503
|
+
body:
|
|
10504
|
+
encoding: UTF-8
|
|
10505
|
+
string: text=%3Cp%3EHello+world%3C%2Fp%3E&source_lang=EN&target_lang=DE&tag_handling=html&tag_handling_version=v2
|
|
10506
|
+
headers:
|
|
10507
|
+
Authorization:
|
|
10508
|
+
- DeepL-Auth-Key VALID_TOKEN
|
|
10509
|
+
User-Agent:
|
|
10510
|
+
- deepl-ruby/3.5.0 (darwin24) ruby/3.2.2
|
|
10511
|
+
Content-Type:
|
|
10512
|
+
- application/x-www-form-urlencoded
|
|
10513
|
+
Accept-Encoding:
|
|
10514
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
10515
|
+
Accept:
|
|
10516
|
+
- "*/*"
|
|
10517
|
+
response:
|
|
10518
|
+
status:
|
|
10519
|
+
code: 200
|
|
10520
|
+
message: OK
|
|
10521
|
+
headers:
|
|
10522
|
+
Content-Type:
|
|
10523
|
+
- application/json
|
|
10524
|
+
Date:
|
|
10525
|
+
- Tue, 10 Dec 2025 12:00:01 GMT
|
|
10526
|
+
X-Trace-Id:
|
|
10527
|
+
- b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7
|
|
10528
|
+
Access-Control-Expose-Headers:
|
|
10529
|
+
- Server-Timing, X-Trace-ID
|
|
10530
|
+
Server-Timing:
|
|
10531
|
+
- l7_lb_tls;dur=82, l7_lb_idle;dur=2, l7_lb_receive;dur=0, l7_lb_total;dur=155
|
|
10532
|
+
Strict-Transport-Security:
|
|
10533
|
+
- max-age=63072000; includeSubDomains; preload
|
|
10534
|
+
Transfer-Encoding:
|
|
10535
|
+
- chunked
|
|
10536
|
+
Vary:
|
|
10537
|
+
- Accept-Encoding
|
|
10538
|
+
body:
|
|
10539
|
+
encoding: UTF-8
|
|
10540
|
+
string: '{"translations":[{"detected_source_language":"EN","text":"<p>Hallo Welt</p>"}]}'
|
|
10541
|
+
recorded_at: Tue, 10 Dec 2025 12:00:01 GMT
|
|
10542
|
+
- request:
|
|
10543
|
+
method: post
|
|
10544
|
+
uri: https://api-free.deepl.com/v2/translate
|
|
10545
|
+
body:
|
|
10546
|
+
encoding: UTF-8
|
|
10547
|
+
string: '{"text":["<p>Hello world</p>"],"source_lang":"EN","target_lang":"DE","tag_handling":"html","tag_handling_version":"v1"}'
|
|
10548
|
+
headers:
|
|
10549
|
+
Authorization:
|
|
10550
|
+
- DeepL-Auth-Key VALID_TOKEN
|
|
10551
|
+
User-Agent:
|
|
10552
|
+
- deepl-ruby/3.5.0 (darwin24) ruby/3.2.2
|
|
10553
|
+
Content-Type:
|
|
10554
|
+
- application/json
|
|
10555
|
+
Accept-Encoding:
|
|
10556
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
10557
|
+
Accept:
|
|
10558
|
+
- "*/*"
|
|
10559
|
+
response:
|
|
10560
|
+
status:
|
|
10561
|
+
code: 200
|
|
10562
|
+
message: OK
|
|
10563
|
+
headers:
|
|
10564
|
+
Content-Type:
|
|
10565
|
+
- application/json
|
|
10566
|
+
Date:
|
|
10567
|
+
- Tue, 10 Dec 2025 13:05:30 GMT
|
|
10568
|
+
X-Trace-Id:
|
|
10569
|
+
- c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6
|
|
10570
|
+
Access-Control-Expose-Headers:
|
|
10571
|
+
- Server-Timing, X-Trace-ID
|
|
10572
|
+
Server-Timing:
|
|
10573
|
+
- l7_lb_tls;dur=75, l7_lb_idle;dur=2, l7_lb_receive;dur=0, l7_lb_total;dur=145
|
|
10574
|
+
Strict-Transport-Security:
|
|
10575
|
+
- max-age=63072000; includeSubDomains; preload
|
|
10576
|
+
Transfer-Encoding:
|
|
10577
|
+
- chunked
|
|
10578
|
+
Vary:
|
|
10579
|
+
- Accept-Encoding
|
|
10580
|
+
Access-Control-Allow-Origin:
|
|
10581
|
+
- "*"
|
|
10582
|
+
body:
|
|
10583
|
+
encoding: UTF-8
|
|
10584
|
+
string: '{"translations":[{"detected_source_language":"EN","text":"<p>Hallo Welt</p>"}]}'
|
|
10585
|
+
recorded_at: Tue, 10 Dec 2025 13:05:30 GMT
|
|
10586
|
+
- request:
|
|
10587
|
+
method: post
|
|
10588
|
+
uri: https://api-free.deepl.com/v2/translate
|
|
10589
|
+
body:
|
|
10590
|
+
encoding: UTF-8
|
|
10591
|
+
string: '{"text":["<p>Hello world</p>"],"source_lang":"EN","target_lang":"DE","tag_handling":"html","tag_handling_version":"v2"}'
|
|
10592
|
+
headers:
|
|
10593
|
+
Authorization:
|
|
10594
|
+
- DeepL-Auth-Key VALID_TOKEN
|
|
10595
|
+
User-Agent:
|
|
10596
|
+
- deepl-ruby/3.5.0 (darwin24) ruby/3.2.2
|
|
10597
|
+
Content-Type:
|
|
10598
|
+
- application/json
|
|
10599
|
+
Accept-Encoding:
|
|
10600
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
10601
|
+
Accept:
|
|
10602
|
+
- "*/*"
|
|
10603
|
+
response:
|
|
10604
|
+
status:
|
|
10605
|
+
code: 200
|
|
10606
|
+
message: OK
|
|
10607
|
+
headers:
|
|
10608
|
+
Content-Type:
|
|
10609
|
+
- application/json
|
|
10610
|
+
Date:
|
|
10611
|
+
- Tue, 10 Dec 2025 13:05:31 GMT
|
|
10612
|
+
X-Trace-Id:
|
|
10613
|
+
- d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7
|
|
10614
|
+
Access-Control-Expose-Headers:
|
|
10615
|
+
- Server-Timing, X-Trace-ID
|
|
10616
|
+
Server-Timing:
|
|
10617
|
+
- l7_lb_tls;dur=78, l7_lb_idle;dur=3, l7_lb_receive;dur=0, l7_lb_total;dur=148
|
|
10618
|
+
Strict-Transport-Security:
|
|
10619
|
+
- max-age=63072000; includeSubDomains; preload
|
|
10620
|
+
Transfer-Encoding:
|
|
10621
|
+
- chunked
|
|
10622
|
+
Vary:
|
|
10623
|
+
- Accept-Encoding
|
|
10624
|
+
Access-Control-Allow-Origin:
|
|
10625
|
+
- "*"
|
|
10626
|
+
body:
|
|
10627
|
+
encoding: UTF-8
|
|
10628
|
+
string: '{"translations":[{"detected_source_language":"EN","text":"<p>Hallo Welt</p>"}]}'
|
|
10629
|
+
recorded_at: Tue, 10 Dec 2025 13:05:31 GMT
|
|
10458
10630
|
recorded_with: VCR 6.3.1
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Copyright 2025 DeepL SE (https://www.deepl.com)
|
|
2
|
+
# Use of this source code is governed by an MIT
|
|
3
|
+
# license that can be found in the LICENSE.md file.
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
require 'spec_helper'
|
|
7
|
+
|
|
8
|
+
describe 'DeepL::Requests::Base extra_body_parameters type preservation' do
|
|
9
|
+
let(:api) { build_deepl_api }
|
|
10
|
+
|
|
11
|
+
around do |tests|
|
|
12
|
+
tmp_env = replace_env_preserving_deepl_vars_except_mock_server
|
|
13
|
+
tests.call
|
|
14
|
+
ENV.replace(tmp_env)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe 'apply_extra_body_parameters_to_json' do
|
|
18
|
+
it 'preserves boolean true' do
|
|
19
|
+
request = DeepL::Requests::Translate.new(
|
|
20
|
+
api, 'test', 'EN', 'ES',
|
|
21
|
+
extra_body_parameters: { enable_beta_languages: true }
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
payload = {}
|
|
25
|
+
request.send(:apply_extra_body_parameters_to_json, payload)
|
|
26
|
+
|
|
27
|
+
expect(payload[:enable_beta_languages]).to be(true)
|
|
28
|
+
expect(payload[:enable_beta_languages]).to be_a(TrueClass)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'preserves boolean false' do
|
|
32
|
+
request = DeepL::Requests::Translate.new(
|
|
33
|
+
api, 'test', 'EN', 'ES',
|
|
34
|
+
extra_body_parameters: { some_flag: false }
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
payload = {}
|
|
38
|
+
request.send(:apply_extra_body_parameters_to_json, payload)
|
|
39
|
+
|
|
40
|
+
expect(payload[:some_flag]).to be(false)
|
|
41
|
+
expect(payload[:some_flag]).to be_a(FalseClass)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'preserves integers' do
|
|
45
|
+
request = DeepL::Requests::Translate.new(
|
|
46
|
+
api, 'test', 'EN', 'ES',
|
|
47
|
+
extra_body_parameters: { some_number: 42 }
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
payload = {}
|
|
51
|
+
request.send(:apply_extra_body_parameters_to_json, payload)
|
|
52
|
+
|
|
53
|
+
expect(payload[:some_number]).to eq(42)
|
|
54
|
+
expect(payload[:some_number]).to be_a(Integer)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'preserves strings' do
|
|
58
|
+
request = DeepL::Requests::Translate.new(
|
|
59
|
+
api, 'test', 'EN', 'ES',
|
|
60
|
+
extra_body_parameters: { some_string: 'hello' }
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
payload = {}
|
|
64
|
+
request.send(:apply_extra_body_parameters_to_json, payload)
|
|
65
|
+
|
|
66
|
+
expect(payload[:some_string]).to eq('hello')
|
|
67
|
+
expect(payload[:some_string]).to be_a(String)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it 'allows overriding standard parameters' do
|
|
71
|
+
request = DeepL::Requests::Translate.new(
|
|
72
|
+
api, 'test', 'EN', 'ES',
|
|
73
|
+
extra_body_parameters: { target_lang: 'FR' }
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
payload = { target_lang: 'ES' }
|
|
77
|
+
request.send(:apply_extra_body_parameters_to_json, payload)
|
|
78
|
+
|
|
79
|
+
expect(payload[:target_lang]).to eq('FR')
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -208,6 +208,23 @@ describe DeepL::Requests::Translate do
|
|
|
208
208
|
end
|
|
209
209
|
end
|
|
210
210
|
|
|
211
|
+
context 'when using `tag_handling_version` options' do
|
|
212
|
+
it 'works with a nil value' do
|
|
213
|
+
request = described_class.new(api, nil, nil, nil, tag_handling_version: nil)
|
|
214
|
+
expect(request.options[:tag_handling_version]).to be_nil
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
it 'works with v1' do
|
|
218
|
+
request = described_class.new(api, nil, nil, nil, tag_handling_version: 'v1')
|
|
219
|
+
expect(request.options[:tag_handling_version]).to eq('v1')
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
it 'works with v2' do
|
|
223
|
+
request = described_class.new(api, nil, nil, nil, tag_handling_version: 'v2')
|
|
224
|
+
expect(request.options[:tag_handling_version]).to eq('v2')
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
211
228
|
context 'when using `model_type` options' do
|
|
212
229
|
it 'works with a nil value' do
|
|
213
230
|
request = described_class.new(api, nil, nil, nil, model_type: nil)
|
|
@@ -415,6 +432,23 @@ describe DeepL::Requests::Translate do
|
|
|
415
432
|
end
|
|
416
433
|
end
|
|
417
434
|
|
|
435
|
+
context 'when performing a request with tag_handling_version' do
|
|
436
|
+
let(:text) { '<p>Hello world</p>' }
|
|
437
|
+
let(:target_lang) { 'DE' }
|
|
438
|
+
|
|
439
|
+
%w[v1 v2].each do |version|
|
|
440
|
+
it "translates correctly with tag_handling_version #{version}" do
|
|
441
|
+
options = { tag_handling: 'html', tag_handling_version: version }
|
|
442
|
+
translate = described_class.new(api, text, source_lang, target_lang, options)
|
|
443
|
+
res = translate.request
|
|
444
|
+
|
|
445
|
+
expect(res).to be_a(DeepL::Resources::Text)
|
|
446
|
+
expect(res.text).not_to be_nil
|
|
447
|
+
expect(res.text).not_to be_empty
|
|
448
|
+
end
|
|
449
|
+
end
|
|
450
|
+
end
|
|
451
|
+
|
|
418
452
|
context 'when performing a bad request' do
|
|
419
453
|
context 'when using an invalid token' do
|
|
420
454
|
let(:api) do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: deepl-rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.6.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- DeepL SE
|
|
@@ -136,6 +136,7 @@ files:
|
|
|
136
136
|
- spec/integration_tests/document_api_spec.rb
|
|
137
137
|
- spec/integration_tests/integration_test_utils.rb
|
|
138
138
|
- spec/integration_tests/style_rule_api_spec.rb
|
|
139
|
+
- spec/requests/extra_body_parameters_types_spec.rb
|
|
139
140
|
- spec/requests/glossary/create_spec.rb
|
|
140
141
|
- spec/requests/glossary/destroy_spec.rb
|
|
141
142
|
- spec/requests/glossary/entries_spec.rb
|