gettext_i18n_rails 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.6
|
data/gettext_i18n_rails.gemspec
CHANGED
data/lib/gettext_i18n_rails.rb
CHANGED
@@ -22,6 +22,12 @@ require 'gettext_i18n_rails/backend'
|
|
22
22
|
I18n.backend = GettextI18nRails::Backend.new
|
23
23
|
|
24
24
|
require 'gettext_i18n_rails/i18n_hacks'
|
25
|
-
|
25
|
+
|
26
|
+
require 'gettext_i18n_rails/active_record'
|
27
|
+
# If configuration via Railties is not available force activerecord extensions
|
28
|
+
if not defined?(Rails::Railtie) and defined?(ActiveRecord)
|
29
|
+
ActiveRecord::Base.extend GettextI18nRails::ActiveRecord
|
30
|
+
end
|
31
|
+
|
26
32
|
require 'gettext_i18n_rails/action_controller' if defined?(ActionController) # so that bundle console can work in a rails project
|
27
33
|
require 'gettext_i18n_rails/railtie'
|
@@ -1,21 +1,21 @@
|
|
1
|
-
|
1
|
+
module GettextI18nRails::ActiveRecord
|
2
2
|
# CarDealer.sales_count -> s_('CarDealer|Sales count') -> 'Sales count' if no translation was found
|
3
|
-
def
|
3
|
+
def human_attribute_name(attribute, *args)
|
4
4
|
s_(gettext_translation_for_attribute_name(attribute))
|
5
5
|
end
|
6
6
|
|
7
7
|
# CarDealer -> _('car dealer')
|
8
|
-
def
|
8
|
+
def human_name(*args)
|
9
9
|
_(self.human_name_without_translation)
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def human_name_without_translation
|
13
13
|
self.to_s.underscore.gsub('_',' ')
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
def
|
18
|
+
def gettext_translation_for_attribute_name(attribute)
|
19
19
|
"#{self}|#{attribute.to_s.split('.').map! {|a| a.gsub('_',' ').capitalize }.join('|')}"
|
20
20
|
end
|
21
21
|
end
|
@@ -4,9 +4,19 @@ if defined?(Rails::Railtie)
|
|
4
4
|
class Railtie < ::Rails::Railtie
|
5
5
|
config.gettext_i18n_rails = ActiveSupport::OrderedOptions.new
|
6
6
|
config.gettext_i18n_rails.msgmerge = %w[--sort-output --no-location --no-wrap]
|
7
|
+
config.gettext_i18n_rails.use_for_active_record_attributes = true
|
8
|
+
|
7
9
|
rake_tasks do
|
8
10
|
require 'gettext_i18n_rails/tasks'
|
9
11
|
end
|
12
|
+
|
13
|
+
config.after_initialize do |app|
|
14
|
+
if app.config.gettext_i18n_rails.use_for_active_record_attributes
|
15
|
+
ActiveSupport.on_load :active_record do
|
16
|
+
extend GettextI18nRails::ActiveRecord
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
10
20
|
end
|
11
21
|
end
|
12
22
|
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: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 6
|
10
|
+
version: 0.3.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Grosser
|