Skip to content

Commit e7f9411

Browse files
committed
KBP-139 #time 2h - configure locale language
1 parent 3072884 commit e7f9411

File tree

12 files changed

+343
-4
lines changed

12 files changed

+343
-4
lines changed

lib/cybele.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
require 'cybele/helpers/simple_form'
1010
require 'cybele/helpers/show_for'
1111
require 'cybele/helpers/recipient_interceptor'
12+
require 'cybele/helpers/locale_language'
1213
require 'cybele/app_builder'

lib/cybele/app_builder.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class AppBuilder < Rails::AppBuilder
99
include Cybele::Helpers::SimpleForm
1010
include Cybele::Helpers::RecipientInterceptor
1111
include Cybele::Helpers::ShowFor
12+
include Cybele::Helpers::LocaleLanguage
1213

1314
def readme
1415
template 'README.md.erb',

lib/cybele/generators/app_generator.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ def setup_rollbar
136136
build :generate_rollbar
137137
end
138138

139+
def configure_locale_language
140+
say 'Configure locale', :green
141+
build :configure_locale_language
142+
end
143+
139144
def setup_show_for
140145
return if @options[:skip_show_for]
141146
say 'Generate show_for', :green

lib/cybele/helpers/locale_language.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
module Cybele
4+
module Helpers
5+
module LocaleLanguage
6+
def configure_locale_language
7+
remove_file 'config/locales/en.yml', force: true
8+
copy_file 'config/locales/tr.yml', 'config/locales/tr.yml'
9+
copy_file 'config/locales/email.tr.yml', 'config/locales/email.tr.yml'
10+
copy_file 'config/locales/models.tr.yml', 'config/locales/models.tr.yml'
11+
copy_file 'config/locales/view.tr.yml', 'config/locales/view.tr.yml'
12+
end
13+
end
14+
end
15+
end

lib/cybele/helpers/responders.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def configure_responders
1919
'require "application_responder"',
2020
"require 'application_responder'"
2121

22-
# Remove comments in locale/responders.yml
23-
uncomment_lines 'config/locales/responders.en.yml', /alert:/
22+
remove_file 'config/locales/responders.en.yml', force: true
23+
copy_file 'config/locales/responders.tr.yml', 'config/locales/responders.tr.yml'
2424
end
2525
end
2626
end

spec/features/new_default_project_spec.rb

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
expect(controller_file).to match('self.responder = ApplicationResponder')
6161
expect(controller_file).to match('respond_to :html, :js, :json')
6262

63-
locale_file = content('config/locales/responders.en.yml')
63+
expect(File).to exist(file_project_path('config/locales/responders.tr.yml'))
64+
locale_file = content('config/locales/responders.tr.yml')
6465
expect(locale_file).not_to match('# alert:')
6566
expect(locale_file).to match('create:')
6667
expect(locale_file).to match('update:')
@@ -111,6 +112,32 @@
111112
expect(config_staging_file).to match('RecipientInterceptor.new')
112113
end
113114

115+
it 'uses locale_language' do
116+
expect(File).to exist(file_project_path('config/locales/tr.yml'))
117+
locale_file = content('config/locales/tr.yml')
118+
expect(locale_file).to match('phone:')
119+
expect(locale_file).to match('date:')
120+
expect(locale_file).to match('time:')
121+
expect(locale_file).to match('number:')
122+
123+
expect(File).to exist(file_project_path('config/locales/email.tr.yml'))
124+
locale_file = content('config/locales/email.tr.yml')
125+
expect(locale_file).to match('email:')
126+
expect(locale_file).to match('devise:')
127+
expect(locale_file).to match('admin:')
128+
expect(locale_file).to match('user:')
129+
130+
expect(File).to exist(file_project_path('config/locales/models.tr.yml'))
131+
locale_file = content('config/locales/models.tr.yml')
132+
expect(locale_file).to match('activerecord:')
133+
expect(locale_file).to match('models:')
134+
expect(locale_file).to match('attributes:')
135+
136+
expect(File).to exist(file_project_path('config/locales/view.tr.yml'))
137+
locale_file = content('config/locales/view.tr.yml')
138+
expect(locale_file).to match('actions:')
139+
end
140+
114141
it 'uses simple_form' do
115142
gemfile_file = content('Gemfile')
116143
expect(gemfile_file).to match(/^gem 'simple_form'/)

spec/features/new_not_default_project_spec.rb

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
expect(controller_file).to match('self.responder = ApplicationResponder')
5252
expect(controller_file).to match('respond_to :html, :js, :json')
5353

54-
locale_file = content('config/locales/responders.en.yml')
54+
expect(File).to exist(file_project_path('config/locales/responders.tr.yml'))
55+
locale_file = content('config/locales/responders.tr.yml')
5556
expect(locale_file).not_to match('# alert:')
5657
expect(locale_file).to match('create:')
5758
expect(locale_file).to match('update:')
@@ -91,6 +92,32 @@
9192
expect(config_test_file).to match(/^Rails.application.configure/)
9293
end
9394

95+
it 'uses locale_language' do
96+
expect(File).to exist(file_project_path('config/locales/tr.yml'))
97+
locale_file = content('config/locales/tr.yml')
98+
expect(locale_file).to match('phone:')
99+
expect(locale_file).to match('date:')
100+
expect(locale_file).to match('time:')
101+
expect(locale_file).to match('number:')
102+
103+
expect(File).to exist(file_project_path('config/locales/email.tr.yml'))
104+
locale_file = content('config/locales/email.tr.yml')
105+
expect(locale_file).to match('email:')
106+
expect(locale_file).to match('devise:')
107+
expect(locale_file).to match('admin:')
108+
expect(locale_file).to match('user:')
109+
110+
expect(File).to exist(file_project_path('config/locales/models.tr.yml'))
111+
locale_file = content('config/locales/models.tr.yml')
112+
expect(locale_file).to match('activerecord:')
113+
expect(locale_file).to match('models:')
114+
expect(locale_file).to match('attributes:')
115+
116+
expect(File).to exist(file_project_path('config/locales/view.tr.yml'))
117+
locale_file = content('config/locales/view.tr.yml')
118+
expect(locale_file).to match('actions:')
119+
end
120+
94121
it 'uses recipient_interceptor' do
95122
gemfile_file = content('Gemfile')
96123
expect(gemfile_file).to match(/^gem 'recipient_interceptor'/)

templates/config/locales/email.tr.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
tr:
3+
email:
4+
salut: 'Merhaba %{user};'
5+
hello: 'Merhaba;'
6+
devise:
7+
confirmation_instruction:
8+
desc1: E-posta adresinizi aşağıdaki link ile doğrulayabilirsiniz
9+
btn_confirm: Hesabımı doğrula
10+
reset_password:
11+
desc1: Parolanızı değiştirmek için link isteğinde bulundunuz. Aşağıdaki link ile bunu yapabilirsiniz.
12+
change: Parolamı değiştir
13+
desc2: Eğer bu isteği siz yapmadıysanız bu e-posta'yı yok sayınız.
14+
desc3: Parolanız yukarıdaki link'e erişip yeni bir parola oluşturmadığınız sürece değişmeyecektir.
15+
admin:
16+
login_info:
17+
title: Yönetici Giriş Bilgileriniz
18+
first_info: Portal üzerinden yönetici hesabınız oluşturuldu. Artık yönetici portalına giriş yapabilirsiniz.
19+
second_info: Giriş bilgileriniz şu şekildedir
20+
btn_login: Giriş yapmak için tıklayınız
21+
last_info: "Eğer 'Giriş Yap' butonunu kullanamıyorsanız giriş linkiniz şu şekildedir <br/> <strong> Link : </strong> %{link} </br> Bu linki kopyalayıp tarayıcınıza yapıştırınız.."
22+
user:
23+
login_info:
24+
title: Kullanıcı Giriş Bilgileriniz
25+
first_info: Portal üzerinden kullanıcı hesabınız oluşturuldu. Artık kullanıcı portalına giriş yapabilirsiniz.
26+
second_info: Giriş bilgileriniz şu şekildedir
27+
btn_login: Giriş yapmak için tıklayınız
28+
last_info: "Eğer 'Giriş Yap' butonunu kullanamıyorsanız giriş linkiniz şu şekildedir <br/> <strong> Link : </strong> %{link} </br> Bu linki kopyalayıp tarayıcınıza yapıştırınız.."
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
tr:
3+
activerecord:
4+
models:
5+
schemamigration: Schemamigration
6+
user: Kullanıcı
7+
users: Kullanıcılar
8+
admin: Yönetici
9+
admins: Yöneticiler
10+
country: Ülke
11+
countries: Ülkeler
12+
city: Şehir
13+
cities: Şehirler
14+
audit: İşlem Geçmişi
15+
audits: İşlem Geçmişleri
16+
attributes:
17+
user:
18+
id: ID
19+
email: E-posta
20+
password: Parola
21+
current_password: Şu anki parolanız
22+
password_confirmation: Parola tekrarı
23+
remember_me: Beni hatırla
24+
encrypted_password: Şifrelenmiş parola
25+
reset_password_token: Parola sıfırlama token'ı
26+
reset_password_sent_at: Parola sıfırlama isteği gönderilme zamanı
27+
remember_created_at: Beni hatırla oluşturulma zamanı
28+
sign_in_count: Giriş sayısı
29+
current_sign_in_at: Güncel giriş tarihi
30+
last_sign_in_at: Son giriş tarihi
31+
last_seen_at: Son görülme tarihi
32+
current_sign_in_ip: Güncel girişe ait IP
33+
last_sign_in_ip: Son giriş işlemine ait IP
34+
authentication_token: Giriş token'ı
35+
name: İsim
36+
surname: Soyisim
37+
is_active: Aktif mi?
38+
time_zone: Zaman bölgesi
39+
created_at: Oluşturulma tarihi
40+
updated_at: Güncellenme tarihi
41+
admin:
42+
id: ID
43+
email: E-posta
44+
password: Parola
45+
current_password: Şu anki parolanız
46+
password_confirmation: Parola tekrarı
47+
remember_me: Beni hatırla
48+
encrypted_password: Şifrelenmiş parola
49+
reset_password_token: Parola sıfırlama token'ı
50+
reset_password_sent_at: Parola sıfırlama isteği gönderilme zamanı
51+
remember_created_at: Beni hatırla oluşturulma zamanı
52+
sign_in_count: Giriş sayısı
53+
current_sign_in_at: Güncel giriş tarihi
54+
last_sign_in_at: Son giriş tarihi
55+
last_seen_at: Son görülme tarihi
56+
current_sign_in_ip: Güncel girişe ait IP
57+
last_sign_in_ip: Son giriş işlemine ait IP
58+
authentication_token: Giriş token'ı
59+
name: İsim
60+
surname: Soyisim
61+
is_active: Aktif mi?
62+
created_at: Oluşturulma tarihi
63+
updated_at: Güncellenme tarihi
64+
country:
65+
id: Id
66+
name: Ülke ismi
67+
created_at: Oluşturulma tarihi
68+
updated_at: Güncellenme tarihi
69+
city:
70+
id: Id
71+
name: Şehir ismi
72+
country: Ülke
73+
country_id: Ülke
74+
created_at: Oluşturulma tarihi
75+
updated_at: Güncellenme tarihi
76+
audits:
77+
id: ID
78+
user_type: İşlemi yapan kullanıcı tipi
79+
user: İşlemi yapan kullanıcı
80+
type: Tip
81+
type_id: Tip ID
82+
action: İşlem
83+
user_id: İşlemi yapan
84+
auditable_type: İşlem yapılan
85+
auditable_id: İşlem yapılan ID
86+
action: İşlem Türü
87+
created_at: Oluşturulma tarihi
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
tr:
3+
flash:
4+
actions:
5+
toggle_is_active:
6+
passive: '%{resource_name} başarıyla pasif edildi.'
7+
active: '%{resource_name} başarıyla aktif edildi.'
8+
create:
9+
notice: '%{resource_name} başarı ile yaratıldı.'
10+
update:
11+
notice: '%{resource_name} başarı ile güncellendi.'
12+
destroy:
13+
notice: '%{resource_name} başarı ile silindi.'
14+
alert: '%{resource_name} silinemedi.'

templates/config/locales/tr.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
tr:
3+
phone:
4+
formats:
5+
long: '+99 (999) 999-9999'
6+
date:
7+
formats:
8+
excel:
9+
rails: '%d/%m/%Y'
10+
datepicker:
11+
rails: '%d/%m/%Y'
12+
js: 'd/m/Y'
13+
default: "%d/%m/%Y"
14+
year_month: "%Y-%B"
15+
date: '%d %B %Y'
16+
time:
17+
formats:
18+
certificate_completed_at_english: '%m/%d/%Y'
19+
certificate_completed_at: '%d/%m/%Y'
20+
datetimepicker_rails: '%d/%m/%Y %H:%M'
21+
datetimepicker:
22+
rails: '%d/%m/%Y %H:%M'
23+
js: 'd/m/Y H:i'
24+
default: "%d/%m/%Y %H:%M"
25+
year_month: "%Y-%B"
26+
date: '%d %B %Y'
27+
due_at:
28+
rails: '%d/%m/%Y %H:%M'
29+
js: 'd/m/Y H:i'
30+
number:
31+
currency:
32+
format:
33+
format: "%u %n"
34+
unit: ""

0 commit comments

Comments
 (0)