habluhablu 0.2.7 → 0.4.2

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: 037df725642b4986782de3965e626feb2b59a6b4baddf6bf4d6ddfa1ebe0830f
4
- data.tar.gz: acbd741f6a3270ad5ad73ebc0ab33ab4460dd556a4670b8fbb86156cf31a75a5
3
+ metadata.gz: ab8b9081f9b8e0cfc475326f18acb28c48a9ef9d9207b747f032cb6d1fcad4cb
4
+ data.tar.gz: 0cdb332c814a10d014156f5a82a6cec4c837255d763410bba9ed451d5f662c77
5
5
  SHA512:
6
- metadata.gz: faf759d481c2b1acb7750ffd6c0375d8d79cb33903a757a052d0d14eb0653a874bbcb00d5d26012fe0aecfd8f3ccfe08829e5f38128bca4125e21659f16e1a01
7
- data.tar.gz: 48167c3fbd17c81caf42fd9d0f57fb78849a3e8797ed7fa40096f794ded56f68dd0155568c8a5717354f950e1718dc65da91c65589ad988206d8bae445a25717
6
+ metadata.gz: 71de8ca3595cb7fc32746aa9a81b16cc780acd9f39c7118ca5692a68679ff91313a2c8da955eb8f360cdad41a4f5d964e7e9a70d4a5ce1b2b7bfb97ad9e8a098
7
+ data.tar.gz: 752a12b29ecacf67e2b34e7cb7b310eed329f46664e03726f76f5dba6e78df7eebe3c90b327cd9ad2b1acd0c547bb36ec1f0855a188a3732b0e4e7bf341b66f2
data/.rubocop.yml CHANGED
@@ -11,6 +11,8 @@ Layout/EndOfLine:
11
11
  Style/StringLiterals:
12
12
  Enabled: true
13
13
  EnforcedStyle: double_quotes
14
+ Exclude:
15
+ - 'lib/translation.rb'
14
16
 
15
17
  Style/StringLiteralsInInterpolation:
16
18
  Enabled: true
@@ -48,3 +50,15 @@ Style/OptionalBooleanParameter:
48
50
  Exclude:
49
51
  - 'lib/languages/languages.rb'
50
52
  - 'lib/habluhablu.rb'
53
+
54
+ Style/FormatStringToken:
55
+ Enabled: false
56
+
57
+ Style/GlobalVars:
58
+ Enabled: false
59
+
60
+ Metrics/AbcSize:
61
+ Enabled: false
62
+
63
+ Style/ConditionalAssignment:
64
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- habluhablu (0.2.7)
4
+ habluhablu (0.4.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
File without changes
@@ -0,0 +1,48 @@
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.
47
+ ---
48
+ translation: "¡amigo!"
@@ -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
@@ -3,6 +3,7 @@
3
3
 
4
4
  require "optparse"
5
5
  require "habluhablu"
6
+ require "translation"
6
7
 
7
8
  args = {}
8
9
  OptionParser.new do |opts|
@@ -11,34 +12,53 @@ OptionParser.new do |opts|
11
12
  opts.on("-l", "--language SYMBOL", "Symbol of the language you want to generate file for (en, es, ...).")
12
13
  opts.on("-m", "--multi SYMBOLS", "Symbols of languages you want to generate files for (en es pl ar)")
13
14
  opts.on("-k", "--keyword KEYWORD", "Add your own keyword for all language files (.yml).")
15
+ opts.on("-s", "--sample FILES", "Add your own sample for language files (.yml).")
16
+ opts.on("-t", "--translate TEXT", "Translation text example: Hello_world_test!")
17
+ opts.on("-f", "--from SYMBOL", "From example: en")
18
+ opts.on("-o", "--target SYMBOL", "Target language example: es")
14
19
  end.parse!(into: args)
15
20
 
16
- if args[:multi].nil?
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])
21
+ information = lambda do |param|
22
+ if File.exist?("config/locales/#{param}.yml")
28
23
  puts "..."
29
24
  sleep 0.5
30
- puts "Everything was added successfully!"
25
+ puts "Everything was generated successfully!"
26
+ else
27
+ puts "Something went wrong!"
31
28
  end
32
- else
29
+ end
30
+
31
+ if args[:translate].nil? == false
32
+ if args[:from].nil? == false
33
+ translator = Translation.new(args[:translate], args[:target])
34
+ else
35
+ translator = Translation.new(args[:translate], args[:target], args[:from])
36
+ end
37
+ end
38
+ translator.response
39
+ information.call(args[:target])
40
+
41
+ if args[:language].nil? == false
42
+ Habluhablu.hablu(args[:language])
43
+ information.call(args[:language])
44
+ end
45
+
46
+ if args[:keyword].nil? == false
47
+ Habluhablu.keyword(args[:keyword])
48
+ puts "..."
49
+ sleep 0.5
50
+ puts "Everything was added successfully!"
51
+ end
52
+
53
+ if args[:multi].nil? == false
33
54
  languages_array = args[:multi].split("_")
34
55
  languages_array.each do |language|
35
56
  Habluhablu.hablu(language)
36
57
  end
37
- if File.exist?("config/locales/#{languages_array.last}.yml")
38
- puts "..."
39
- sleep 0.5
40
- puts "Everything was generated successfully!"
41
- else
42
- puts "Something went wrong!"
43
- end
58
+ information.call(languages_array.last)
59
+ end
60
+
61
+ if args[:sample].nil? == false
62
+ Habluhablu.render_sample(args[:sample])
63
+ information.call("sample")
44
64
  end
data/lib/habluhablu.rb CHANGED
@@ -14,6 +14,13 @@ module Habluhablu
14
14
  end
15
15
  end
16
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
+
17
24
  # Cutom error with helpful message
18
25
  class GemI18nError < Error
19
26
  def initialize
@@ -49,4 +56,17 @@ module Habluhablu
49
56
  end
50
57
  end
51
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
52
72
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Habluhablu
4
- VERSION = "0.2.7"
4
+ VERSION = "0.4.2"
5
5
  end
@@ -14,14 +14,14 @@ class Languages
14
14
  "welcome" => "مرحبا",
15
15
  "registration" => "عنوان البريد الإلكتروني",
16
16
  "log_in" => "تسجيل الدخول",
17
- "log_in_with" => "#{replace} سجّل الدخول باستخدام حساب", # Example: 'with Facebook'
17
+ "log_in_with" => "%{replace} سجّل الدخول باستخدام حساب", # Example: 'with Facebook'
18
18
  "log_out" => "تسجيل الخروج",
19
19
  "email_address" => "عنوان البريد الإلكتروني",
20
20
  "username" => "اسم االمستخدم",
21
21
  "password" => "كلمه المرور",
22
22
  "remember_me" => "تذكرنى",
23
23
  "forgot_password" => "نسيت كلمة مرورك",
24
- "do_not_have_account" => "ليس لديك حساب؟",
24
+ "do_not_have_account" => "ليس لديك حساب على {register}%؟",
25
25
  "lorem" => "غينيا واستمر العصبة ضرب قد. وباءت الأمريكي الأوربيين هو به،, هو العالم، الثقيلة بال. مع وايرلندا الأوروبيّون كان, قد بحق أسابيع العظمى واعتلاء. انه كل وإقامة المواد. "
26
26
  }
27
27
  },
@@ -30,14 +30,14 @@ class Languages
30
30
  "welcome" => "Welcome",
31
31
  "registration" => "Registartion",
32
32
  "log_in" => "Log in",
33
- "log_in_with" => "Log in with #{replace}", # Example: 'with Facebook'
33
+ "log_in_with" => "Log in with %{replace}", # Example: 'with Facebook'
34
34
  "log_out" => "Log out",
35
35
  "email_address" => "Email address",
36
36
  "username" => "Username",
37
37
  "password" => "Password",
38
38
  "remember_me" => "Remember me",
39
39
  "forgot_password" => "Forgot password?",
40
- "do_not_have_account" => "Don't You have an account?",
40
+ "do_not_have_account" => "Don't You have an %{register} account?",
41
41
  "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."
42
42
  }
43
43
  },
@@ -54,14 +54,14 @@ class Languages
54
54
  "welcome" => "Bienvenido",
55
55
  "registration" => "Regístrate",
56
56
  "log_in" => "Iniciar sesión",
57
- "log_in_with" => "Iniciar sesión con #{replace}", # Example: 'with Facebook'
57
+ "log_in_with" => "Iniciar sesión con %{replace}", # Example: 'with Facebook'
58
58
  "log_out" => "Cerrar la sesión",
59
59
  "email_address" => "Dirección de correo electrónico",
60
60
  "username" => "Nombre de usuario",
61
61
  "password" => "Contraseña",
62
62
  "remember_me" => "Recordarme",
63
63
  "forgot_password" => "¿Has olvidado tu contraseña?",
64
- "do_not_have_account" => "¿No tienes una cuenta?",
64
+ "do_not_have_account" => "¿No tienes una cuenta en %{register}?",
65
65
  "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."
66
66
  }
67
67
  },
@@ -78,14 +78,14 @@ class Languages
78
78
  "welcome" => "Witaj",
79
79
  "registration" => "Zarejestruj się",
80
80
  "log_in" => "Zaloguj się",
81
- "log_in_with" => "Zaloguj się za pomocą #{replace}", # Example: 'with Facebook'
81
+ "log_in_with" => "Zaloguj się za pomocą %{replace}", # Example: 'with Facebook'
82
82
  "log_out" => "Wyolguj się",
83
83
  "email_address" => "Adres email",
84
84
  "username" => "Nazwa użytkownika",
85
85
  "password" => "Hasło",
86
86
  "remember_me" => "Zapamiętaj mnie!",
87
87
  "forgot_password" => "Zapomniałeś hasła?",
88
- "do_not_have_account" => "Nie masz jeszcze konta?",
88
+ "do_not_have_account" => "Nie masz jeszcze konta w ${register}?",
89
89
  "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."
90
90
  }
91
91
  },
@@ -95,14 +95,14 @@ class Languages
95
95
  "welcome" => "שלום",
96
96
  "registration" => "הירשם",
97
97
  "log_in" => "להתחבר",
98
- "log_in_with" => "#{replace}התחבר ל", # Example: 'with Facebook'
98
+ "log_in_with" => "%{replace}התחבר ל", # Example: 'with Facebook'
99
99
  "log_out" => "להתנתק",
100
100
  "email_address" => "אימייל",
101
101
  "username" => "שם משתמש",
102
102
  "password" => "סיסמה",
103
103
  "remember_me" => "זכור אותי",
104
104
  "forgot_password" => "שכחת את הסיסמא?",
105
- "do_not_have_account" => "אין לך חשבון?",
105
+ "do_not_have_account" => "%{register} אין לך חשבון?",
106
106
  "lorem" => "כדי יסוד מונחים מועמדים של, דת דפים מאמרשיחהצפה זאת. אתה דת שונה כלשהו, גם אחר ליום בשפות, או ניווט פולנית לחיבור ארץ. ויש בקלות ואמנות אירועים או, אל אינו כלכלה שתי."
107
107
  }
108
108
  },
@@ -111,14 +111,14 @@ class Languages
111
111
  "welcome" => "Bienvenu", # bienvenue female
112
112
  "registration" => "Créer un compte",
113
113
  "log_in" => "Connexion",
114
- "log_in_with" => "Se connecter avec #{replace}", # Example: 'with Facebook'
114
+ "log_in_with" => "Se connecter avec %{replace}", # Example: 'with Facebook'
115
115
  "log_out" => "Déconnexion",
116
116
  "email_address" => "Adresse e-mail",
117
117
  "username" => "Nom d'utilisateur",
118
118
  "password" => "Mot de passe",
119
119
  "remember_me" => "Mémoriser",
120
120
  "forgot_password" => "Mot de passe oublié",
121
- "do_not_have_account" => "Vous n'avez pas de compte?",
121
+ "do_not_have_account" => "Vous n'avez pas de compte %{register}?",
122
122
  "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."
123
123
  }
124
124
  },
@@ -127,14 +127,14 @@ class Languages
127
127
  "welcome" => "Benvenuto", # benvenuta female
128
128
  "registration" => "Iscriviti",
129
129
  "log_in" => "Accedi",
130
- "log_in_with" => "Accedi con #{replace}", # Example: 'with Facebook'
130
+ "log_in_with" => "Accedi con %{replace}", # Example: 'with Facebook'
131
131
  "log_out" => "Esci",
132
132
  "email_address" => "Indirizzo e-mail",
133
133
  "username" => "Nome utente",
134
134
  "password" => "Password",
135
135
  "remember_me" => "Ricordami",
136
136
  "forgot_password" => "Ho dimenticato la password",
137
- "do_not_have_account" => "Non possiedi un account?",
137
+ "do_not_have_account" => "Non possiedi un account %{register}?",
138
138
  "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."
139
139
  }
140
140
  },
@@ -143,17 +143,49 @@ class Languages
143
143
  "welcome" => "Willkommen",
144
144
  "registration" => "Registrieren",
145
145
  "log_in" => "Anmelden",
146
- "log_in_with" => "Anmeldung mit #{replace}", # Example: 'with Facebook'
146
+ "log_in_with" => "Anmeldung mit %{replace}", # Example: 'with Facebook'
147
147
  "log_out" => "Abmelden",
148
148
  "email_address" => "E-Mail-Adresse",
149
149
  "username" => "Nutzername",
150
150
  "password" => "Passwort",
151
151
  "remember_me" => "Merken",
152
152
  "forgot_password" => "Passwort vergessen?",
153
- "do_not_have_account" => "Hast du noch kein FACEBOOK-Konto?", # Change facebook!
153
+ "do_not_have_account" => "Hast du noch kein %{replace}-Konto?", # Change!
154
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."
155
155
  }
156
156
  },
157
+ ru: {
158
+ "ru" => {
159
+ "welcome" => "Добро пожаловать",
160
+ "registration" => "Зарегистрироваться",
161
+ "log_in" => "Вход",
162
+ "log_in_with" => "Войти с помощью %{replace}", # Example: 'with Facebook'
163
+ "log_out" => "Выйти",
164
+ "email_address" => "Адрес электронной почты",
165
+ "username" => "имя пользователя",
166
+ "password" => "Пароль",
167
+ "remember_me" => "Запомнить меня",
168
+ "forgot_password" => "Забыли пароль",
169
+ "do_not_have_account" => "У вас нет учётной записи %{register}?", # Change facebook!
170
+ "lorem" => "Лорем ипсум долор сит амет, пер цлита поссит ех, ат мунере фабулас петентиум сит. Иус цу цибо саперет сцрипсерит, нец виси муциус лабитур ид. Ет хис нонумес нолуиссе дигниссим."
171
+ }
172
+ },
173
+ ja: {
174
+ "ja" => {
175
+ "welcome" => "ようこそ",
176
+ "registration" => "サインアップ",
177
+ "log_in" => "サインイン",
178
+ "log_in_with" => "%{replace}でサインインする", # Example: 'with Facebook'
179
+ "log_out" => "サインアウト",
180
+ "email_address" => "メールアドレス",
181
+ "username" => "ユーザー名",
182
+ "password" => "パスワード",
183
+ "remember_me" => "パスワードを記憶する",
184
+ "forgot_password" => "パスワードを忘れた場合",
185
+ "do_not_have_account" => "%{register}アカウントをお持ちではありませんか??", # Change facebook!
186
+ "lorem" => "旅ロ京青利セムレ弱改フヨス波府かばぼ意送でぼ調掲察たス日西重ケアナ住橋ユムミク順待ふかんぼ人奨貯鏡すびそ。"
187
+ }
188
+ },
157
189
  pt: {
158
190
  "pt" => {
159
191
  "date" => {
@@ -165,14 +197,14 @@ class Languages
165
197
  "welcome" => "Bem-vindo",
166
198
  "registration" => "Cadastrar",
167
199
  "log_in" => "Entrar",
168
- "log_in_with" => "Entrar com #{replace}", # Example: 'with Facebook'
200
+ "log_in_with" => "Entrar com %{replace}", # Example: 'with Facebook'
169
201
  "log_out" => "Fazer logoff",
170
202
  "email_address" => "Endereço de E-mail",
171
203
  "username" => "Nome de usuário",
172
204
  "password" => "Senha",
173
205
  "remember_me" => "Lembrar de mim",
174
206
  "forgot_password" => "Esqueceu Sua Senha",
175
- "do_not_have_account" => "Não tem uma conta da?", # Example: da Facebook
207
+ "do_not_have_account" => "Não tem uma conta da %{register}?", # Example: da Facebook
176
208
  "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
209
  }
178
210
  },
@@ -187,14 +219,14 @@ class Languages
187
219
  "welcome" => "Hoşgeldiniz",
188
220
  "registration" => "Kayıt Ol",
189
221
  "log_in" => "Giriş Yap",
190
- "log_in_with" => "#{replace} ile giriş yap", # Example: 'with Facebook'!
222
+ "log_in_with" => "%{replace} ile giriş yap", # Example: 'with Facebook'!
191
223
  "log_out" => "Çıkış Yap",
192
224
  "email_address" => "E-posta Adresi",
193
225
  "username" => "Kullanıcı adı",
194
226
  "password" => "Şifre",
195
227
  "remember_me" => "Beni hatırla",
196
228
  "forgot_password" => "Şifreni Mi Unuttun?",
197
- "do_not_have_account" => "Bir #{tr_register} hesabın yok mu?", # Example: Facebook
229
+ "do_not_have_account" => "Bir %{register} hesabın yok mu?", # Example: Facebook
198
230
  "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
231
  }
200
232
  },
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "uri"
4
+ require "net/http"
5
+ require "openssl"
6
+ require "json"
7
+ require "yaml"
8
+
9
+ # Class comment
10
+ class Translation
11
+ def initialize(text, target, source = "en")
12
+ @text = text.gsub("_", "%2C%20")
13
+ @target = target
14
+ @source = source
15
+ @url = URI("https://google-translate1.p.rapidapi.com/language/translate/v2")
16
+
17
+ @http = Net::HTTP.new(@url.host, @url.port)
18
+ @http.use_ssl = true
19
+ @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
20
+
21
+ @request = Net::HTTP::Post.new(@url)
22
+ @request["content-type"] = "application/x-www-form-urlencoded"
23
+ @request["accept-encoding"] = "application/gzip"
24
+ File.open("config/locales/api_key.txt", "a+") do |f|
25
+ $KEY = f.read
26
+ end
27
+ if $KEY.length <= 2 || $KEY.nil?
28
+ @request["x-rapidapi-key"] = 'ef9f61b3d0mshb95dcad44627e7cp176d4bjsn8f4d9e2a1706'
29
+ else
30
+ @request["x-rapidapi-key"] = $KEY
31
+ end
32
+ @request["x-rapidapi-host"] = "google-translate1.p.rapidapi.com"
33
+ @request.body = "q=#{@text}!&target=#{@target}&source=#{@source}"
34
+ # Example "q=Hello%2C%20dear%2C%20friend!&target=es&source=en"
35
+ end
36
+
37
+ def response
38
+ response = @http.request(@request)
39
+ content = JSON.parse(response.read_body)
40
+ content = content["data"]["translations"].first["translatedText"]
41
+ File.open("config/locales/#{@target}.yml", "a+") do |f|
42
+ f.write({ "translation" => content.to_s }.to_yaml)
43
+ end
44
+ end
45
+ end
46
+
47
+ tr = Translation.new("Hi_there", "es")
48
+ tr.response
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.7
4
+ version: 0.4.2
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-11 00:00:00.000000000 Z
11
+ date: 2021-05-13 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,12 +31,16 @@ files:
31
31
  - Rakefile
32
32
  - bin/console
33
33
  - bin/setup
34
+ - config/locales/api_key.txt
35
+ - config/locales/es.yml
36
+ - config/locales/iw.yml
34
37
  - exe/habluhablu
35
38
  - habluhablu.gemspec
36
39
  - lib/habluhablu.rb
37
40
  - lib/habluhablu/version.rb
38
41
  - lib/languages/Countries_Flags.md
39
42
  - lib/languages/languages.rb
43
+ - lib/translation.rb
40
44
  homepage: https://github.com/patrickgramatowski/habluhablu_gem
41
45
  licenses:
42
46
  - MIT