rich_i18n 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1 -1
- data/README.textile +56 -29
- data/Rakefile +22 -8
- data/VERSION +1 -1
- data/{lib/app → app}/views/rich_i18n.html.erb +0 -0
- data/{lib/assets → assets}/jzip/jquery/core.jz +0 -0
- data/{lib/assets → assets}/jzip/jquery/extensions/modules.js +0 -0
- data/{lib/assets → assets}/jzip/jquery/seat_holder.js +31 -31
- data/{lib/assets → assets}/jzip/rich.js +0 -0
- data/{lib/assets → assets}/jzip/rich/i18n.js +2 -2
- data/{lib/assets → assets}/jzip/rich_i18n.jz +0 -0
- data/lib/generators/rich.rb +25 -0
- data/lib/generators/rich/translation/templates/migration.rb +18 -0
- data/lib/generators/rich/translation/templates/model.rb +7 -0
- data/lib/generators/rich/translation/translation_generator.rb +59 -0
- data/lib/rich/i18n.rb +2 -2
- data/lib/rich/i18n/actionpack.rb +0 -1
- data/lib/rich/i18n/actionpack/action_controller/base.rb +3 -3
- data/lib/rich/i18n/actionpack/action_view/base.rb +3 -3
- data/lib/rich/i18n/actionpack/action_view/sanitizor.rb +14 -20
- data/lib/rich/i18n/activesupport.rb +1 -0
- data/lib/rich/i18n/activesupport/active_support/dependencies.rb +12 -0
- data/lib/rich/i18n/core/array.rb +0 -2
- data/lib/rich/i18n/core/array/merging.rb +5 -7
- data/lib/rich/i18n/core/enriched_string.rb +68 -25
- data/lib/rich/i18n/core/object.rb +2 -2
- data/lib/rich/i18n/core/object/enriched.rb +16 -0
- data/lib/rich/i18n/core/string.rb +4 -2
- data/lib/rich/i18n/core/{object/output.rb → string/enriched.rb} +8 -8
- data/lib/rich/i18n/core/string/html_safe.rb +18 -0
- data/lib/rich/i18n/core/string/inflections.rb +9 -9
- data/lib/rich/i18n/core/string/internationalization.rb +20 -18
- data/lib/rich/i18n/core/symbol/internationalization.rb +2 -2
- data/lib/rich/i18n/engine.rb +71 -61
- data/lib/rich/i18n/formtastic.rb +15 -13
- data/lib/rich/i18n/rails.rb +1 -0
- data/lib/rich/i18n/rails/engine.rb +5 -0
- data/lib/rich_i18n.rb +3 -3
- data/locales/nl.yml +3 -3
- data/rails_generators/rich_i18n_translation/rich_i18n_translation_generator.rb +3 -3
- data/rails_generators/rich_i18n_translation/templates/migration.rb +1 -1
- data/rails_generators/rich_i18n_translation/templates/model.rb +2 -2
- data/rich_i18n.gemspec +159 -33
- data/test/rails-2/dummy/Gemfile +5 -0
- data/test/rails-2/dummy/Gemfile.lock +50 -0
- data/test/rails-2/dummy/Rakefile +10 -0
- data/test/rails-2/dummy/app/controllers/application_controller.rb +10 -0
- data/test/rails-2/dummy/app/helpers/application_helper.rb +3 -0
- data/test/rails-2/dummy/config/boot.rb +124 -0
- data/test/rails-2/dummy/config/database.yml +22 -0
- data/test/rails-2/dummy/config/environment.rb +41 -0
- data/test/rails-2/dummy/config/environments/development.rb +17 -0
- data/test/rails-2/dummy/config/environments/production.rb +28 -0
- data/test/rails-2/dummy/config/environments/test.rb +28 -0
- data/test/rails-2/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails-2/dummy/config/initializers/cookie_verification_secret.rb +7 -0
- data/test/rails-2/dummy/config/initializers/inflections.rb +10 -0
- data/test/rails-2/dummy/config/initializers/mime_types.rb +5 -0
- data/test/rails-2/dummy/config/initializers/new_rails_defaults.rb +21 -0
- data/test/rails-2/dummy/config/initializers/session_store.rb +15 -0
- data/test/rails-2/dummy/config/locales/en.yml +5 -0
- data/test/rails-2/dummy/config/preinitializer.rb +20 -0
- data/test/rails-2/dummy/config/routes.rb +43 -0
- data/test/rails-2/dummy/db/seeds.rb +7 -0
- data/test/rails-2/dummy/db/test.sqlite3 +0 -0
- data/test/rails-2/dummy/log/development.log +0 -0
- data/test/rails-2/dummy/log/production.log +0 -0
- data/test/rails-2/dummy/log/server.log +0 -0
- data/test/rails-2/dummy/log/test.log +0 -0
- data/test/rails-2/dummy/public/404.html +30 -0
- data/test/rails-2/dummy/public/422.html +30 -0
- data/test/rails-2/dummy/public/500.html +30 -0
- data/test/rails-2/dummy/public/favicon.ico +0 -0
- data/test/rails-2/dummy/public/images/rails.png +0 -0
- data/test/rails-2/dummy/public/index.html +275 -0
- data/test/rails-2/dummy/public/javascripts/application.js +2 -0
- data/test/rails-2/dummy/public/javascripts/controls.js +963 -0
- data/test/rails-2/dummy/public/javascripts/dragdrop.js +973 -0
- data/test/rails-2/dummy/public/javascripts/effects.js +1128 -0
- data/test/rails-2/dummy/public/javascripts/prototype.js +4320 -0
- data/test/rails-2/dummy/public/robots.txt +5 -0
- data/test/rails-2/dummy/script/about +4 -0
- data/test/rails-2/dummy/script/console +3 -0
- data/test/rails-2/dummy/script/dbconsole +3 -0
- data/test/rails-2/dummy/script/destroy +3 -0
- data/test/rails-2/dummy/script/generate +3 -0
- data/test/rails-2/dummy/script/performance/benchmarker +3 -0
- data/test/rails-2/dummy/script/performance/profiler +3 -0
- data/test/rails-2/dummy/script/plugin +3 -0
- data/test/rails-2/dummy/script/runner +3 -0
- data/test/rails-2/dummy/script/server +3 -0
- data/test/rails-2/test_helper.rb +5 -0
- data/test/rails-3/dummy/Gemfile +5 -0
- data/test/rails-3/dummy/Gemfile.lock +93 -0
- data/test/rails-3/dummy/Rakefile +7 -0
- data/test/rails-3/dummy/app/controllers/application_controller.rb +3 -0
- data/test/rails-3/dummy/app/helpers/application_helper.rb +2 -0
- data/test/rails-3/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/rails-3/dummy/config.ru +4 -0
- data/test/rails-3/dummy/config/application.rb +44 -0
- data/test/rails-3/dummy/config/boot.rb +10 -0
- data/test/rails-3/dummy/config/database.yml +22 -0
- data/test/rails-3/dummy/config/environment.rb +5 -0
- data/test/rails-3/dummy/config/environments/development.rb +26 -0
- data/test/rails-3/dummy/config/environments/production.rb +49 -0
- data/test/rails-3/dummy/config/environments/test.rb +35 -0
- data/test/rails-3/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails-3/dummy/config/initializers/inflections.rb +10 -0
- data/test/rails-3/dummy/config/initializers/mime_types.rb +5 -0
- data/test/rails-3/dummy/config/initializers/secret_token.rb +7 -0
- data/test/rails-3/dummy/config/initializers/session_store.rb +8 -0
- data/test/rails-3/dummy/config/locales/en.yml +5 -0
- data/test/rails-3/dummy/config/routes.rb +58 -0
- data/test/rails-3/dummy/db/test.sqlite3 +0 -0
- data/test/rails-3/dummy/log/development.log +0 -0
- data/test/rails-3/dummy/log/production.log +0 -0
- data/test/rails-3/dummy/log/server.log +0 -0
- data/test/rails-3/dummy/log/test.log +0 -0
- data/test/rails-3/dummy/public/404.html +26 -0
- data/test/rails-3/dummy/public/422.html +26 -0
- data/test/rails-3/dummy/public/500.html +26 -0
- data/test/rails-3/dummy/public/favicon.ico +0 -0
- data/test/rails-3/dummy/public/javascripts/application.js +2 -0
- data/test/rails-3/dummy/public/javascripts/controls.js +965 -0
- data/test/rails-3/dummy/public/javascripts/dragdrop.js +974 -0
- data/test/rails-3/dummy/public/javascripts/effects.js +1123 -0
- data/test/rails-3/dummy/public/javascripts/prototype.js +6001 -0
- data/test/rails-3/dummy/public/javascripts/rails.js +175 -0
- data/test/rails-3/dummy/public/stylesheets/.gitkeep +0 -0
- data/test/rails-3/dummy/script/rails +6 -0
- data/test/rails-3/test_helper.rb +8 -0
- data/test/tests/core/array/merging_test.rb +14 -0
- data/test/tests/core/enriched_string_test.rb +20 -0
- data/test/tests/core/string/inflections_test.rb +32 -0
- data/test/tests/core/string/merging_test.rb +15 -0
- data/test/tests/locales/nl/internationalization_test.rb +55 -0
- metadata +183 -44
- data/lib/rich/i18n/actionpack/action_controller/dispatcher.rb +0 -12
- data/lib/rich/i18n/core/enumerable/methods.rb +0 -16
- data/lib/rich/i18n/core/hash.rb +0 -6
- data/lib/rich/i18n/core/nil_class.rb +0 -8
- data/lib/rich/i18n/core/string/enrichments.rb +0 -66
- data/test/core/string/inflections_test.rb +0 -42
- data/test/core/string/internationalization_test.rb +0 -23
- data/test/engine_test.rb +0 -20
- data/test/locales/nl/internationalization_test.rb +0 -47
- data/test/setup.rb +0 -14
- data/test/test_helper.rb +0 -5
@@ -4,37 +4,37 @@ module Rich
|
|
4
4
|
module Core
|
5
5
|
module String
|
6
6
|
module Inflections
|
7
|
-
|
7
|
+
|
8
8
|
# -- start FIXME: these methods are also defined in rich_pluralization
|
9
|
-
|
9
|
+
|
10
10
|
def upcase_first
|
11
11
|
empty? ?
|
12
12
|
self :
|
13
13
|
self[0].chr.capitalize + self[1, size]
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def cp_case(s)
|
17
17
|
send((:downcase unless s.dup.downcase!) || (:upcase unless s.dup.upcase!) || (:upcase_first unless s.dup.upcase_first!) || :to_s)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def upcase_first!
|
21
21
|
self == (result = upcase_first) ? nil : replace(result)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def cp_case!(s)
|
25
25
|
self == (result = cp_case(s)) ? nil : replace(result)
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
# -- end
|
29
|
-
|
29
|
+
|
30
30
|
def singularize!
|
31
31
|
downcase == (result = singularize).downcase ? nil : replace(result)
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
def pluralize!
|
35
35
|
downcase == (result = pluralize).downcase ? nil : replace(result)
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -12,24 +12,24 @@ module Rich
|
|
12
12
|
cattr_accessor :i18n_translations
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
module ClassMethods
|
17
17
|
def clear_translations
|
18
18
|
i18n_translations.clear
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
module InstanceMethods
|
23
23
|
def t(options = {})
|
24
24
|
self.split(" ").inject([]) do |array, string|
|
25
25
|
key = string.include?(".") ? string.dup : "word.#{string}"
|
26
26
|
default = key.split(".").last
|
27
27
|
translating_word = key.starts_with?("word.")
|
28
|
-
|
28
|
+
|
29
29
|
key.downcase! unless string.match(/^(label|seatholder)\./)
|
30
30
|
|
31
31
|
options[:pluralize] = "".respond_to?(:pl) && (options[:pluralize].nil? || options[:pluralize])
|
32
|
-
options[:translate_callback] ||= LOGGER_PROC if
|
32
|
+
options[:translate_callback] ||= LOGGER_PROC if Rails.env.development?
|
33
33
|
|
34
34
|
if options.include? :default
|
35
35
|
options[:default] = [options[:default]].flatten << default.humanize
|
@@ -39,14 +39,14 @@ module Rich
|
|
39
39
|
else
|
40
40
|
s = i18n_t key, options.merge({:default => translating_word ? "" : default.humanize})
|
41
41
|
value = s.dup
|
42
|
-
|
42
|
+
|
43
43
|
if translating_word
|
44
44
|
unless (translated = !s.empty?) or !"".respond_to?(:pl)
|
45
45
|
key.singularize!
|
46
46
|
s = i18n_t key, options.merge({:default => ""})
|
47
47
|
value = s.dup
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
if s.empty?
|
51
51
|
s = default.humanize
|
52
52
|
value = s.dup
|
@@ -55,31 +55,33 @@ module Rich
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
unless s.gsub!(/^=\s+/, "") || options[:as].to_s == "html"
|
60
60
|
s.cp_case! options[:capitalize] ? default.capitalize : default
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
array << " " unless array.empty?
|
64
|
-
array << EnrichedString.new(s, options.reject{|k, v|
|
65
|
-
|
64
|
+
array << EnrichedString.new(s, options.reject{|k, v| !RICH_CMS_OPTIONS.include? k.to_s}.merge({:key => key, :value => value, :locale => I18n.locale, :derivative_key => string}))
|
65
|
+
|
66
66
|
end.join
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
private
|
70
70
|
|
71
|
-
RICH_I18N_OPTIONS =
|
72
|
-
|
73
|
-
|
71
|
+
RICH_I18N_OPTIONS = %w(count pluralize capitalize translate_callback)
|
72
|
+
RICH_CMS_OPTIONS = %w(tag html as)
|
73
|
+
|
74
|
+
LOGGER_PROC = Proc.new{|translation, key, options| Rich::I18n::Engine.logger.try :info, "== RICH-I18N: I18n.t #{key.inspect}, #{options.inspect}"}
|
75
|
+
|
74
76
|
@@i18n_translations = {}
|
75
77
|
|
76
78
|
def i18n_t(key, opts = {})
|
77
79
|
options = opts.inject({}) do |hash, (k, v)|
|
78
80
|
# FIXME: this code is to handle interpolated translations... however, this needs to be refactored
|
79
|
-
hash[k] = v.is_a?(String) && v.include?("<i18n") ? v.gsub(/(\<i18n[^\>]+\>)|(\<\/i18n\>)/, "") : v unless RICH_I18N_OPTIONS.include?(k)
|
81
|
+
hash[k] = v.is_a?(String) && v.include?("<i18n") ? v.gsub(/(\<i18n[^\>]+\>)|(\<\/i18n\>)/, "") : v unless (RICH_I18N_OPTIONS + RICH_CMS_OPTIONS).include?(k.to_s)
|
80
82
|
hash
|
81
83
|
end
|
82
|
-
|
84
|
+
|
83
85
|
k = "#{I18n.locale} #{key.inspect}, #{options.inspect}"
|
84
86
|
translation = if Engine.cache_translations
|
85
87
|
((@@i18n_translations[I18n.locale.to_s.downcase] ||= {})[k] ||= I18n.t(key, options)).try :dup
|
@@ -87,11 +89,11 @@ module Rich
|
|
87
89
|
I18n.t key, options
|
88
90
|
end
|
89
91
|
opts[:translate_callback].try :call, translation, key, options
|
90
|
-
|
92
|
+
|
91
93
|
translation
|
92
94
|
end
|
93
95
|
end
|
94
|
-
|
96
|
+
|
95
97
|
end
|
96
98
|
end
|
97
99
|
end
|
data/lib/rich/i18n/engine.rb
CHANGED
@@ -1,74 +1,84 @@
|
|
1
1
|
|
2
2
|
module Rich
|
3
3
|
module I18n
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
4
|
+
class Engine < Rails::Engine
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
attr_accessor :logger, :enable_enriched_output, :cache_translations
|
9
|
+
|
10
|
+
def init(test_locale = nil)
|
11
|
+
@enable_enriched_output = true if @enable_enriched_output.nil?
|
12
|
+
@cache_translations = true if @cache_translations .nil?
|
13
|
+
|
14
|
+
%w(controllers).each do |dir|
|
15
|
+
path = File.join File.dirname(__FILE__), "..", "..", "app", dir
|
16
|
+
$LOAD_PATH << path
|
17
|
+
ActiveSupport::Dependencies.autoload_paths << path
|
18
|
+
ActiveSupport::Dependencies.autoload_once_paths.delete path
|
19
|
+
end
|
20
|
+
|
21
|
+
procedure = proc {
|
22
|
+
::Jzip::Engine.add_template_location({File.expand_path("../../../../assets/jzip", __FILE__) => File.join(Rails.root, "public", "javascripts")})
|
23
|
+
::Formtastic::SemanticFormBuilder.escape_html_entities_in_hints_and_labels = false if ::Formtastic::SemanticFormBuilder.respond_to?(:escape_html_entities_in_hints_and_labels)
|
24
|
+
load_i18n test_locale
|
25
|
+
Rich::I18n::Engine.logger = Rails.logger
|
26
|
+
}
|
27
|
+
|
28
|
+
if Rails::VERSION::MAJOR >= 3
|
29
|
+
config.after_initialize do
|
30
|
+
procedure.call
|
31
|
+
end
|
32
|
+
else
|
33
|
+
procedure.call
|
34
|
+
end
|
35
|
+
|
36
|
+
test_locale
|
18
37
|
end
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
load_i18n test_class
|
24
|
-
end
|
25
|
-
|
26
|
-
def current_controller=(current_controller)
|
27
|
-
@current_controller = current_controller
|
28
|
-
@can_enrich_output = nil
|
29
|
-
end
|
30
|
-
|
31
|
-
def load_i18n(test_class)
|
32
|
-
if test_class
|
33
|
-
test_locale = test_class.name.match(/(Rich\:\:I18n\:\:Test\:\:Locales\:\:)(\w+)/).captures[1].downcase.to_sym
|
34
|
-
|
35
|
-
I18n.load_path = [File.join(File.dirname(__FILE__), "..", "..", "..", "locales", "#{test_locale}.yml")]
|
36
|
-
else
|
37
|
-
I18n.load_path += Dir[File.join(File.dirname(__FILE__), "..", "..", "..", "locales", "*.yml")]
|
38
|
+
|
39
|
+
def current_controller=(current_controller)
|
40
|
+
@current_controller = current_controller
|
41
|
+
@can_enrich_output = nil
|
38
42
|
end
|
39
43
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
::
|
54
|
-
|
44
|
+
def load_i18n(test_locale)
|
45
|
+
if test_locale
|
46
|
+
I18n.load_path = [File.join(File.dirname(__FILE__), "..", "..", "..", "locales", "#{test_locale}.yml")]
|
47
|
+
else
|
48
|
+
I18n.load_path += Dir[File.join(File.dirname(__FILE__), "..", "..", "..", "locales", "*.yml")]
|
49
|
+
end
|
50
|
+
I18n.backend.reload!
|
51
|
+
end
|
52
|
+
|
53
|
+
def enable_i18n_cms(enriched_output_criteria = :current_rich_cms_admin, assign_i18n_backend = true)
|
54
|
+
raise "Missing E9s module Rich-CMS, please install first" unless defined?(Cms::Engine)
|
55
|
+
|
56
|
+
self.enable_enriched_output = enriched_output_criteria
|
57
|
+
Cms::Engine.register ".i18n", {:class_name => "Translation", :key => [:key, :locale], :before_edit => "Rich.I18n.beforeEdit", :after_update => "Rich.I18n.afterUpdate"}
|
58
|
+
|
59
|
+
# FIXME: the check is a dirty fix to be able to test all the E9s modules at once (find a better implementation)
|
60
|
+
if RAILS_ENV != "test" && assign_i18n_backend
|
61
|
+
::I18n.backend = ::I18n::Backend::Chain.new ::I18n::Backend::ActiveRecord.new, ::I18n.backend
|
62
|
+
::I18n.backend.extend ::I18n::Backend::Fallbacks
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def enable_enriched_output=(value)
|
67
|
+
@enable_enriched_output = value
|
68
|
+
@can_enrich_output = nil
|
55
69
|
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def enable_enriched_output=(value)
|
59
|
-
@enable_enriched_output = value
|
60
|
-
@can_enrich_output = nil
|
61
|
-
end
|
62
70
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
71
|
+
def can_enrich_output?
|
72
|
+
if @can_enrich_output.nil?
|
73
|
+
@can_enrich_output = !!@enable_enriched_output &&
|
74
|
+
(@enable_enriched_output.is_a?(Symbol) ? (@current_controller.send(@enable_enriched_output) rescue false) : @enable_enriched_output)
|
75
|
+
else
|
76
|
+
@can_enrich_output
|
77
|
+
end
|
69
78
|
end
|
79
|
+
|
70
80
|
end
|
71
|
-
|
81
|
+
|
72
82
|
end
|
73
83
|
end
|
74
84
|
end
|
data/lib/rich/i18n/formtastic.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
module Rich
|
3
3
|
module I18n
|
4
4
|
module Formtastic
|
5
|
-
|
5
|
+
|
6
6
|
def self.included(base)
|
7
7
|
base.alias_method_chain :input, :enrichments
|
8
8
|
end
|
@@ -13,39 +13,41 @@ module Rich
|
|
13
13
|
method = method_arg.to_s
|
14
14
|
options = args.extract_options!
|
15
15
|
wrapper_tag = options.delete(:wrapper_tag)
|
16
|
-
|
16
|
+
|
17
17
|
unless options.include?(:label)
|
18
18
|
keys = [:"label.#{object}.#{method}", :"label.#{method}", :"word.#{method}"]
|
19
|
-
|
19
|
+
|
20
20
|
if @options.include?(:name)
|
21
21
|
keys.unshift :"label.forms.(#{@options[:name]}).#{method}"
|
22
22
|
keys.unshift :"label.forms.(#{@options[:name]}).#{object}.#{method}"
|
23
23
|
end
|
24
|
-
|
25
|
-
options[:label] = keys.shift.t(:default => keys, :capitalize => true).
|
24
|
+
|
25
|
+
options[:label] = keys.shift.t(:default => keys, :capitalize => true).to_s
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
unless options.include?(:seatholder)
|
29
29
|
keys = [:"seatholder.#{object}.#{method}", :"seatholder.#{method}", ""]
|
30
|
-
|
30
|
+
|
31
31
|
if @options.include?(:name)
|
32
32
|
keys.unshift :"seatholder.forms.(#{@options[:name]}).#{method}"
|
33
33
|
keys.unshift :"seatholder.forms.(#{@options[:name]}).#{object}.#{method}"
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
seatholder = keys.shift.t :default => keys, :capitalize => true
|
37
|
-
options[:seatholder] = seatholder.
|
37
|
+
options[:seatholder] = seatholder.to_s unless seatholder.empty?
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
(options[:input_html] ||= {}).store :seatholder, options.delete(:seatholder) unless @object && @object.respond_to?(:errors) && !@object.errors[method.to_sym].blank?
|
41
|
-
|
41
|
+
|
42
42
|
if (output = input_without_enrichments method_arg, options) and wrapper_tag
|
43
43
|
output.gsub(/^\<li/, "<#{wrapper_tag}").gsub(/\<\/li\>$/, "</#{wrapper_tag}>")
|
44
44
|
else
|
45
45
|
output
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
end
|
50
|
-
end
|
50
|
+
end
|
51
51
|
end
|
52
|
+
|
53
|
+
Formtastic::SemanticFormBuilder.send :include, Rich::I18n::Formtastic
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "rails", "engine.rb")
|
data/lib/rich_i18n.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require "jzip"
|
2
|
-
|
3
1
|
require "formtastic"
|
4
|
-
|
2
|
+
require "jzip"
|
5
3
|
|
6
4
|
require "rich/i18n"
|
7
5
|
require "rich/i18n/core"
|
6
|
+
require "rich/i18n/activesupport"
|
8
7
|
require "rich/i18n/actionpack"
|
8
|
+
require "rich/i18n/rails"
|
9
9
|
require "rich/i18n/engine"
|
10
10
|
require "rich/i18n/formtastic"
|
data/locales/nl.yml
CHANGED
@@ -12,12 +12,12 @@ class RichI18nTranslationGenerator < Rails::Generator::Base
|
|
12
12
|
m.migration_template "migration.rb", "db/migrate", :migration_file_name => migration_file_name
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def after_generate
|
17
17
|
File.open(destination_path("config/initializers/enrichments.rb"), "a+") do |file|
|
18
18
|
file << "\nRich::I18n::Engine.enable_i18n_cms"
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
system "rake db:migrate" if options[:migrate]
|
22
22
|
end
|
23
23
|
|
@@ -28,7 +28,7 @@ class RichI18nTranslationGenerator < Rails::Generator::Base
|
|
28
28
|
def model_class_name
|
29
29
|
@name.classify
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
def table_name
|
33
33
|
model_file_name.gsub("/", "_").pluralize
|
34
34
|
end
|