Commit c01d14f
Changed files (10)
app
assets
stylesheets
controllers
views
layouts
registrations
config
locales
spec
app/assets/stylesheets/application.css → app/assets/stylesheets/application.scss
File renamed without changes
app/controllers/registrations_controller.rb
@@ -4,12 +4,12 @@ class RegistrationsController < ApplicationController
end
def create
- user = User.new(secure_params)
- if user.save
- log_in(user)
+ @user = User.new(secure_params)
+ if @user.save
+ log_in(@user)
redirect_to dashboard_path
else
- flash[:error] = user.errors.full_messages
+ flash.now[:error] = @user.errors.full_messages
render :new
end
end
app/views/layouts/_flash.html.erb
@@ -0,0 +1,14 @@
+<% if flash.any? %>
+ <div class="row">
+ <% flash.each do |name, errors| %>
+ <div data-alert class="alert-box <%= name %>">
+ <ul>
+ <% errors.each do |error| %>
+ <%= content_tag :li, error %>
+ <% end %>
+ </ul>
+ <a href="#" class="close">×</a>
+ </div>
+ <% end %>
+ </div>
+<% end %>
app/views/layouts/application.html.erb
@@ -9,7 +9,8 @@
<%= csrf_meta_tags %>
</head>
<body>
+ <%= render partial: 'layouts/flash' %>
<%= yield %>
<%= javascript_include_tag "application" %>
</body>
-</html>
\ No newline at end of file
+</html>
app/views/registrations/new.html.erb
@@ -1,27 +1,25 @@
<div class="row">
<%= form_for @user, url: registrations_path do |f| %>
- <div class="small-12 columns">
- <label>Username
- <%= f.text_field :username, placeholder: "Username" %>
- </label>
- </div> <!-- /.small-12 -->
- <div class="small-12 columns">
- <label>Email
- <%= f.email_field :email, placeholder: "Email" %>
- </label>
- </div> <!-- /.small-12 -->
- <div class="small-12 columns">
- <label>Password
- <%= f.password_field :password, placeholder: "Password" %>
- </label>
- </div> <!-- /.small-12 -->
- <div class="small-12 columns">
- <label>I Agree
- <%= f.check_box :terms_and_conditions %>
- </label>
- </div> <!-- /.small-12 -->
- <div class="small-12 columns">
- <%= f.submit "Register", class: "button" %>
- </div> <!-- /.small-12 -->
+ <div class="small-12 columns">
+ <label><%= t('.username') %>
+ <%= f.text_field :username, placeholder: t('.username') %>
+ </label>
+ </div> <!-- /.small-12 -->
+ <div class="small-12 columns">
+ <label><%= t('.email') %>
+ <%= f.email_field :email, placeholder: t('.email') %>
+ </label>
+ </div> <!-- /.small-12 -->
+ <div class="small-12 columns">
+ <label><% t('.password') %>
+ <%= f.password_field :password, placeholder: t('.password') %>
+ </label>
+ </div> <!-- /.small-12 -->
+ <div class="small-12 columns">
+ <label> <%= f.check_box :terms_and_conditions %> <%= t('.terms_and_conditions') %> </label>
+ </div> <!-- /.small-12 -->
+ <div class="small-12 columns">
+ <%= f.submit t('.register_button'), class: "button" %>
+ </div> <!-- /.small-12 -->
<% end %>
</div> <!-- /.row -->
config/locales/en.yml
@@ -20,4 +20,10 @@
# available at http://guides.rubyonrails.org/i18n.html.
en:
- hello: "Hello world"
+ registrations:
+ new:
+ username: "Username"
+ email: "Email"
+ password: "Password"
+ terms_and_conditions: "I Agree"
+ register_button: "Register"
config/i18n-tasks.yml
@@ -0,0 +1,89 @@
+# i18n-tasks finds and manages missing and unused translations https://github.com/glebm/i18n-tasks
+
+base_locale: en
+## i18n-tasks detects locales automatically from the existing locale files
+## uncomment to set locales explicitly
+# locales: [en, es, fr]
+
+## i18n-tasks report locale, default: en, available: en, ru
+# internal_locale: ru
+
+# Read and write locale data
+data:
+ ## by default, translation data are read from the file system, or you can provide a custom data adapter
+ # adapter: I18n::Tasks::Data::FileSystem
+
+ # Locale files to read from
+ read:
+ - config/locales/%{locale}.yml
+ # - config/locales/*.%{locale}.yml
+ # - config/locales/**/*.%{locale}.yml
+
+ # key => file routes, matched top to bottom
+ write:
+ ## E.g., write devise and simple form keys to their respective files
+ # - ['{devise, simple_form}.*', 'config/locales/\1.%{locale}.yml']
+ # Catch-all
+ - config/locales/%{locale}.yml
+ # `i18n-tasks normalize -p` will force move the keys according to these rules
+
+ # YAML / JSON serializer options, passed to load / dump / parse / serialize
+ yaml:
+ write:
+ # do not wrap lines at 80 characters
+ line_width: -1
+ json:
+ write:
+ # pretty print JSON
+ indent: ' '
+ space: ' '
+ object_nl: "\n"
+ array_nl: "\n"
+
+# Find translate calls
+search:
+ ## Default scanner finds t() and I18n.t() calls
+ # scanner: I18n::Tasks::Scanners::PatternWithScopeScanner
+
+ ## Paths to search in, passed to File.find
+ paths:
+ - app/
+
+ ## Root for resolving relative keys (default)
+ # relative_roots:
+ # - app/views
+
+ ## File.fnmatch patterns to exclude from search (default)
+ # exclude: ["*.jpg", "*.png", "*.gif", "*.svg", "*.ico", "*.eot", "*.ttf", "*.woff", "*.pdf"]
+
+ ## Or, File.fnmatch patterns to include
+ # include: ["*.rb", "*.html.slim"]
+
+## Google Translate
+# translation:
+# # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate
+# api_key: "AbC-dEf5"
+
+## Consider these keys not missing
+# ignore_missing:
+# - 'errors.messages.{accepted,blank,invalid,too_short,too_long}'
+# - '{devise,simple_form}.*'
+
+## Consider these keys used
+# ignore_unused:
+# - 'activerecord.attributes.*'
+# - '{devise,kaminari,will_paginate}.*'
+# - 'simple_form.{yes,no}'
+# - 'simple_form.{placeholders,hints,labels}.*'
+# - 'simple_form.{error_notification,required}.:'
+
+## Exclude these keys from `i18n-tasks eq-base' report
+# ignore_eq_base:
+# all:
+# - common.ok
+# fr,es:
+# - common.brand
+
+## Exclude these keys from all of the reports
+# ignore:
+# - kaminari.*
spec/i18n_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper'
+require 'i18n/tasks'
+
+describe 'I18n' do
+ let(:i18n) { I18n::Tasks::BaseTask.new }
+ let(:missing_keys) { i18n.missing_keys }
+ let(:unused_keys) { i18n.unused_keys }
+
+ it 'does not have missing keys' do
+ expect(missing_keys).to be_empty,
+ "Missing #{missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them"
+ end
+
+ it 'does not have unused keys' do
+ expect(unused_keys).to be_empty,
+ "#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them"
+ end
+end
Gemfile
@@ -45,5 +45,6 @@ group :development, :test do
gem 'spring'
gem 'rspec-rails'
gem 'foreman'
+ gem 'i18n-tasks'
end
Gemfile.lock
@@ -56,6 +56,10 @@ GEM
debugger-linecache (1.2.0)
diff-lcs (1.2.5)
dotenv (1.0.2)
+ easy_translate (0.5.0)
+ json
+ thread
+ thread_safe
email_validator (1.5.0)
activemodel
erubis (2.7.0)
@@ -68,8 +72,18 @@ GEM
sass (>= 3.2.0)
globalid (0.3.0)
activesupport (>= 4.1.0)
+ highline (1.6.21)
hike (1.2.3)
i18n (0.7.0)
+ i18n-tasks (0.7.10)
+ activesupport
+ easy_translate (>= 0.5.0)
+ erubis
+ highline
+ i18n
+ slop (>= 3.5.0)
+ term-ansicolor
+ terminal-table
jbuilder (2.2.6)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
@@ -156,9 +170,14 @@ GEM
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
+ term-ansicolor (1.3.0)
+ tins (~> 1.0)
+ terminal-table (1.4.5)
thor (0.19.1)
+ thread (0.1.4)
thread_safe (0.3.4)
tilt (1.4.1)
+ tins (1.3.3)
turbolinks (2.5.3)
coffee-rails
tzinfo (1.2.2)
@@ -181,6 +200,7 @@ DEPENDENCIES
email_validator
foreman
foundation-rails
+ i18n-tasks
jbuilder (~> 2.0)
jquery-rails
pg