Commit 00b06a4dafa6bf4274f5d7ef14c6b7cdf5458e0b
Committed by
Rafael Manzo
1 parent
3444bb93
Exists in
colab
and in
4 other branches
Added set_locale to application controller and first locale translations
Signed off by: Daniel Alves <danpaulalves@gmail.com>
Showing
2 changed files
with
20 additions
and
5 deletions
Show diff stats
app/controllers/application_controller.rb
| ... | ... | @@ -6,16 +6,21 @@ class ApplicationController < ActionController::Base |
| 6 | 6 | add_flash_types :error, :alert |
| 7 | 7 | |
| 8 | 8 | before_filter :configure_permitted_parameters, if: :devise_controller? |
| 9 | + before_filter :set_locale | |
| 9 | 10 | |
| 10 | 11 | protected |
| 11 | 12 | |
| 12 | - # We don't have how too test this unless we have the Devise controllers. | |
| 13 | - # Since creating the controllers looks wronger than not testing this two | |
| 14 | - # lines. I think we can live without 100% of coverage | |
| 15 | 13 | # :nocov: |
| 16 | 14 | def configure_permitted_parameters |
| 17 | 15 | devise_parameter_sanitizer.for(:sign_up) << :name |
| 18 | 16 | devise_parameter_sanitizer.for(:account_update) << :name |
| 19 | 17 | end |
| 20 | - # :nocov: | |
| 18 | + | |
| 19 | + def set_locale | |
| 20 | + if (params[:locale]) | |
| 21 | + I18n.locale = params[:locale] | |
| 22 | + else | |
| 23 | + I18n.locale = I18n.default_locale | |
| 24 | + end | |
| 25 | + end | |
| 21 | 26 | end | ... | ... |
config/locales/en.yml
| ... | ... | @@ -20,4 +20,14 @@ |
| 20 | 20 | # available at http://guides.rubyonrails.org/i18n.html. |
| 21 | 21 | |
| 22 | 22 | en: |
| 23 | - hello: "Hello world" | |
| 23 | + successfully_created: "%{record} was successfully created." | |
| 24 | + successfully_updated: "%{record} was successfully updated." | |
| 25 | + | |
| 26 | + #class names | |
| 27 | + MetricConfiguration: "Metric Configuration" | |
| 28 | + CompoundMetricConfiguration: "Compound Metric Configuration" | |
| 29 | + KalibroRange: "Range" | |
| 30 | + ReadingGroup: "Reading Group" | |
| 31 | + Repository: "Repository" | |
| 32 | + Project: "Project" | |
| 33 | + Reading: "Reading" | ... | ... |