habluhablu 0.5.4 → 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/.travis.yml +6 -0
- data/CHANGELOG.md +12 -1
- data/Gemfile.lock +1 -1
- data/README.md +38 -7
- data/lib/habluhablu/version.rb +1 -1
- data/lib/habluhablu.rb +7 -0
- data/lib/languages/languages.rb +50 -2
- data/lib/translation.rb +6 -6
- 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: 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/.travis.yml
ADDED
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
@@ -1,24 +1,41 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/habluhablu.svg)](https://badge.fury.io/rb/habluhablu)
|
2
|
+
[![Build Status](https://travis-ci.org/patrickgramatowski/habluhablu_gem.svg?branch=master)](https://travis-ci.org/patrickgramatowski/habluhablu_gem)
|
2
3
|
|
3
4
|
# HabluHablu
|
4
5
|
|
5
|
-
HabluHablu is a CLI written in Ruby, which allows you to generate language file with translations of the most useful phrases.
|
6
|
+
:earth_americas: HabluHablu is a CLI written in Ruby, which allows you to generate a language file (for I18n) with translations of the most useful phrases. :closed_book:
|
7
|
+
|
8
|
+
:dart: The main goal for me is to create a library of translations for the most of languages and maybe even for the most popular dialects.
|
9
|
+
What about ancient languages? :scroll:
|
6
10
|
|
7
11
|
## Supported languages
|
8
12
|
|
9
13
|
- English
|
14
|
+
- Spanish
|
15
|
+
- German
|
16
|
+
- French
|
17
|
+
- Italian
|
18
|
+
- Japanese
|
19
|
+
- Russian
|
20
|
+
- Korean
|
21
|
+
- Portuguese
|
22
|
+
- Turkish
|
10
23
|
- Polish
|
24
|
+
- Hungarian
|
25
|
+
- Thai (th - symbol)
|
26
|
+
- Chinese (zh - symbol)
|
11
27
|
- Arabic
|
12
|
-
- Spanish
|
13
28
|
- Hebrew
|
14
29
|
- If you want to help me out and add your language, don't hesitate!
|
15
30
|
- In progress...
|
16
31
|
|
17
32
|
### Installation
|
18
33
|
|
19
|
-
|
34
|
+
**Important!**
|
35
|
+
To be able to use the gem:
|
36
|
+
- Install [I18n gem](https://github.com/ruby-i18n/i18n)
|
20
37
|
|
21
|
-
|
38
|
+
Add this line to your application's Gemfile:
|
22
39
|
|
23
40
|
```ruby
|
24
41
|
gem 'habluhablu'
|
@@ -34,10 +51,24 @@ Or install it yourself as:
|
|
34
51
|
|
35
52
|
### Usage
|
36
53
|
|
37
|
-
Generate file for a specific language using `habluhablu -l <symbol>` command.
|
38
|
-
Generate an example language file using `habluhablu -l example` command (it generates empty file with keywords to fill).
|
39
|
-
Generate files for a more languages using `habluhablu -m <symbols>(separated by '_')` command.
|
40
54
|
[List of symbols](https://www.w3.org/International/O-charset-lang.html)
|
55
|
+
Generate file for a specific language using `habluhablu -l <symbol>` command.
|
56
|
+
|
57
|
+
Generate an example language file using `habluhablu -l example` command (it generates empty file with keywords to fill).
|
58
|
+
|
59
|
+
Generate files for a more languages using `habluhablu -m <symbols>(separated by '_')` command.
|
60
|
+
|
61
|
+
To generate a keyword for all languages files use: `habluhablu -k <keyword>` command.
|
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).
|
64
|
+
|
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']`
|
66
|
+
|
67
|
+
If you want to generate your own sample for languages files, You can do it by:
|
68
|
+
- creating your own sample.yml file in config/locales directory
|
69
|
+
- using `habluhablu -s <symbols>(separated by '_')` command
|
70
|
+
|
71
|
+
Generate a json file of the languages you want, use `habluhablu -j <symbols>(separated by '_')` command.
|
41
72
|
|
42
73
|
`habluhablu --help`
|
43
74
|
|
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
@@ -290,6 +290,52 @@ class Languages
|
|
290
290
|
"lorem" => "เป็นข้อความแทนที่ ใช้เพื่อลดความสนใจต่อข้อความที่นำมาแสดง สำหรับการแสดงลักษณะของ ฟอนต์ การพิมพ์และการจัดหน้า"
|
291
291
|
}
|
292
292
|
},
|
293
|
+
zh: {
|
294
|
+
"zh" => {
|
295
|
+
"date" => {
|
296
|
+
"months_names" => %w[
|
297
|
+
],
|
298
|
+
"abbr_month_names" => %w[
|
299
|
+
]
|
300
|
+
},
|
301
|
+
"language" => "简体中文",
|
302
|
+
"welcome" => "欢迎",
|
303
|
+
"registration" => "注册",
|
304
|
+
"log_in" => "登录",
|
305
|
+
"log_in_with" => "登录 %(replace)", # Example: 'with Facebook'
|
306
|
+
"log_out" => "登出",
|
307
|
+
"email_address" => "电子邮件地址",
|
308
|
+
"username" => "用户名",
|
309
|
+
"password" => "密码",
|
310
|
+
"remember_me" => "记住我",
|
311
|
+
"forgot_password" => "忘记密码",
|
312
|
+
"do_not_have_account" => "还没有 %(register) 账户?",
|
313
|
+
"lorem" => "側経意責家方家閉討店暖育田庁載社転線宇。得君新術治温抗添代話考振投員殴大闘北裁。品間識部案代学凰処済準世一戸刻法分。悼測済諏計飯利安凶断理資沢同岩面文認革。内警格化再薬方久化体教御決数詭芸得筆代。"
|
314
|
+
}
|
315
|
+
},
|
316
|
+
hu: {
|
317
|
+
"hu" => {
|
318
|
+
"date" => {
|
319
|
+
"months_names" => %w[
|
320
|
+
],
|
321
|
+
"abbr_month_names" => %w[
|
322
|
+
]
|
323
|
+
},
|
324
|
+
"language" => "Magyar",
|
325
|
+
"welcome" => "Üdvözöljük",
|
326
|
+
"registration" => "Fiók létrehozása",
|
327
|
+
"log_in" => "Bejelentkezés",
|
328
|
+
"log_in_with" => "Jelentkezz be %(replace)", # Example: 'with Facebook'
|
329
|
+
"log_out" => "Kijelentkezés",
|
330
|
+
"email_address" => "E-mail-címet",
|
331
|
+
"username" => "Felhasználónév",
|
332
|
+
"password" => "Jelszó",
|
333
|
+
"remember_me" => "Maradjak bejelentkezve",
|
334
|
+
"forgot_password" => "Nem tudsz bejelentkezni?",
|
335
|
+
"do_not_have_account" => "Nincs %(register) fiókja?",
|
336
|
+
"lorem" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
|
337
|
+
}
|
338
|
+
},
|
293
339
|
example: {
|
294
340
|
"example" => {
|
295
341
|
"date" => {
|
@@ -317,10 +363,12 @@ class Languages
|
|
317
363
|
end
|
318
364
|
|
319
365
|
def include_language?
|
320
|
-
@languages.key?(@language)
|
366
|
+
@languages.key?(@language)
|
321
367
|
end
|
322
368
|
|
323
369
|
def render
|
324
|
-
@languages.key?(@language)
|
370
|
+
raise Habluhablu::NoLanguageSymbolYet.new unless @languages.key?(@language)
|
371
|
+
|
372
|
+
@languages[@language].to_yaml
|
325
373
|
end
|
326
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
|
28
|
-
@request["x-rapidapi-key"] = '
|
24
|
+
|
25
|
+
@key = ENV['HABLUHABLU_API_KEY']
|
26
|
+
|
27
|
+
if @key.nil?
|
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.
|
@@ -23,6 +23,7 @@ files:
|
|
23
23
|
- ".gitignore"
|
24
24
|
- ".rspec"
|
25
25
|
- ".rubocop.yml"
|
26
|
+
- ".travis.yml"
|
26
27
|
- CHANGELOG.md
|
27
28
|
- Gemfile
|
28
29
|
- Gemfile.lock
|