habluhablu 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e59482360e21f3a8dca5d1114a494e5dd4dd10ddb603c9b1acc010bef8724670
4
- data.tar.gz: c76b0010dc85ffffbc79f59738851af2bc050236abc40a2754a3841af2ba83ef
3
+ metadata.gz: 2b59bcc4b8c7abe845d71a3d0fc7899d32a51253452f16b91980fce4b92fd481
4
+ data.tar.gz: 94484f9a79517cd23390236284523fdb84ed9ad7aa19010f632b404f778e190b
5
5
  SHA512:
6
- metadata.gz: aad0edcb6f8b3986f7ef76533d317020ac6693cb013d1cddec208d2839f647dd19e8951f4bf45ca67623157099c3f2e3f215012729651f5fd90e113d9d46f4df
7
- data.tar.gz: c285834be77e75ac8490da796080bd5699899d9f45cc90a5352463f5e61afb957c356dcad0d44f7d3ecaba577e25b2016dca4cead31f9ff9962a9037c6ed9589
6
+ metadata.gz: 91d81e714301a3d5570e2caf010678f0acc20324e5c0daff52943b48571670722422849f36979249aaaf8b183f229218b3a910edf2b352deead7ffe1aa9c5691
7
+ data.tar.gz: 4fb8cdce81a855a8909e09753ac56388c0a7b2f1e385c4c000f03eae1dbf729db6a584ceec7938429792e1c4f3350269010e3f45b17db985d24f3c646c76e580
data/.gitignore CHANGED
@@ -7,5 +7,7 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
 
10
+ *.gem
11
+
10
12
  # rspec failure tracking
11
13
  .rspec_status
data/.rubocop.yml CHANGED
@@ -18,7 +18,7 @@ Layout/LineLength:
18
18
  Max: 120
19
19
 
20
20
  Metrics/MethodLength:
21
- Max: 11
21
+ Max: 20
22
22
 
23
23
  Style/IfUnlessModifier:
24
24
  Exclude:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- habluhablu (0.1.4)
4
+ habluhablu (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -35,9 +35,11 @@ Or install it yourself as:
35
35
 
36
36
  ### Usage
37
37
 
38
- Generate file for a specific language using `habluhablu language <symbol>` command.
38
+ Generate file for a specific language using `habluhablu -l <symbol>` command.
39
39
  [List of symbols](https://www.w3.org/International/O-charset-lang.html)
40
40
 
41
+ `habluhablu --help`
42
+
41
43
  ### Contributing
42
44
 
43
45
  Bug reports and pull requests are welcome on GitHub at https://github.com/patrickgramatowski/habluhablu_gem.
data/exe/habluhablu ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "optparse"
5
+ require "habluhablu"
6
+
7
+ args = {}
8
+ OptionParser.new do |opts|
9
+ opts.banner = "Generate files including basic phrases translations (using with I18n gem)"
10
+
11
+ opts.on("-l", "--language SYMBOL", "The unit of the unnamed, first amount argument")
12
+ end.parse!(into: args)
13
+
14
+ Habluhablu.hablu(args[:language])
15
+ if File.exist?("config/locales/#{args[:language]}.yml")
16
+ puts "..."
17
+ sleep 0.5
18
+ puts "File for #{args[:language].upcase} language has been generated successfully!"
19
+ else
20
+ puts "Something went wrong!"
21
+ end
data/habluhablu.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = "HabluHablu makes it easier to use I18n."
12
12
  spec.description = "The gem allows you to generate language file with translations of the most useful phrases."
13
- spec.homepage = "https://github.com/patrickgramatowski/habluhablu"
13
+ spec.homepage = "https://github.com/patrickgramatowski/habluhablu_gem"
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
16
16
 
data/lib/habluhablu.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "habluhablu/version"
4
+ require_relative "languages/languages"
4
5
 
5
6
  # Module HabluHablu
6
7
  module Habluhablu
@@ -29,15 +30,14 @@ module Habluhablu
29
30
 
30
31
  # Check if specified symbol's language does exist
31
32
  # if not, raise the custom error
32
- if File.exist?("./languages/#{language}.yml").eql?(false)
33
+ language_class = Languages.new(language)
34
+ if language_class.include_language? == false
33
35
  raise WrongSymbolError.new(language)
34
36
  end
35
37
 
36
38
  # Create a file of specified language
37
39
  File.open("./config/locales/#{language}.yml", "w") do |f|
38
- File.open("./languages/#{language}.yml") do |i18n|
39
- f.write(i18n.read.to_s)
40
- end
40
+ f.write(language_class.render)
41
41
  end
42
42
  end
43
43
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Habluhablu
4
- VERSION = "0.1.4"
4
+ VERSION = "0.2.0"
5
5
  end
File without changes
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "yaml"
4
+
5
+ # Class comment
6
+ class Languages
7
+ def initialize(language)
8
+ @language = language.to_sym
9
+ @languages = {
10
+ ar: {
11
+ "ar" => {
12
+ "welcome" => "مرحبا",
13
+ "registration" => "عنوان البريد الإلكتروني",
14
+ "log_in" => "تسجيل الدخول",
15
+ "log_in_with" => "سجّل الدخول باستخدام حساب", # Example: 'with Facebook'
16
+ "log_out" => "تسجيل الخروج",
17
+ "email_address" => "عنوان البريد الإلكتروني",
18
+ "username" => "اسم االمستخدم",
19
+ "password" => "كلمه المرور",
20
+ "remember_me" => "تذكرنى",
21
+ "forgot_password" => "نسيت كلمة مرورك",
22
+ "do_not_have_account" => "ليس لديك حساب؟"
23
+ }
24
+ },
25
+ en: {
26
+ "en" => {
27
+ "welcome" => "Welcome",
28
+ "registration" => "Registartion",
29
+ "log_in" => "Log in",
30
+ "log_in_with" => "Log in with", # Example: 'with Facebook'
31
+ "log_out" => "Log out",
32
+ "email_address" => "Email address",
33
+ "username" => "Username",
34
+ "password" => "Password",
35
+ "remember_me" => "Remember me",
36
+ "forgot_password" => "Forgot password?",
37
+ "do_not_have_account" => "Don't You have an account?"
38
+ }
39
+ },
40
+ es: {
41
+ "es" => {
42
+ "welcome" => "Bienvenido",
43
+ "registration" => "Regístrate",
44
+ "log_in" => "Iniciar sesión",
45
+ "log_in_with" => "Iniciar sesión con", # Example: 'with Facebook'
46
+ "log_out" => "Cerrar la sesión",
47
+ "email_address" => "Dirección de correo electrónico",
48
+ "username" => "Nombre de usuario",
49
+ "password" => "Contraseña",
50
+ "remember_me" => "Recordarme",
51
+ "forgot_password" => "¿Has olvidado tu contraseña?",
52
+ "do_not_have_account" => "¿No tienes una cuenta?"
53
+ }
54
+ },
55
+ pl: {
56
+ "pl" => {
57
+ "welcome" => "Witaj",
58
+ "registration" => "Zarejestruj się",
59
+ "log_in" => "Zaloguj się",
60
+ "log_in_with" => "Zaloguj się za pomocą", # Example: 'with Facebook'
61
+ "log_out" => "Wyolguj się",
62
+ "email_address" => "Adres email",
63
+ "username" => "Nazwa użytkownika",
64
+ "password" => "Hasło",
65
+ "remember_me" => "Zapamiętaj mnie!",
66
+ "forgot_password" => "Zapomniałeś hasła?",
67
+ "do_not_have_account" => "Nie masz jeszcze konta?"
68
+ }
69
+ },
70
+ iw: {
71
+ "iw" => {
72
+ # I'm not sure about this translation, it has to be checked!!
73
+ "welcome" => "שלום",
74
+ "registration" => "הירשם",
75
+ "log_in" => "להתחבר",
76
+ "log_in_with" => "התחבר ל", # Example: 'with Facebook'
77
+ "log_out" => "להתנתק",
78
+ "email_address" => "אימייל",
79
+ "username" => "שם משתמש",
80
+ "password" => "סיסמה",
81
+ "remember_me" => "זכור אותי",
82
+ "forgot_password" => "שכחת את הסיסמא?",
83
+ "do_not_have_account" => "אין לך חשבון?"
84
+ }
85
+ }
86
+ }
87
+ end
88
+
89
+ def include_language?
90
+ @languages.key?(@language) ? true : false
91
+ end
92
+
93
+ def render
94
+ @languages.key?(@language) ? @languages[@language].to_yaml : "No language in the lib (YET!)"
95
+ end
96
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: habluhablu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Gramatowski
@@ -14,7 +14,8 @@ description: The gem allows you to generate language file with translations of t
14
14
  most useful phrases.
15
15
  email:
16
16
  - patrick.gramatowski@gmail.com
17
- executables: []
17
+ executables:
18
+ - habluhablu
18
19
  extensions: []
19
20
  extra_rdoc_files: []
20
21
  files:
@@ -29,25 +30,21 @@ files:
29
30
  - README.md
30
31
  - Rakefile
31
32
  - bin/console
32
- - bin/habluhablu
33
33
  - bin/setup
34
+ - exe/habluhablu
34
35
  - habluhablu.gemspec
35
- - languages/Countries_Flags.md
36
- - languages/ar.yml
37
- - languages/en.yml
38
- - languages/es.yml
39
- - languages/iw.yml
40
- - languages/pl.yml
41
36
  - lib/habluhablu.rb
42
37
  - lib/habluhablu/version.rb
43
- homepage: https://github.com/patrickgramatowski/habluhablu
38
+ - lib/languages/Countries_Flags.md
39
+ - lib/languages/languages.rb
40
+ homepage: https://github.com/patrickgramatowski/habluhablu_gem
44
41
  licenses:
45
42
  - MIT
46
43
  metadata:
47
44
  allowed_push_host: https://rubygems.org
48
- homepage_uri: https://github.com/patrickgramatowski/habluhablu
49
- source_code_uri: https://github.com/patrickgramatowski/habluhablu
50
- changelog_uri: https://github.com/patrickgramatowski/habluhablu/CHANGELOG.md
45
+ homepage_uri: https://github.com/patrickgramatowski/habluhablu_gem
46
+ source_code_uri: https://github.com/patrickgramatowski/habluhablu_gem
47
+ changelog_uri: https://github.com/patrickgramatowski/habluhablu_gem/CHANGELOG.md
51
48
  post_install_message:
52
49
  rdoc_options: []
53
50
  require_paths:
data/bin/habluhablu DELETED
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "thor"
5
- require "habluhablu"
6
-
7
- # Class comment
8
- class CLI < Thor
9
- desc "help", "some"
10
- desc "<language>", "Generate file .yml"
11
- long_desc <<-LONGDESC
12
- Generate files including basic phrases translations (using with I18n gem).
13
- LONGDESC
14
- def language(symbol)
15
- Habluhablu.hablu(symbol)
16
- if File.exist?("config/locales/#{symbol}.yml")
17
- puts "..."
18
- sleep 0.5
19
- puts "File for #{symbol.upcase} language has been generated successfully!"
20
- else
21
- puts "Something went wrong!"
22
- end
23
- end
24
- end
25
-
26
- CLI.start(ARGV)
data/languages/ar.yml DELETED
@@ -1,2 +0,0 @@
1
- ar:
2
- welcome: "مرحبا"
data/languages/en.yml DELETED
@@ -1,2 +0,0 @@
1
- en:
2
- welcome: "Welcome"
data/languages/es.yml DELETED
@@ -1,2 +0,0 @@
1
- es:
2
- welcome: "Bienvenido"
data/languages/iw.yml DELETED
@@ -1,2 +0,0 @@
1
- iw:
2
- welcome: "שלום"
data/languages/pl.yml DELETED
@@ -1,2 +0,0 @@
1
- pl:
2
- welcome: "Witaj"