translate_self 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1bdc270fdc320b15fa9fd8249fa24c38591c2aa1210bb6622a37b7268781636
4
- data.tar.gz: 854e6cbb249caf59708b4ba93dd5ee1f085996bfdd14b377163ef579bf68c650
3
+ metadata.gz: d621cceb4a433a739bd6656dc910084900ffabd8a93969f4fd167e7ae8204bc1
4
+ data.tar.gz: 9b8ba476746f15856f4788b3c32cc5ab71bb24c3933168fc79a2fbdaa82d5a52
5
5
  SHA512:
6
- metadata.gz: 37922d9018c6e61366b60896c1475d21149c290a8a29c95fe5d74c79d568313b63b5013a6f5af91eb4bc251d256ca8d2755acd330fd446808c3b608f42e77a91
7
- data.tar.gz: 9bd11a1a8952635f2a3db3628b8d7a26593fe39096cfd59a8234f6db59ab3da7b6327f91e914644536a9c4019467edbb60c3651248f69fbd3800356d82b542f0
6
+ metadata.gz: 77ef05a2eda347e2bc4836d24aff629751217f2765edda9bfb72b2265040dc6a7ee2812e1f28ca205465cc449a82c543236276db13810f319223d73be73d87cd
7
+ data.tar.gz: 426ce380fa7762b630816d2ce4b94036b62299e1618ce64d100f1db821d37786272c89c7b5e8a52fcbe6614b5808a241221892636d00d9741812aed1a2915ea3
@@ -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 default task
16
- run: bundle exec rake
18
+ - name: Run the RSpec tests
19
+ run: bundle exec rake spec
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /.idea/
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
data/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  ## [Unreleased]
2
+ - Nothing new yet.
2
3
 
3
4
  ## [0.1.0] - 2021-06-02
4
5
 
5
- - Initial release
6
+ - Initial release!
7
+ You can now translate strings! Be free!
data/Gemfile CHANGED
@@ -3,12 +3,4 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in translate_self.gemspec
6
- gemspec
7
-
8
- gem 'byebug'
9
-
10
- gem 'rake', '~> 13.0'
11
-
12
- gem 'rspec', '~> 3.0'
13
-
14
- gem 'rubocop', '~> 1.7'
6
+ gemspec
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.0)
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
- raise 'No language given!' if to_lan.nil?
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?
@@ -1,3 +1,3 @@
1
1
  module TranslateSelf
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -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/rails_material_design_icons'
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.1.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-02 00:00:00.000000000 Z
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/rails_material_design_icons
97
+ homepage: https://github.com/sampokuokkanen/translate_self
103
98
  licenses:
104
99
  - MIT
105
100
  metadata:
106
- homepage_uri: https://github.com/sampokuokkanen/rails_material_design_icons
107
- source_code_uri: https://github.com/sampokuokkanen/rails_material_design_icons
108
- changelog_uri: https://github.com/sampokuokkanen/rails_material_design_icons
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
@@ -1,8 +0,0 @@
1
- # Default ignored files
2
- /shelf/
3
- /workspace.xml
4
- # Datasource local storage ignored files
5
- /dataSources/
6
- /dataSources.local.xml
7
- # Editor-based HTTP Client requests
8
- /httpRequests/
data/.idea/misc.xml DELETED
@@ -1,4 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectRootManager" version="2" project-jdk-name="rbenv: 3.0.1" project-jdk-type="RUBY_SDK" />
4
- </project>
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>
@@ -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>
data/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>