diff options
| author | Zog | 2018-03-16 16:35:13 +0100 | 
|---|---|---|
| committer | Zog | 2018-03-16 16:41:27 +0100 | 
| commit | ac69f1295251a62bf617f8e31dfd772d44854cb3 (patch) | |
| tree | 63aa3a17fa824a19ffc706cbc87eb8c50456b6e4 | |
| parent | 79bf79f39bc9dc26cbd594f80c35b0d5559e610c (diff) | |
| download | chouette-core-enhanced-i18n.tar.bz2 | |
Refs #6238; Update `t_action` method to handle the 'update' and 'create' actionsenhanced-i18n
| -rw-r--r-- | config/initializers/i18n.rb | 13 | 
1 files changed, 11 insertions, 2 deletions
| diff --git a/config/initializers/i18n.rb b/config/initializers/i18n.rb index 21fff6ff2..02d42f899 100644 --- a/config/initializers/i18n.rb +++ b/config/initializers/i18n.rb @@ -136,10 +136,19 @@ class ActiveRecord::Base    # Translate the given action on the model, with default    def self.t_action(action, params={}) +    key = case action.to_sym +    when :create +      :new +    when :update +      :edit +    else +      action +    end +      begin -      I18n.translate_without_fallback "#{i18n_key.pluralize}.actions.#{action}", ({raise: true}.update(params)) +      I18n.translate_without_fallback "#{i18n_key.pluralize}.actions.#{key}", ({raise: true}.update(params))      rescue -      I18n.translate_without_fallback "actions.#{action}", params +      I18n.translate_without_fallback "actions.#{key}", params      end    end | 
