habluhablu 0.2.3 → 0.3.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: 176362e18a8aa159746f31972df293f854a9b596cf67404ecf26669d0cb2e458
4
- data.tar.gz: b519b6b00ba63a4e4bc345e0f865c6116825ac87eb4b29da920a8d63018025b9
3
+ metadata.gz: 74cc8fdd9b2fe0b2cb45b4457eec91c27745560026c457856b068d47f8d9ea47
4
+ data.tar.gz: 12e305f318399b37b365bb6914e14a47dd09ef17b98bffe0c4a476ca1cd8c436
5
5
  SHA512:
6
- metadata.gz: 665658210f5d615d9dd2d83efc9685b548a290de796842ec627b0ff6a4a0859604c2d99a5b39e20bb905003522dd59c402aca1f0ec800e353478172c1677c809
7
- data.tar.gz: 03bd56cfd7945c44704dbd1df2107a9158391cfd13529415942f6525bdad4faec03b92e6c6e6571986bf345d18a10e704564f3797b2b47e57a7268690e91a0d3
6
+ metadata.gz: 5d4e5b984fb6bcf5948dca8fefddfa391fbb3b17efc8a1e8957f0e0b1150e88c9a8f45e32fe2675e6c53613c3b3d34175a01bdbab3cb13e30c6414b493f4fcf9
7
+ data.tar.gz: edd8228e983a65532bea4d576df2be32f9693c97b60943b242d3d3c74b3b3f41bece5faf1855b52988636f1ede4ef8e8e404774f7839f2cb34499fb433a70cd8
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,8 @@ 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'
51
+
52
+ Style/FormatStringToken:
53
+ Enabled: false
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.3.0)
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).
@@ -0,0 +1,46 @@
1
+ ---
2
+ es:
3
+ date:
4
+ months_names:
5
+ - Enero
6
+ - Febrero
7
+ - Marzo
8
+ - Abril
9
+ - Mayo
10
+ - Junio
11
+ - Julio
12
+ - Agosto
13
+ - Septiembre
14
+ - Octubre
15
+ - Noviembre
16
+ - Dieciembre
17
+ abbr_month_names:
18
+ - Ene
19
+ - Feb
20
+ - Mar
21
+ - Abr
22
+ - May
23
+ - Jun
24
+ - Jul
25
+ - Ago
26
+ - Set
27
+ - Oct
28
+ - Nov
29
+ - Dic
30
+ welcome: Bienvenido
31
+ registration: Regístrate
32
+ log_in: Iniciar sesión
33
+ log_in_with: Iniciar sesión con %{replace}
34
+ log_out: Cerrar la sesión
35
+ email_address: Dirección de correo electrónico
36
+ username: Nombre de usuario
37
+ password: Contraseña
38
+ remember_me: Recordarme
39
+ forgot_password: "¿Has olvidado tu contraseña?"
40
+ do_not_have_account: "¿No tienes una cuenta?"
41
+ lorem: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
42
+ incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
43
+ exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
44
+ irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
45
+ pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
46
+ deserunt mollit anim id est laborum.
@@ -0,0 +1,16 @@
1
+ ---
2
+ iw:
3
+ welcome: שלום
4
+ registration: הירשם
5
+ log_in: להתחבר
6
+ log_in_with: "%{replace}התחבר ל"
7
+ log_out: להתנתק
8
+ email_address: אימייל
9
+ username: שם משתמש
10
+ password: סיסמה
11
+ remember_me: זכור אותי
12
+ forgot_password: שכחת את הסיסמא?
13
+ do_not_have_account: אין לך חשבון?
14
+ lorem: כדי יסוד מונחים מועמדים של, דת דפים מאמרשיחהצפה זאת. אתה דת שונה כלשהו, גם
15
+ אחר ליום בשפות, או ניווט פולנית לחיבור ארץ. ויש בקלות ואמנות אירועים או, אל אינו
16
+ כלכלה שתי.
data/exe/habluhablu CHANGED
@@ -10,27 +10,39 @@ 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).")
14
+ opts.on("-s", "--sample FILES", "Add your own sample for language files (.yml).")
13
15
  end.parse!(into: args)
14
16
 
15
- if args[:multi].nil?
16
- Habluhablu.hablu(args[:language])
17
- if File.exist?("config/locales/#{args[:language]}.yml")
17
+ information = lambda do |param|
18
+ if File.exist?("config/locales/#{param}.yml")
18
19
  puts "..."
19
20
  sleep 0.5
20
21
  puts "Everything was generated successfully!"
21
22
  else
22
23
  puts "Something went wrong!"
23
24
  end
24
- else
25
- languages_array = args[:multi].split("_")
26
- languages_array.each do |language|
27
- Habluhablu.hablu(language)
28
- end
29
- if File.exist?("config/locales/#{languages_array.last}.yml")
30
- puts "..."
31
- sleep 0.5
32
- puts "Everything was generated successfully!"
25
+ end
26
+
27
+ if args[:sample].nil?
28
+ if args[:multi].nil?
29
+ if args[:keyword].nil?
30
+ Habluhablu.hablu(args[:language])
31
+ information.call(args[:language])
32
+ else
33
+ Habluhablu.keyword(args[:keyword])
34
+ puts "..."
35
+ sleep 0.5
36
+ puts "Everything was added successfully!"
37
+ end
33
38
  else
34
- puts "Something went wrong!"
39
+ languages_array = args[:multi].split("_")
40
+ languages_array.each do |language|
41
+ Habluhablu.hablu(language)
42
+ end
43
+ information.call(languages_array.last)
35
44
  end
45
+ else
46
+ Habluhablu.render_sample(args[:sample])
47
+ information.call("sample")
36
48
  end
data/lib/habluhablu.rb CHANGED
@@ -1,47 +1,72 @@
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 NoSampleError < Error
19
+ def initialize
20
+ super("There is no sample.yml file!")
21
+ end
22
+ end
23
+
24
+ # Cutom error with helpful message
25
+ class GemI18nError < Error
26
+ def initialize
27
+ super("Install I18n gem!")
28
+ end
29
+ end
30
+
31
+ def self.hablu(language)
32
+ # Check if I18n gem is included
33
+ # if not, raise the custom error
34
+ if Dir.exist?("./config/locales").eql?(false)
35
+ raise GemI18nError.new
36
+ end
37
+
38
+ # Check if specified symbol's language does exist
39
+ # if not, raise the custom error
40
+ language_class = Languages.new(language)
41
+ if language_class.include_language? == false
42
+ raise WrongSymbolError.new(language)
43
+ end
44
+
45
+ # Create a file of specified language
46
+ File.open("./config/locales/#{language}.yml", "w") do |f|
47
+ f.write(language_class.render)
48
+ end
49
+ end
50
+
51
+ def self.keyword(keyword)
52
+ languages = Dir["config/locales/*.yml"]
53
+ languages.each do |file|
54
+ File.open(file.to_s, "a") do |f|
55
+ f.write(%(\n #{keyword}: => ""))
56
+ end
57
+ end
58
+ end
59
+
60
+ def self.render_sample(languages)
61
+ raise NoSampleError.new unless File.exist?("config/locales/sample.yml")
62
+
63
+ languages = languages.split("_")
64
+ languages.each do |language|
65
+ File.open("config/locales/sample.yml", "r") do |f|
66
+ File.open("config/locales/#{language}.yml", "a+") do |fl|
67
+ fl.write(f.read)
68
+ end
69
+ end
70
+ end
71
+ end
72
+ 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.3.0"
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 = {
@@ -12,7 +14,7 @@ class Languages
12
14
  "welcome" => "مرحبا",
13
15
  "registration" => "عنوان البريد الإلكتروني",
14
16
  "log_in" => "تسجيل الدخول",
15
- "log_in_with" => "سجّل الدخول باستخدام حساب", # Example: 'with Facebook'
17
+ "log_in_with" => "%{replace} سجّل الدخول باستخدام حساب", # Example: 'with Facebook'
16
18
  "log_out" => "تسجيل الخروج",
17
19
  "email_address" => "عنوان البريد الإلكتروني",
18
20
  "username" => "اسم االمستخدم",
@@ -28,7 +30,7 @@ class Languages
28
30
  "welcome" => "Welcome",
29
31
  "registration" => "Registartion",
30
32
  "log_in" => "Log in",
31
- "log_in_with" => "Log in with", # Example: 'with Facebook'
33
+ "log_in_with" => "Log in with %{replace}", # Example: 'with Facebook'
32
34
  "log_out" => "Log out",
33
35
  "email_address" => "Email address",
34
36
  "username" => "Username",
@@ -41,10 +43,18 @@ 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",
47
- "log_in_with" => "Iniciar sesión con", # Example: 'with Facebook'
57
+ "log_in_with" => "Iniciar sesión con %{replace}", # Example: 'with Facebook'
48
58
  "log_out" => "Cerrar la sesión",
49
59
  "email_address" => "Dirección de correo electrónico",
50
60
  "username" => "Nombre de usuario",
@@ -57,10 +67,18 @@ 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ę",
63
- "log_in_with" => "Zaloguj się za pomocą", # Example: 'with Facebook'
81
+ "log_in_with" => "Zaloguj się za pomocą %{replace}", # Example: 'with Facebook'
64
82
  "log_out" => "Wyolguj się",
65
83
  "email_address" => "Adres email",
66
84
  "username" => "Nazwa użytkownika",
@@ -77,7 +95,7 @@ class Languages
77
95
  "welcome" => "שלום",
78
96
  "registration" => "הירשם",
79
97
  "log_in" => "להתחבר",
80
- "log_in_with" => "התחבר ל", # Example: 'with Facebook'
98
+ "log_in_with" => "%{replace}התחבר ל", # Example: 'with Facebook'
81
99
  "log_out" => "להתנתק",
82
100
  "email_address" => "אימייל",
83
101
  "username" => "שם משתמש",
@@ -93,7 +111,7 @@ class Languages
93
111
  "welcome" => "Bienvenu", # bienvenue female
94
112
  "registration" => "Créer un compte",
95
113
  "log_in" => "Connexion",
96
- "log_in_with" => "Se connecter avec", # Example: 'with Facebook'
114
+ "log_in_with" => "Se connecter avec %{replace}", # Example: 'with Facebook'
97
115
  "log_out" => "Déconnexion",
98
116
  "email_address" => "Adresse e-mail",
99
117
  "username" => "Nom d'utilisateur",
@@ -109,7 +127,7 @@ class Languages
109
127
  "welcome" => "Benvenuto", # benvenuta female
110
128
  "registration" => "Iscriviti",
111
129
  "log_in" => "Accedi",
112
- "log_in_with" => "Accedi con", # Example: 'with Facebook'
130
+ "log_in_with" => "Accedi con %{replace}", # Example: 'with Facebook'
113
131
  "log_out" => "Esci",
114
132
  "email_address" => "Indirizzo e-mail",
115
133
  "username" => "Nome utente",
@@ -125,7 +143,7 @@ class Languages
125
143
  "welcome" => "Willkommen",
126
144
  "registration" => "Registrieren",
127
145
  "log_in" => "Anmelden",
128
- "log_in_with" => "Anmeldung mit", # Example: 'with Facebook'
146
+ "log_in_with" => "Anmeldung mit %{replace}", # Example: 'with Facebook'
129
147
  "log_out" => "Abmelden",
130
148
  "email_address" => "E-Mail-Adresse",
131
149
  "username" => "Nutzername",
@@ -134,7 +152,72 @@ class Languages
134
152
  "forgot_password" => "Passwort vergessen?",
135
153
  "do_not_have_account" => "Hast du noch kein FACEBOOK-Konto?", # Change facebook!
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
+ }
156
+ },
157
+ pt: {
158
+ "pt" => {
159
+ "date" => {
160
+ "months_names" => %w[
161
+ ],
162
+ "abbr_month_names" => %w[
163
+ ]
164
+ },
165
+ "welcome" => "Bem-vindo",
166
+ "registration" => "Cadastrar",
167
+ "log_in" => "Entrar",
168
+ "log_in_with" => "Entrar com %{replace}", # Example: 'with Facebook'
169
+ "log_out" => "Fazer logoff",
170
+ "email_address" => "Endereço de E-mail",
171
+ "username" => "Nome de usuário",
172
+ "password" => "Senha",
173
+ "remember_me" => "Lembrar de mim",
174
+ "forgot_password" => "Esqueceu Sua Senha",
175
+ "do_not_have_account" => "Não tem uma conta da?", # Example: da Facebook
176
+ "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."
177
+ }
178
+ },
179
+ tr: {
180
+ "tr" => {
181
+ "date" => {
182
+ "months_names" => %w[
183
+ ],
184
+ "abbr_month_names" => %w[
185
+ ]
186
+ },
187
+ "welcome" => "Hoşgeldiniz",
188
+ "registration" => "Kayıt Ol",
189
+ "log_in" => "Giriş Yap",
190
+ "log_in_with" => "%{replace} ile giriş yap", # Example: 'with Facebook'!
191
+ "log_out" => "Çıkış Yap",
192
+ "email_address" => "E-posta Adresi",
193
+ "username" => "Kullanıcı adı",
194
+ "password" => "Şifre",
195
+ "remember_me" => "Beni hatırla",
196
+ "forgot_password" => "Şifreni Mi Unuttun?",
197
+ "do_not_have_account" => "Bir %{tr_register} hesabın yok mu?", # Example: Facebook
198
+ "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."
199
+ }
200
+ },
201
+ example: {
202
+ "example" => {
203
+ "date" => {
204
+ "months_names" => %w[
205
+ ],
206
+ "abbr_month_names" => %w[
207
+ ]
208
+ },
209
+ "welcome" => "",
210
+ "registration" => "",
211
+ "log_in" => "",
212
+ "log_in_with" => "", # Example: 'with Facebook'
213
+ "log_out" => "",
214
+ "email_address" => "",
215
+ "username" => "",
216
+ "password" => "",
217
+ "remember_me" => "",
218
+ "forgot_password" => "",
219
+ "do_not_have_account" => "",
220
+ "lorem" => ""
138
221
  }
139
222
  }
140
223
  }
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.3.0
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.
@@ -31,6 +31,8 @@ files:
31
31
  - Rakefile
32
32
  - bin/console
33
33
  - bin/setup
34
+ - config/locales/es.yml
35
+ - config/locales/iw.yml
34
36
  - exe/habluhablu
35
37
  - habluhablu.gemspec
36
38
  - lib/habluhablu.rb