habluhablu 0.2.3 → 0.2.5

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: 176362e18a8aa159746f31972df293f854a9b596cf67404ecf26669d0cb2e458
4
- data.tar.gz: b519b6b00ba63a4e4bc345e0f865c6116825ac87eb4b29da920a8d63018025b9
3
+ metadata.gz: 94aed4a66a4b970448f7a9ff6be9b7d73477b6ae6583bc8c06c94e2ca0303a65
4
+ data.tar.gz: 22dc784c2c02be87bef45a604c4be9bed7899f93367401230bb755557fc4ca31
5
5
  SHA512:
6
- metadata.gz: 665658210f5d615d9dd2d83efc9685b548a290de796842ec627b0ff6a4a0859604c2d99a5b39e20bb905003522dd59c402aca1f0ec800e353478172c1677c809
7
- data.tar.gz: 03bd56cfd7945c44704dbd1df2107a9158391cfd13529415942f6525bdad4faec03b92e6c6e6571986bf345d18a10e704564f3797b2b47e57a7268690e91a0d3
6
+ metadata.gz: 1e6ca3ff12dcdad68b9f224734a48941cc44eadeea774400cce526ef2c2b1d5ed6699f32d85890ffcddeddb3cd78d06aeaff8a6a601445581c9cd9c2d1e4d3f1
7
+ data.tar.gz: e74f72eb74f4aeec6adad77026539d953fa4f37249b193427b8ff21b640c8157616c11449b5e10a6999aa2f809a45746bc5cfbb2cda003d10e6b265ba8a0aff4
data/.rubocop.yml CHANGED
@@ -17,7 +17,7 @@ Style/StringLiteralsInInterpolation:
17
17
  EnforcedStyle: double_quotes
18
18
 
19
19
  Layout/LineLength:
20
- Max: 120
20
+ Enabled: false
21
21
 
22
22
  Metrics/MethodLength:
23
23
  Exclude:
@@ -46,4 +46,5 @@ Metrics/ClassLength:
46
46
 
47
47
  Style/OptionalBooleanParameter:
48
48
  Exclude:
49
- - 'lib/languages/languages.rb'
49
+ - 'lib/languages/languages.rb'
50
+ - 'lib/habluhablu.rb'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- habluhablu (0.2.3)
4
+ habluhablu (0.2.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -34,9 +34,11 @@ Or install it yourself as:
34
34
 
35
35
  ### Usage
36
36
 
37
- Generate file for a specific language using `habluhablu -l <symbol>` command.
38
- [List of symbols](https://www.w3.org/International/O-charset-lang.html)
39
-
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
+ [List of symbols](https://www.w3.org/International/O-charset-lang.html)
41
+
40
42
  `habluhablu --help`
41
43
 
42
44
  There is also an option to add countries flag using bootstrap (for more informations go to languages/Countries_Flags.md).
data/exe/habluhablu CHANGED
@@ -10,16 +10,24 @@ OptionParser.new do |opts|
10
10
 
11
11
  opts.on("-l", "--language SYMBOL", "Symbol of the language you want to generate file for (en, es, ...).")
12
12
  opts.on("-m", "--multi SYMBOLS", "Symbols of languages you want to generate files for (en es pl ar)")
13
+ opts.on("-k", "--keyword KEYWORD", "Add your own keyword for all language files (.yml).")
13
14
  end.parse!(into: args)
14
15
 
15
16
  if args[:multi].nil?
16
- Habluhablu.hablu(args[:language])
17
- if File.exist?("config/locales/#{args[:language]}.yml")
17
+ if args[:keyword].nil?
18
+ Habluhablu.hablu(args[:language])
19
+ if File.exist?("config/locales/#{args[:language]}.yml")
20
+ puts "..."
21
+ sleep 0.5
22
+ puts "Everything was generated successfully!"
23
+ else
24
+ puts "Something went wrong!"
25
+ end
26
+ else
27
+ Habluhablu.keyword(args[:keyword])
18
28
  puts "..."
19
29
  sleep 0.5
20
- puts "Everything was generated successfully!"
21
- else
22
- puts "Something went wrong!"
30
+ puts "Everything was added successfully!"
23
31
  end
24
32
  else
25
33
  languages_array = args[:multi].split("_")
data/lib/habluhablu.rb CHANGED
@@ -1,47 +1,52 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "habluhablu/version"
4
- require_relative "languages/languages"
5
-
6
- # Module HabluHablu
7
- module Habluhablu
8
- class Error < StandardError; end
9
-
10
- # Cutom error with helpful message
11
- class WrongSymbolError < Error
12
- def initialize(language)
13
- super("Wrong language symbol: #{language}!")
14
- end
15
- end
16
-
17
- # Cutom error with helpful message
18
- class GemI18nError < Error
19
- def initialize
20
- super("Install I18n gem!")
21
- end
22
- end
23
-
24
- def self.hablu(language, lorem = false)
25
- # Check if I18n gem is included
26
- # if not, raise the custom error
27
- if Dir.exist?("./config/locales").eql?(false)
28
- raise GemI18nError.new
29
- end
30
-
31
- # Check if specified symbol's language does exist
32
- # if not, raise the custom error
33
- language_class = Languages.new(language)
34
- if language_class.include_language? == false
35
- raise WrongSymbolError.new(language)
36
- end
37
-
38
- if lorem.eql?(true)
39
- language_class.include_lorem(lorem)
40
- end
41
-
42
- # Create a file of specified language
43
- File.open("./config/locales/#{language}.yml", "w") do |f|
44
- f.write(language_class.render)
45
- end
46
- end
47
- end
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "habluhablu/version"
4
+ require_relative "languages/languages"
5
+
6
+ # Module HabluHablu
7
+ module Habluhablu
8
+ class Error < StandardError; end
9
+
10
+ # Cutom error with helpful message
11
+ class WrongSymbolError < Error
12
+ def initialize(language)
13
+ super("Wrong language symbol: #{language}!")
14
+ end
15
+ end
16
+
17
+ # Cutom error with helpful message
18
+ class GemI18nError < Error
19
+ def initialize
20
+ super("Install I18n gem!")
21
+ end
22
+ end
23
+
24
+ def self.hablu(language)
25
+ # Check if I18n gem is included
26
+ # if not, raise the custom error
27
+ if Dir.exist?("./config/locales").eql?(false)
28
+ raise GemI18nError.new
29
+ end
30
+
31
+ # Check if specified symbol's language does exist
32
+ # if not, raise the custom error
33
+ language_class = Languages.new(language)
34
+ if language_class.include_language? == false
35
+ raise WrongSymbolError.new(language)
36
+ end
37
+
38
+ # Create a file of specified language
39
+ File.open("./config/locales/#{language}.yml", "w") do |f|
40
+ f.write(language_class.render)
41
+ end
42
+ end
43
+
44
+ def self.keyword(keyword)
45
+ languages = Dir["config/locales/*.yml"]
46
+ languages.each do |file|
47
+ File.open(file.to_s, "a") do |f|
48
+ f.write(%(\n #{keyword}: => ""))
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,5 +1,5 @@
1
- # frozen_string_literal: true
2
-
3
- module Habluhablu
4
- VERSION = "0.2.3"
5
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Habluhablu
4
+ VERSION = "0.2.5"
5
+ end
@@ -4,6 +4,8 @@ require "yaml"
4
4
 
5
5
  # Class comment
6
6
  class Languages
7
+ attr_writer :languages
8
+
7
9
  def initialize(language)
8
10
  @language = language.to_sym
9
11
  @languages = {
@@ -41,6 +43,14 @@ class Languages
41
43
  },
42
44
  es: {
43
45
  "es" => {
46
+ "date" => {
47
+ "months_names" => %w[
48
+ Enero Febrero Marzo Abril Mayo Junio Julio Agosto Septiembre Octubre Noviembre Dieciembre
49
+ ],
50
+ "abbr_month_names" => %w[
51
+ Ene Feb Mar Abr May Jun Jul Ago Set Oct Nov Dic
52
+ ]
53
+ },
44
54
  "welcome" => "Bienvenido",
45
55
  "registration" => "Regístrate",
46
56
  "log_in" => "Iniciar sesión",
@@ -57,6 +67,14 @@ class Languages
57
67
  },
58
68
  pl: {
59
69
  "pl" => {
70
+ "date" => {
71
+ "months_names" => %w[
72
+ Styczeń Luty Marzec Kwiecień Maj Czerwiec Lipiec Sierpień Wrzesień Październik Listopad Grudzień
73
+ ],
74
+ "abbr_month_names" => %w[
75
+ Sty Lut Mar Kwi Maj Cze Lip Sie Wrz Paź Lis Gru
76
+ ]
77
+ },
60
78
  "welcome" => "Witaj",
61
79
  "registration" => "Zarejestruj się",
62
80
  "log_in" => "Zaloguj się",
@@ -136,6 +154,28 @@ class Languages
136
154
  "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."
137
155
 
138
156
  }
157
+ },
158
+ example: {
159
+ "example" => {
160
+ "date" => {
161
+ "months_names" => %w[
162
+ ],
163
+ "abbr_month_names" => %w[
164
+ ]
165
+ },
166
+ "welcome" => "",
167
+ "registration" => "",
168
+ "log_in" => "",
169
+ "log_in_with" => "", # Example: 'with Facebook'
170
+ "log_out" => "",
171
+ "email_address" => "",
172
+ "username" => "",
173
+ "password" => "",
174
+ "remember_me" => "",
175
+ "forgot_password" => "",
176
+ "do_not_have_account" => "",
177
+ "lorem" => ""
178
+ }
139
179
  }
140
180
  }
141
181
  end
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.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Gramatowski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-10 00:00:00.000000000 Z
11
+ date: 2021-05-11 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.