habluhablu 0.5.7 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -1
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/lib/habluhablu/version.rb +1 -1
- data/lib/habluhablu.rb +7 -0
- data/lib/languages/languages.rb +4 -2
- data/lib/translation.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b0ab7b1bf0eff39d9728b8dfa084c141a875834476ab75979e312ccce3d0992
|
4
|
+
data.tar.gz: ed07ad6442164b97452b77d02181726e3c0ad1cd13e3f5c97be967bc168e4319
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd18d45a2dbee563cd070477dcd37351b702c7c9a573b72fa9fc9a7cf66f976035878eacd7dc1a45420c2297a90ada99c6902349e9e005d230da5e72a3840dec
|
7
|
+
data.tar.gz: f420e01ca997baeb742c78bdd09dddfde5c9609a8b9376bf3bc0a745cb6e5afea87609658278be66b27352c72774e6098e0642ca10646518e95ebaa77c9cc801
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,15 @@
|
|
1
|
-
## [
|
1
|
+
## [0.5.8] - 2022-01-10
|
2
|
+
|
3
|
+
- Updates CHANGELOG
|
4
|
+
- Refactores some parts of code
|
5
|
+
|
6
|
+
# [0.1.1]-[0.5.7] 2021-05-05 - 2021-06-13
|
7
|
+
|
8
|
+
- Adds new languages
|
9
|
+
- Integrates gem to be able to use Google Translate API
|
10
|
+
- Improves documentation
|
11
|
+
- Adds specs
|
12
|
+
- Adds the ability to generate language files in different formats
|
2
13
|
|
3
14
|
## [0.1.0] - 2021-05-05
|
4
15
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -21,6 +21,7 @@ What about ancient languages? :scroll:
|
|
21
21
|
- Portuguese
|
22
22
|
- Turkish
|
23
23
|
- Polish
|
24
|
+
- Hungarian
|
24
25
|
- Thai (th - symbol)
|
25
26
|
- Chinese (zh - symbol)
|
26
27
|
- Arabic
|
@@ -61,7 +62,7 @@ To generate a keyword for all languages files use: `habluhablu -k <keyword>` com
|
|
61
62
|
|
62
63
|
To translate a phrase/word use: `habluhablu -t hello_world -f en -o es`, where the command translates 'hello there' to spanish (-o flag).
|
63
64
|
|
64
|
-
**Important!** to use translator you will have to create an account [Google API](https://rapidapi.com/googlecloud/api/google-translate1) and
|
65
|
+
**Important!** to use translator you will have to create an account [Google API](https://rapidapi.com/googlecloud/api/google-translate1) and set the api key as ENV variable - `ENV['HABLUHABLU_API_KEY']`
|
65
66
|
|
66
67
|
If you want to generate your own sample for languages files, You can do it by:
|
67
68
|
- creating your own sample.yml file in config/locales directory
|
data/lib/habluhablu/version.rb
CHANGED
data/lib/habluhablu.rb
CHANGED
@@ -7,6 +7,13 @@ require_relative "languages/languages"
|
|
7
7
|
module Habluhablu
|
8
8
|
class Error < StandardError; end
|
9
9
|
|
10
|
+
# Raise error if wrong language symbol passed
|
11
|
+
class NoLanguageSymbolYet < Error
|
12
|
+
def initialize
|
13
|
+
super("No language in the lib (YET!)")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
10
17
|
# Cutom error with helpful message
|
11
18
|
class WrongSymbolError < Error
|
12
19
|
def initialize(language)
|
data/lib/languages/languages.rb
CHANGED
@@ -363,10 +363,12 @@ class Languages
|
|
363
363
|
end
|
364
364
|
|
365
365
|
def include_language?
|
366
|
-
@languages.key?(@language)
|
366
|
+
@languages.key?(@language)
|
367
367
|
end
|
368
368
|
|
369
369
|
def render
|
370
|
-
@languages.key?(@language)
|
370
|
+
raise Habluhablu::NoLanguageSymbolYet.new unless @languages.key?(@language)
|
371
|
+
|
372
|
+
@languages[@language].to_yaml
|
371
373
|
end
|
372
374
|
end
|
data/lib/translation.rb
CHANGED
@@ -21,13 +21,13 @@ class Translation
|
|
21
21
|
@request = Net::HTTP::Post.new(@url)
|
22
22
|
@request["content-type"] = "application/x-www-form-urlencoded"
|
23
23
|
@request["accept-encoding"] = "application/gzip"
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
if
|
24
|
+
|
25
|
+
@key = ENV['HABLUHABLU_API_KEY']
|
26
|
+
|
27
|
+
if @key.nil?
|
28
28
|
@request["x-rapidapi-key"] = 'Add your google api key!'
|
29
29
|
else
|
30
|
-
@request["x-rapidapi-key"] =
|
30
|
+
@request["x-rapidapi-key"] = @key
|
31
31
|
end
|
32
32
|
@request["x-rapidapi-host"] = "google-translate1.p.rapidapi.com"
|
33
33
|
@request.body = "q=#{@text}!&target=#{@target}&source=#{@source}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: habluhablu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Gramatowski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Generate language file (for I18n) with translations of the most useful
|
14
14
|
phrases.
|