Skip to content

Commit

Permalink
KBP-124 #time 5m - Conflict was resolved.
Browse files Browse the repository at this point in the history
  • Loading branch information
esref.viduslu committed Oct 30, 2017
2 parents 98e36cd + 8434185 commit 34c2630
Show file tree
Hide file tree
Showing 17 changed files with 175 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/cybele.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
require 'cybele/helpers/show_for'
require 'cybele/helpers/recipient_interceptor'
require 'cybele/helpers/haml'
require 'cybele/helpers/locale_language'
require 'cybele/app_builder'
1 change: 1 addition & 0 deletions lib/cybele/app_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class AppBuilder < Rails::AppBuilder
include Cybele::Helpers::RecipientInterceptor
include Cybele::Helpers::ShowFor
include Cybele::Helpers::Haml
include Cybele::Helpers::LocaleLanguage

def readme
template 'README.md.erb',
Expand Down
5 changes: 5 additions & 0 deletions lib/cybele/generators/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ def setup_rollbar
build :generate_rollbar
end

def configure_locale_language
say 'Configure locale', :green
build :configure_locale_language
end

def setup_show_for
return if @options[:skip_show_for]
say 'Generate show_for', :green
Expand Down
17 changes: 17 additions & 0 deletions lib/cybele/helpers/locale_language.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module Cybele
module Helpers
module LocaleLanguage
def configure_locale_language
copy_file 'config/locales/tr.yml', 'config/locales/tr.yml'
copy_file 'config/locales/email.tr.yml', 'config/locales/email.tr.yml'
copy_file 'config/locales/models.tr.yml', 'config/locales/models.tr.yml'
copy_file 'config/locales/view.tr.yml', 'config/locales/view.tr.yml'
copy_file 'config/locales/email.en.yml', 'config/locales/email.en.yml'
copy_file 'config/locales/models.en.yml', 'config/locales/models.en.yml'
copy_file 'config/locales/view.en.yml', 'config/locales/view.en.yml'
end
end
end
end
1 change: 1 addition & 0 deletions lib/cybele/helpers/responders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def configure_responders

# Remove comments in locale/responders.yml
uncomment_lines 'config/locales/responders.en.yml', /alert:/
copy_file 'config/locales/responders.tr.yml', 'config/locales/responders.tr.yml'
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions lib/cybele/helpers/show_for.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ module ShowFor
def configure_show_for
# Run the show_for generator
bundle_command 'exec rails generate show_for:install'
# Remove show_for english file
remove_file 'config/locales/show_for.en.yml', force: true

# Add show_for turkish file
copy_file 'config/locales/show_for.tr.yml', 'config/locales/show_for.tr.yml'
end
Expand Down
2 changes: 0 additions & 2 deletions lib/cybele/helpers/simple_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ module SimpleForm
def configure_simple_form
# Run the simple_form generator
bundle_command 'exec rails generate simple_form:install --bootstrap -force'
# Remove simple_form english file
remove_file 'config/locales/simple_form.en.yml', force: true
# Add simple_form turkish file
copy_file 'config/locales/simple_form.tr.yml', 'config/locales/simple_form.tr.yml'
end
Expand Down
44 changes: 43 additions & 1 deletion spec/features/new_default_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
expect(controller_file).to match('self.responder = ApplicationResponder')
expect(controller_file).to match('respond_to :html, :js, :json')

locale_file = content('config/locales/responders.en.yml')
expect(File).to exist(file_project_path('config/locales/responders.en.yml'))
expect(File).to exist(file_project_path('config/locales/responders.tr.yml'))
locale_file = content('config/locales/responders.tr.yml')
expect(locale_file).not_to match('# alert:')
expect(locale_file).to match('create:')
expect(locale_file).to match('update:')
Expand Down Expand Up @@ -122,6 +124,9 @@
config_show_for_file = content('config/initializers/show_for.rb')
expect(config_show_for_file).to match(/^ShowFor.setup/)

show_for_en_yml_file = content('config/locales/show_for.en.yml')
expect(show_for_en_yml_file).to match('show_for')

show_for_tr_yml_file = content('config/locales/show_for.tr.yml')
expect(show_for_tr_yml_file).to match('show_for')
end
Expand Down Expand Up @@ -151,6 +156,40 @@
expect(config_staging_file).to match('RecipientInterceptor.new')
end

it 'uses locale_language' do
expect(File).to exist(file_project_path('config/locales/en.yml'))
expect(File).to exist(file_project_path('config/locales/tr.yml'))
locale_file = content('config/locales/tr.yml')
expect(locale_file).to match('phone:')
expect(locale_file).to match('date:')
expect(locale_file).to match('time:')
expect(locale_file).to match('number:')

expect(File).to exist(file_project_path('config/locales/email.en.yml'))
locale_file = content('config/locales/email.en.yml')
expect(locale_file).to match('email:')

expect(File).to exist(file_project_path('config/locales/email.tr.yml'))
locale_file = content('config/locales/email.tr.yml')
expect(locale_file).to match('email:')

expect(File).to exist(file_project_path('config/locales/models.en.yml'))
locale_file = content('config/locales/models.en.yml')
expect(locale_file).to match('activerecord:')

expect(File).to exist(file_project_path('config/locales/models.tr.yml'))
locale_file = content('config/locales/models.tr.yml')
expect(locale_file).to match('activerecord:')

expect(File).to exist(file_project_path('config/locales/view.en.yml'))
locale_file = content('config/locales/view.en.yml')
expect(locale_file).to match('view:')

expect(File).to exist(file_project_path('config/locales/view.tr.yml'))
locale_file = content('config/locales/view.tr.yml')
expect(locale_file).to match('view:')
end

it 'uses simple_form' do
gemfile_file = content('Gemfile')
expect(gemfile_file).to match(/^gem 'simple_form'/)
Expand All @@ -161,6 +200,9 @@
simple_form_bootstrap_file = content('config/initializers/simple_form_bootstrap.rb')
expect(simple_form_bootstrap_file).to match(/^SimpleForm.setup/)

simple_form_en_yml_file = content('config/locales/simple_form.en.yml')
expect(simple_form_en_yml_file).to match('simple_form')

simple_form_tr_yml_file = content('config/locales/simple_form.tr.yml')
expect(simple_form_tr_yml_file).to match('simple_form')
end
Expand Down
41 changes: 40 additions & 1 deletion spec/features/new_not_default_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
expect(controller_file).to match('self.responder = ApplicationResponder')
expect(controller_file).to match('respond_to :html, :js, :json')

locale_file = content('config/locales/responders.en.yml')
expect(File).to exist(file_project_path('config/locales/responders.en.yml'))
expect(File).to exist(file_project_path('config/locales/responders.tr.yml'))
locale_file = content('config/locales/responders.tr.yml')
expect(locale_file).not_to match('# alert:')
expect(locale_file).to match('create:')
expect(locale_file).to match('update:')
Expand Down Expand Up @@ -112,6 +114,7 @@
expect(gemfile_file).not_to match(/^gem 'show_for'/)

expect(File).not_to exist(file_project_path('config/initializers/show_for.rb'))
expect(File).not_to exist(file_project_path('config/locales/show_for.en.yml'))
expect(File).not_to exist(file_project_path('config/locales/show_for.tr.yml'))
end

Expand All @@ -132,6 +135,41 @@
expect(config_test_file).to match(/^Rails.application.configure/)
end

it 'uses locale_language' do
expect(File).to exist(file_project_path('config/locales/en.yml'))
expect(File).to exist(file_project_path('config/locales/tr.yml'))
locale_file = content('config/locales/tr.yml')
expect(locale_file).to match('phone:')
expect(locale_file).to match('date:')
expect(locale_file).to match('time:')
expect(locale_file).to match('number:')

expect(File).to exist(file_project_path('config/locales/email.en.yml'))
locale_file = content('config/locales/email.en.yml')
expect(locale_file).to match('email:')

expect(File).to exist(file_project_path('config/locales/email.tr.yml'))
locale_file = content('config/locales/email.tr.yml')
expect(locale_file).to match('email:')

expect(File).to exist(file_project_path('config/locales/models.en.yml'))
locale_file = content('config/locales/models.en.yml')
expect(locale_file).to match('activerecord:')

expect(File).to exist(file_project_path('config/locales/models.tr.yml'))
locale_file = content('config/locales/models.tr.yml')
expect(locale_file).to match('activerecord:')

expect(File).to exist(file_project_path('config/locales/view.en.yml'))
locale_file = content('config/locales/view.en.yml')
expect(locale_file).to match('view:')

expect(File).to exist(file_project_path('config/locales/view.tr.yml'))
locale_file = content('config/locales/view.tr.yml')
expect(locale_file).to match('view:')
end


it 'uses recipient_interceptor' do
gemfile_file = content('Gemfile')
expect(gemfile_file).to match(/^gem 'recipient_interceptor'/)
Expand All @@ -146,6 +184,7 @@

expect(File).not_to exist(file_project_path('config/initializers/simple_form.rb'))
expect(File).not_to exist(file_project_path('config/initializers/simple_form_bootstrap.rb'))
expect(File).not_to exist(file_project_path('config/locales/simple_form.en.yml'))
expect(File).not_to exist(file_project_path('config/locales/simple_form.tr.yml'))
end

Expand Down
5 changes: 5 additions & 0 deletions templates/config/locales/email.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
en:
email:
salut: 'Hello %{user};'
hello: 'Hello;'
5 changes: 5 additions & 0 deletions templates/config/locales/email.tr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
tr:
email:
salut: 'Merhaba %{user};'
hello: 'Merhaba;'
2 changes: 2 additions & 0 deletions templates/config/locales/models.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
en:
activerecord:
2 changes: 2 additions & 0 deletions templates/config/locales/models.tr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tr:
activerecord:
14 changes: 14 additions & 0 deletions templates/config/locales/responders.tr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
tr:
flash:
actions:
toggle_is_active:
passive: '%{resource_name} başarıyla pasif edildi.'
active: '%{resource_name} başarıyla aktif edildi.'
create:
notice: '%{resource_name} başarı ile yaratıldı.'
update:
notice: '%{resource_name} başarı ile güncellendi.'
destroy:
notice: '%{resource_name} başarı ile silindi.'
alert: '%{resource_name} silinemedi.'
34 changes: 34 additions & 0 deletions templates/config/locales/tr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
tr:
phone:
formats:
long: '+99 (999) 999-9999'
date:
formats:
excel:
rails: '%d/%m/%Y'
datepicker:
rails: '%d/%m/%Y'
js: 'd/m/Y'
default: "%d/%m/%Y"
year_month: "%Y-%B"
date: '%d %B %Y'
time:
formats:
certificate_completed_at_english: '%m/%d/%Y'
certificate_completed_at: '%d/%m/%Y'
datetimepicker_rails: '%d/%m/%Y %H:%M'
datetimepicker:
rails: '%d/%m/%Y %H:%M'
js: 'd/m/Y H:i'
default: "%d/%m/%Y %H:%M"
year_month: "%Y-%B"
date: '%d %B %Y'
due_at:
rails: '%d/%m/%Y %H:%M'
js: 'd/m/Y H:i'
number:
currency:
format:
format: "%u %n"
unit: ""
2 changes: 2 additions & 0 deletions templates/config/locales/view.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
en:
view:
2 changes: 2 additions & 0 deletions templates/config/locales/view.tr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tr:
view:

0 comments on commit 34c2630

Please sign in to comment.