translate_self 0.5.0 → 0.6.0
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 +10 -1
- data/Gemfile.lock +1 -1
- data/README.md +22 -1
- data/benchmark.rb +16 -0
- data/lib/translate_self.rb +2 -1
- data/lib/translate_self/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48a0238d6e09ae494d46da95732914c18c77882cc8a077d1c522a124c985cd62
|
4
|
+
data.tar.gz: 84a3fe6ae48a310dabe1fa8952773dd6234cebd03f7b370fd57b1aca44e8add7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13d585250ec562d77cd50d7d175c214ae136069d806d0b584e919a020f7769c1b2df09e7610639d18fd3909065173d02fd44f062f0f6f25636c64b019d4345fc
|
7
|
+
data.tar.gz: cf6a84eb4c137084fa8b96f3c6e5dbab24e88499da2b638280eceaef615818b175d363d8de9d70529c82f243760a2750a3d8b7081f69a2e56bf583f7553d72a8
|
data/CHANGELOG.md
CHANGED
@@ -17,4 +17,13 @@ Seems like you need to update it by hand!
|
|
17
17
|
|
18
18
|
## [0.4.0] - 2021-06-05
|
19
19
|
|
20
|
-
- The translated new string now knows what language it is.
|
20
|
+
- The translated new string now knows what language it is.
|
21
|
+
|
22
|
+
## [0.5.0] - 2021-06-06
|
23
|
+
|
24
|
+
- Add TranslatableString class to work around frozen string literal magic comment.
|
25
|
+
Also will not crash with frozen strings now.
|
26
|
+
|
27
|
+
## [0.6.0] - 2021-06-08
|
28
|
+
|
29
|
+
- Add option to use ENV variable DEEPL_HOST
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -19,7 +19,11 @@ Just get a DeepL auth key and export it as follows:
|
|
19
19
|
export DEEPL_AUTH_KEY="your-api-token"
|
20
20
|
```
|
21
21
|
|
22
|
-
|
22
|
+
By default this gem uses the free DeepL servers, but you can also configure your own:
|
23
|
+
|
24
|
+
```sh
|
25
|
+
export DEEPL_HOST="non-free-host"
|
26
|
+
```
|
23
27
|
|
24
28
|
Now you can translate it to your language of chose with this gem!
|
25
29
|
```ruby
|
@@ -92,6 +96,23 @@ hello.translate
|
|
92
96
|
# "Moi"
|
93
97
|
```
|
94
98
|
|
99
|
+
## Benchmark
|
100
|
+
|
101
|
+
Create a string 5000000 times.
|
102
|
+
|
103
|
+
```shell
|
104
|
+
C:\home\sampo\translate_self> ruby benchmark.rb
|
105
|
+
Rehearsal -------------------------------------------------------
|
106
|
+
normal string 0.252435 0.000000 0.252435 ( 0.252490)
|
107
|
+
translatable string 0.299736 0.000000 0.299736 ( 0.299789)
|
108
|
+
---------------------------------------------- total: 0.552171sec
|
109
|
+
|
110
|
+
user system total real
|
111
|
+
normal string 0.237091 0.000000 0.237091 ( 0.237091)
|
112
|
+
translatable string 0.237607 0.000000 0.237607 ( 0.237611)
|
113
|
+
```
|
114
|
+
So... the overhead might be surprisingly low!
|
115
|
+
|
95
116
|
## Development
|
96
117
|
|
97
118
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/benchmark.rb
ADDED
data/lib/translate_self.rb
CHANGED
@@ -9,7 +9,8 @@ module TranslateSelf
|
|
9
9
|
include Translation
|
10
10
|
class Error < StandardError; end
|
11
11
|
DeepL.configure do |config|
|
12
|
-
config.
|
12
|
+
config.auth_key = ENV['DEEPL_AUTH_KEY']
|
13
|
+
config.host = ENV['DEEPL_HOST'] || 'https://api-free.deepl.com' # Default value is 'https://api.deepl.com'
|
13
14
|
end
|
14
15
|
AVAILABLE_LANGUAGES = %w[bg cs da de el en es et fi fr hu it ja lt lv nl pl pt ro ru sk sl sv zh].freeze
|
15
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: translate_self
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sampo Kuokkanen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deepl-rb
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- LICENSE.txt
|
87
87
|
- README.md
|
88
88
|
- Rakefile
|
89
|
+
- benchmark.rb
|
89
90
|
- bin/console
|
90
91
|
- bin/setup
|
91
92
|
- lib/ext/string.rb
|