translate_self 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +5 -2
- data/.gitignore +1 -0
- data/CHANGELOG.md +3 -1
- data/Gemfile +1 -9
- data/Gemfile.lock +2 -4
- data/lib/translate_self/translation.rb +24 -2
- data/lib/translate_self/version.rb +1 -1
- data/translate_self.gemspec +1 -1
- metadata +6 -11
- data/.idea/.gitignore +0 -8
- data/.idea/misc.xml +0 -4
- data/.idea/modules.xml +0 -8
- data/.idea/translate_self.iml +0 -36
- data/.idea/vcs.xml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d621cceb4a433a739bd6656dc910084900ffabd8a93969f4fd167e7ae8204bc1
|
4
|
+
data.tar.gz: 9b8ba476746f15856f4788b3c32cc5ab71bb24c3933168fc79a2fbdaa82d5a52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77ef05a2eda347e2bc4836d24aff629751217f2765edda9bfb72b2265040dc6a7ee2812e1f28ca205465cc449a82c543236276db13810f319223d73be73d87cd
|
7
|
+
data.tar.gz: 426ce380fa7762b630816d2ce4b94036b62299e1618ce64d100f1db821d37786272c89c7b5e8a52fcbe6614b5808a241221892636d00d9741812aed1a2915ea3
|
data/.github/workflows/main.yml
CHANGED
@@ -2,6 +2,9 @@ name: Ruby
|
|
2
2
|
|
3
3
|
on: [push,pull_request]
|
4
4
|
|
5
|
+
env:
|
6
|
+
DEEPL_AUTH_KEY: ${{ secrets.DEEPL_AUTH_KEY }}
|
7
|
+
|
5
8
|
jobs:
|
6
9
|
build:
|
7
10
|
runs-on: ubuntu-latest
|
@@ -12,5 +15,5 @@ jobs:
|
|
12
15
|
with:
|
13
16
|
ruby-version: 3.0.1
|
14
17
|
bundler-cache: true
|
15
|
-
- name: Run the
|
16
|
-
run: bundle exec rake
|
18
|
+
- name: Run the RSpec tests
|
19
|
+
run: bundle exec rake spec
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,12 +2,12 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
translate_self (0.1.0)
|
5
|
+
deepl-rb
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
8
9
|
specs:
|
9
10
|
ast (2.4.2)
|
10
|
-
byebug (11.1.3)
|
11
11
|
deepl-rb (2.3.0)
|
12
12
|
diff-lcs (1.4.4)
|
13
13
|
parallel (1.20.1)
|
@@ -48,10 +48,8 @@ PLATFORMS
|
|
48
48
|
x86_64-linux
|
49
49
|
|
50
50
|
DEPENDENCIES
|
51
|
-
byebug
|
52
|
-
deepl-rb
|
53
51
|
rake (~> 13.0)
|
54
|
-
rspec (~> 3.
|
52
|
+
rspec (~> 3.2)
|
55
53
|
rubocop (~> 1.7)
|
56
54
|
translate_self!
|
57
55
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'byebug'
|
2
1
|
require 'deepl'
|
3
2
|
|
4
3
|
# The part where the actual translation happens.
|
@@ -9,14 +8,37 @@ module Translation
|
|
9
8
|
TranslateSelf::AVAILABLE_LANGUAGES
|
10
9
|
end
|
11
10
|
|
11
|
+
# Translates self to the desired language. \
|
12
|
+
# Sample usage:
|
13
|
+
# hello = 'hello'\
|
14
|
+
# hello.to_language = 'fi'
|
15
|
+
# moi = hello.translate
|
16
|
+
# pp moi
|
17
|
+
# # 'Hei'
|
18
|
+
# @return [String] a new and shiny translated string!
|
12
19
|
def translate
|
13
20
|
call_deepl(self, language, to_language)
|
14
21
|
end
|
15
22
|
|
23
|
+
# Replaces self with the translation. \
|
24
|
+
# Sample usage:
|
25
|
+
# hello = 'hello'\
|
26
|
+
# hello.to_language = 'fi'
|
27
|
+
# hello.translate!
|
28
|
+
# pp hello
|
29
|
+
# # 'Hei'
|
30
|
+
# @return [String] self replaced with the new translation
|
16
31
|
def translate!
|
17
32
|
replace translate
|
18
33
|
end
|
19
34
|
|
35
|
+
# Translates the string itself to a language the user wants to translate it to. \
|
36
|
+
# Sample usage:
|
37
|
+
# 'hello'.translate_to_fi
|
38
|
+
# # Hei
|
39
|
+
#
|
40
|
+
# @param [String] the language to translate to, e.g. "fi"
|
41
|
+
# @return [String] the contents translated to another language
|
20
42
|
%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].each do |lan|
|
21
43
|
define_method("translate_to_#{lan}") do |language = lan|
|
22
44
|
call_deepl(self, self.language, language)
|
@@ -26,7 +48,7 @@ module Translation
|
|
26
48
|
private
|
27
49
|
|
28
50
|
def call_deepl(text, language = self.language, to_lan = to_language)
|
29
|
-
|
51
|
+
warn 'No language given!' and return if to_lan.nil?
|
30
52
|
|
31
53
|
response = DeepL.translate text, language, to_lan
|
32
54
|
self.language = response.detected_source_language.downcase if self.language.nil?
|
data/translate_self.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = 'TranslateSelf lets strings translate themselves. '
|
12
12
|
spec.description = 'Let the strings do the job for you. No need to do any of the manual work! \
|
13
13
|
The strings translate themselves!! Translate to Japanese, English, Finnish...'
|
14
|
-
spec.homepage = 'https://github.com/sampokuokkanen/
|
14
|
+
spec.homepage = 'https://github.com/sampokuokkanen/translate_self'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
|
17
17
|
|
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.2.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-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deepl-rb
|
@@ -78,11 +78,6 @@ files:
|
|
78
78
|
- ".byebug_history"
|
79
79
|
- ".github/workflows/main.yml"
|
80
80
|
- ".gitignore"
|
81
|
-
- ".idea/.gitignore"
|
82
|
-
- ".idea/misc.xml"
|
83
|
-
- ".idea/modules.xml"
|
84
|
-
- ".idea/translate_self.iml"
|
85
|
-
- ".idea/vcs.xml"
|
86
81
|
- ".rspec"
|
87
82
|
- ".rubocop.yml"
|
88
83
|
- CHANGELOG.md
|
@@ -99,13 +94,13 @@ files:
|
|
99
94
|
- lib/translate_self/translation.rb
|
100
95
|
- lib/translate_self/version.rb
|
101
96
|
- translate_self.gemspec
|
102
|
-
homepage: https://github.com/sampokuokkanen/
|
97
|
+
homepage: https://github.com/sampokuokkanen/translate_self
|
103
98
|
licenses:
|
104
99
|
- MIT
|
105
100
|
metadata:
|
106
|
-
homepage_uri: https://github.com/sampokuokkanen/
|
107
|
-
source_code_uri: https://github.com/sampokuokkanen/
|
108
|
-
changelog_uri: https://github.com/sampokuokkanen/
|
101
|
+
homepage_uri: https://github.com/sampokuokkanen/translate_self
|
102
|
+
source_code_uri: https://github.com/sampokuokkanen/translate_self
|
103
|
+
changelog_uri: https://github.com/sampokuokkanen/translate_self
|
109
104
|
post_install_message:
|
110
105
|
rdoc_options: []
|
111
106
|
require_paths:
|
data/.idea/.gitignore
DELETED
data/.idea/misc.xml
DELETED
data/.idea/modules.xml
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<project version="4">
|
3
|
-
<component name="ProjectModuleManager">
|
4
|
-
<modules>
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/translate_self.iml" filepath="$PROJECT_DIR$/.idea/translate_self.iml" />
|
6
|
-
</modules>
|
7
|
-
</component>
|
8
|
-
</project>
|
data/.idea/translate_self.iml
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<module type="RUBY_MODULE" version="4">
|
3
|
-
<component name="ModuleRunConfigurationManager">
|
4
|
-
<shared />
|
5
|
-
</component>
|
6
|
-
<component name="NewModuleRootManager">
|
7
|
-
<content url="file://$MODULE_DIR$">
|
8
|
-
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
9
|
-
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
10
|
-
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
11
|
-
</content>
|
12
|
-
<orderEntry type="inheritedJdk" />
|
13
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
14
|
-
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, rbenv: 3.0.1) [gem]" level="application" />
|
15
|
-
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.17, rbenv: 3.0.1) [gem]" level="application" />
|
16
|
-
<orderEntry type="library" scope="PROVIDED" name="byebug (v11.1.3, rbenv: 3.0.1) [gem]" level="application" />
|
17
|
-
<orderEntry type="library" scope="PROVIDED" name="deepl-rb (v2.3.0, rbenv: 3.0.1) [gem]" level="application" />
|
18
|
-
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.4.4, rbenv: 3.0.1) [gem]" level="application" />
|
19
|
-
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.20.1, rbenv: 3.0.1) [gem]" level="application" />
|
20
|
-
<orderEntry type="library" scope="PROVIDED" name="parser (v3.0.1.1, rbenv: 3.0.1) [gem]" level="application" />
|
21
|
-
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, rbenv: 3.0.1) [gem]" level="application" />
|
22
|
-
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.3, rbenv: 3.0.1) [gem]" level="application" />
|
23
|
-
<orderEntry type="library" scope="PROVIDED" name="rbs (v1.0.4, rbenv: 3.0.1) [gem]" level="application" />
|
24
|
-
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.1.1, rbenv: 3.0.1) [gem]" level="application" />
|
25
|
-
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, rbenv: 3.0.1) [gem]" level="application" />
|
26
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.10.0, rbenv: 3.0.1) [gem]" level="application" />
|
27
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.10.1, rbenv: 3.0.1) [gem]" level="application" />
|
28
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.10.1, rbenv: 3.0.1) [gem]" level="application" />
|
29
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.10.2, rbenv: 3.0.1) [gem]" level="application" />
|
30
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.10.2, rbenv: 3.0.1) [gem]" level="application" />
|
31
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop (v1.16.0, rbenv: 3.0.1) [gem]" level="application" />
|
32
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.7.0, rbenv: 3.0.1) [gem]" level="application" />
|
33
|
-
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, rbenv: 3.0.1) [gem]" level="application" />
|
34
|
-
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.0.0, rbenv: 3.0.1) [gem]" level="application" />
|
35
|
-
</component>
|
36
|
-
</module>
|