gettext_i18n_rails 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock
CHANGED
@@ -4,4 +4,25 @@ module ActiveModel
|
|
4
4
|
_(@klass.humanize_class_name)
|
5
5
|
end
|
6
6
|
end
|
7
|
+
|
8
|
+
module Translation
|
9
|
+
# CarDealer.sales_count -> s_('CarDealer|Sales count') -> 'Sales count' if no translation was found
|
10
|
+
def human_attribute_name(attribute, *args)
|
11
|
+
s_(gettext_translation_for_attribute_name(attribute))
|
12
|
+
end
|
13
|
+
|
14
|
+
def gettext_translation_for_attribute_name(attribute)
|
15
|
+
attribute = attribute.to_s
|
16
|
+
if attribute.ends_with?('_id')
|
17
|
+
humanize_class_name(attribute)
|
18
|
+
else
|
19
|
+
"#{self}|#{attribute.split('.').map! {|a| a.humanize }.join('|')}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def humanize_class_name(name=nil)
|
24
|
+
name ||= self.to_s
|
25
|
+
name.underscore.humanize
|
26
|
+
end
|
27
|
+
end
|
7
28
|
end
|
@@ -1,25 +1,8 @@
|
|
1
1
|
module GettextI18nRails::ActiveRecord
|
2
|
-
|
3
|
-
def human_attribute_name(attribute, *args)
|
4
|
-
s_(gettext_translation_for_attribute_name(attribute))
|
5
|
-
end
|
2
|
+
include ActiveModel::Translation
|
6
3
|
|
7
4
|
# method deprecated in Rails 3.1
|
8
5
|
def human_name(*args)
|
9
6
|
_(self.humanize_class_name)
|
10
7
|
end
|
11
|
-
|
12
|
-
def humanize_class_name(name=nil)
|
13
|
-
name ||= self.to_s
|
14
|
-
name.underscore.humanize
|
15
|
-
end
|
16
|
-
|
17
|
-
def gettext_translation_for_attribute_name(attribute)
|
18
|
-
attribute = attribute.to_s
|
19
|
-
if attribute.ends_with?('_id')
|
20
|
-
humanize_class_name(attribute)
|
21
|
-
else
|
22
|
-
"#{self}|#{attribute.split('.').map! {|a| a.humanize }.join('|')}"
|
23
|
-
end
|
24
|
-
end
|
25
8
|
end
|
@@ -13,7 +13,6 @@ if defined?(Rails::Railtie)
|
|
13
13
|
config.after_initialize do |app|
|
14
14
|
if app.config.gettext_i18n_rails.use_for_active_record_attributes
|
15
15
|
ActiveSupport.on_load :active_record do
|
16
|
-
extend GettextI18nRails::ActiveRecord
|
17
16
|
require 'gettext_i18n_rails/active_model.rb'
|
18
17
|
end
|
19
18
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gettext_i18n_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 4
|
10
|
+
version: 0.5.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Grosser
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-05-
|
18
|
+
date: 2012-05-24 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: fast_gettext
|