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.
Files changed (148) hide show
  1. data/CHANGELOG +1 -1
  2. data/README.textile +56 -29
  3. data/Rakefile +22 -8
  4. data/VERSION +1 -1
  5. data/{lib/app → app}/views/rich_i18n.html.erb +0 -0
  6. data/{lib/assets → assets}/jzip/jquery/core.jz +0 -0
  7. data/{lib/assets → assets}/jzip/jquery/extensions/modules.js +0 -0
  8. data/{lib/assets → assets}/jzip/jquery/seat_holder.js +31 -31
  9. data/{lib/assets → assets}/jzip/rich.js +0 -0
  10. data/{lib/assets → assets}/jzip/rich/i18n.js +2 -2
  11. data/{lib/assets → assets}/jzip/rich_i18n.jz +0 -0
  12. data/lib/generators/rich.rb +25 -0
  13. data/lib/generators/rich/translation/templates/migration.rb +18 -0
  14. data/lib/generators/rich/translation/templates/model.rb +7 -0
  15. data/lib/generators/rich/translation/translation_generator.rb +59 -0
  16. data/lib/rich/i18n.rb +2 -2
  17. data/lib/rich/i18n/actionpack.rb +0 -1
  18. data/lib/rich/i18n/actionpack/action_controller/base.rb +3 -3
  19. data/lib/rich/i18n/actionpack/action_view/base.rb +3 -3
  20. data/lib/rich/i18n/actionpack/action_view/sanitizor.rb +14 -20
  21. data/lib/rich/i18n/activesupport.rb +1 -0
  22. data/lib/rich/i18n/activesupport/active_support/dependencies.rb +12 -0
  23. data/lib/rich/i18n/core/array.rb +0 -2
  24. data/lib/rich/i18n/core/array/merging.rb +5 -7
  25. data/lib/rich/i18n/core/enriched_string.rb +68 -25
  26. data/lib/rich/i18n/core/object.rb +2 -2
  27. data/lib/rich/i18n/core/object/enriched.rb +16 -0
  28. data/lib/rich/i18n/core/string.rb +4 -2
  29. data/lib/rich/i18n/core/{object/output.rb → string/enriched.rb} +8 -8
  30. data/lib/rich/i18n/core/string/html_safe.rb +18 -0
  31. data/lib/rich/i18n/core/string/inflections.rb +9 -9
  32. data/lib/rich/i18n/core/string/internationalization.rb +20 -18
  33. data/lib/rich/i18n/core/symbol/internationalization.rb +2 -2
  34. data/lib/rich/i18n/engine.rb +71 -61
  35. data/lib/rich/i18n/formtastic.rb +15 -13
  36. data/lib/rich/i18n/rails.rb +1 -0
  37. data/lib/rich/i18n/rails/engine.rb +5 -0
  38. data/lib/rich_i18n.rb +3 -3
  39. data/locales/nl.yml +3 -3
  40. data/rails_generators/rich_i18n_translation/rich_i18n_translation_generator.rb +3 -3
  41. data/rails_generators/rich_i18n_translation/templates/migration.rb +1 -1
  42. data/rails_generators/rich_i18n_translation/templates/model.rb +2 -2
  43. data/rich_i18n.gemspec +159 -33
  44. data/test/rails-2/dummy/Gemfile +5 -0
  45. data/test/rails-2/dummy/Gemfile.lock +50 -0
  46. data/test/rails-2/dummy/Rakefile +10 -0
  47. data/test/rails-2/dummy/app/controllers/application_controller.rb +10 -0
  48. data/test/rails-2/dummy/app/helpers/application_helper.rb +3 -0
  49. data/test/rails-2/dummy/config/boot.rb +124 -0
  50. data/test/rails-2/dummy/config/database.yml +22 -0
  51. data/test/rails-2/dummy/config/environment.rb +41 -0
  52. data/test/rails-2/dummy/config/environments/development.rb +17 -0
  53. data/test/rails-2/dummy/config/environments/production.rb +28 -0
  54. data/test/rails-2/dummy/config/environments/test.rb +28 -0
  55. data/test/rails-2/dummy/config/initializers/backtrace_silencers.rb +7 -0
  56. data/test/rails-2/dummy/config/initializers/cookie_verification_secret.rb +7 -0
  57. data/test/rails-2/dummy/config/initializers/inflections.rb +10 -0
  58. data/test/rails-2/dummy/config/initializers/mime_types.rb +5 -0
  59. data/test/rails-2/dummy/config/initializers/new_rails_defaults.rb +21 -0
  60. data/test/rails-2/dummy/config/initializers/session_store.rb +15 -0
  61. data/test/rails-2/dummy/config/locales/en.yml +5 -0
  62. data/test/rails-2/dummy/config/preinitializer.rb +20 -0
  63. data/test/rails-2/dummy/config/routes.rb +43 -0
  64. data/test/rails-2/dummy/db/seeds.rb +7 -0
  65. data/test/rails-2/dummy/db/test.sqlite3 +0 -0
  66. data/test/rails-2/dummy/log/development.log +0 -0
  67. data/test/rails-2/dummy/log/production.log +0 -0
  68. data/test/rails-2/dummy/log/server.log +0 -0
  69. data/test/rails-2/dummy/log/test.log +0 -0
  70. data/test/rails-2/dummy/public/404.html +30 -0
  71. data/test/rails-2/dummy/public/422.html +30 -0
  72. data/test/rails-2/dummy/public/500.html +30 -0
  73. data/test/rails-2/dummy/public/favicon.ico +0 -0
  74. data/test/rails-2/dummy/public/images/rails.png +0 -0
  75. data/test/rails-2/dummy/public/index.html +275 -0
  76. data/test/rails-2/dummy/public/javascripts/application.js +2 -0
  77. data/test/rails-2/dummy/public/javascripts/controls.js +963 -0
  78. data/test/rails-2/dummy/public/javascripts/dragdrop.js +973 -0
  79. data/test/rails-2/dummy/public/javascripts/effects.js +1128 -0
  80. data/test/rails-2/dummy/public/javascripts/prototype.js +4320 -0
  81. data/test/rails-2/dummy/public/robots.txt +5 -0
  82. data/test/rails-2/dummy/script/about +4 -0
  83. data/test/rails-2/dummy/script/console +3 -0
  84. data/test/rails-2/dummy/script/dbconsole +3 -0
  85. data/test/rails-2/dummy/script/destroy +3 -0
  86. data/test/rails-2/dummy/script/generate +3 -0
  87. data/test/rails-2/dummy/script/performance/benchmarker +3 -0
  88. data/test/rails-2/dummy/script/performance/profiler +3 -0
  89. data/test/rails-2/dummy/script/plugin +3 -0
  90. data/test/rails-2/dummy/script/runner +3 -0
  91. data/test/rails-2/dummy/script/server +3 -0
  92. data/test/rails-2/test_helper.rb +5 -0
  93. data/test/rails-3/dummy/Gemfile +5 -0
  94. data/test/rails-3/dummy/Gemfile.lock +93 -0
  95. data/test/rails-3/dummy/Rakefile +7 -0
  96. data/test/rails-3/dummy/app/controllers/application_controller.rb +3 -0
  97. data/test/rails-3/dummy/app/helpers/application_helper.rb +2 -0
  98. data/test/rails-3/dummy/app/views/layouts/application.html.erb +14 -0
  99. data/test/rails-3/dummy/config.ru +4 -0
  100. data/test/rails-3/dummy/config/application.rb +44 -0
  101. data/test/rails-3/dummy/config/boot.rb +10 -0
  102. data/test/rails-3/dummy/config/database.yml +22 -0
  103. data/test/rails-3/dummy/config/environment.rb +5 -0
  104. data/test/rails-3/dummy/config/environments/development.rb +26 -0
  105. data/test/rails-3/dummy/config/environments/production.rb +49 -0
  106. data/test/rails-3/dummy/config/environments/test.rb +35 -0
  107. data/test/rails-3/dummy/config/initializers/backtrace_silencers.rb +7 -0
  108. data/test/rails-3/dummy/config/initializers/inflections.rb +10 -0
  109. data/test/rails-3/dummy/config/initializers/mime_types.rb +5 -0
  110. data/test/rails-3/dummy/config/initializers/secret_token.rb +7 -0
  111. data/test/rails-3/dummy/config/initializers/session_store.rb +8 -0
  112. data/test/rails-3/dummy/config/locales/en.yml +5 -0
  113. data/test/rails-3/dummy/config/routes.rb +58 -0
  114. data/test/rails-3/dummy/db/test.sqlite3 +0 -0
  115. data/test/rails-3/dummy/log/development.log +0 -0
  116. data/test/rails-3/dummy/log/production.log +0 -0
  117. data/test/rails-3/dummy/log/server.log +0 -0
  118. data/test/rails-3/dummy/log/test.log +0 -0
  119. data/test/rails-3/dummy/public/404.html +26 -0
  120. data/test/rails-3/dummy/public/422.html +26 -0
  121. data/test/rails-3/dummy/public/500.html +26 -0
  122. data/test/rails-3/dummy/public/favicon.ico +0 -0
  123. data/test/rails-3/dummy/public/javascripts/application.js +2 -0
  124. data/test/rails-3/dummy/public/javascripts/controls.js +965 -0
  125. data/test/rails-3/dummy/public/javascripts/dragdrop.js +974 -0
  126. data/test/rails-3/dummy/public/javascripts/effects.js +1123 -0
  127. data/test/rails-3/dummy/public/javascripts/prototype.js +6001 -0
  128. data/test/rails-3/dummy/public/javascripts/rails.js +175 -0
  129. data/test/rails-3/dummy/public/stylesheets/.gitkeep +0 -0
  130. data/test/rails-3/dummy/script/rails +6 -0
  131. data/test/rails-3/test_helper.rb +8 -0
  132. data/test/tests/core/array/merging_test.rb +14 -0
  133. data/test/tests/core/enriched_string_test.rb +20 -0
  134. data/test/tests/core/string/inflections_test.rb +32 -0
  135. data/test/tests/core/string/merging_test.rb +15 -0
  136. data/test/tests/locales/nl/internationalization_test.rb +55 -0
  137. metadata +183 -44
  138. data/lib/rich/i18n/actionpack/action_controller/dispatcher.rb +0 -12
  139. data/lib/rich/i18n/core/enumerable/methods.rb +0 -16
  140. data/lib/rich/i18n/core/hash.rb +0 -6
  141. data/lib/rich/i18n/core/nil_class.rb +0 -8
  142. data/lib/rich/i18n/core/string/enrichments.rb +0 -66
  143. data/test/core/string/inflections_test.rb +0 -42
  144. data/test/core/string/internationalization_test.rb +0 -23
  145. data/test/engine_test.rb +0 -20
  146. data/test/locales/nl/internationalization_test.rb +0 -47
  147. data/test/setup.rb +0 -14
  148. data/test/test_helper.rb +0 -5
@@ -1,12 +0,0 @@
1
-
2
- unless defined?(Rich::I18n::CONTROLLER_HOOKED)
3
-
4
- ActionController::Dispatcher.to_prepare :rich_i18n_formtastic do
5
- if defined? Formtastic::SemanticFormBuilder
6
- Formtastic::SemanticFormBuilder.send :include, Rich::I18n::Formtastic unless Formtastic::SemanticFormBuilder.included_modules.include? Rich::I18n::Formtastic
7
- end
8
- end
9
-
10
- Rich::I18n::CONTROLLER_HOOKED = true
11
-
12
- end
@@ -1,16 +0,0 @@
1
-
2
- module Rich
3
- module I18n
4
- module Core
5
- module Enumerable
6
- module Methods
7
-
8
- def filled?
9
- !empty?
10
- end
11
-
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,6 +0,0 @@
1
-
2
- require "rich/i18n/core/enumerable/methods"
3
-
4
- class Hash
5
- include Rich::I18n::Core::Enumerable::Methods
6
- end
@@ -1,8 +0,0 @@
1
-
2
- class NilClass
3
-
4
- def filled?
5
- false
6
- end
7
-
8
- end
@@ -1,66 +0,0 @@
1
-
2
- module Rich
3
- module I18n
4
- module Core
5
- module String
6
- module Enrichments
7
-
8
- def self.included(base)
9
- base.class_eval do
10
- alias_method_chain :initialize_copy, :rich_i18n
11
-
12
- alias_method :add_without_rich_i18n, :+
13
- alias_method :+, :add_with_rich_i18n
14
-
15
- alias_method_chain :concat, :rich_i18n
16
- undef_method :<<
17
- alias_method :<<, :concat_with_rich_i18n
18
-
19
- attr_accessor :merged_strings
20
- end
21
- end
22
-
23
- def initialize_copy_with_rich_i18n(s)
24
- result = initialize_copy_without_rich_i18n(s)
25
- result.merged_strings = self.merged_strings.try :dup
26
- end
27
-
28
- def add_with_rich_i18n(other)
29
- strings, result = self.merged_strings.try(:dup) || [], add_without_rich_i18n(other.enriched_string? ? other.string : other)
30
-
31
- if (result.merged_strings = strings).empty?
32
- result.merged_strings << self.dup
33
- end
34
- unless other.empty?
35
- result.merged_strings << other
36
- end
37
-
38
- result
39
- end
40
-
41
- def concat_with_rich_i18n(other_or_fixnum)
42
- string, result = self.dup, concat_without_rich_i18n(other_or_fixnum)
43
-
44
- if (result.merged_strings ||= []).empty? and !string.empty?
45
- result.merged_strings << string
46
- end
47
- result.merged_strings << other_or_fixnum.dup unless other_or_fixnum.empty?
48
-
49
- result
50
- end
51
-
52
- def enriched_string?
53
- (merged_strings || []).any?(&:enriched_string?)
54
- end
55
-
56
- def to_output
57
- merged_strings.blank? ?
58
- to_es :
59
- merged_strings.collect(&:to_output).join(" ")
60
- end
61
-
62
- end
63
- end
64
- end
65
- end
66
- end
@@ -1,42 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "test_helper.rb"))
2
-
3
- module Rich
4
- module I18n
5
- module Test
6
- module Core
7
- module String
8
-
9
- class InflectionsTest < ActiveSupport::TestCase
10
- setup do
11
- include Setup
12
- end
13
-
14
- test "upcase_first" do
15
- assert_equal "" , "".upcase_first
16
- assert_equal "E9s", "e9s".upcase_first
17
- assert_equal "E9S", "E9S".upcase_first
18
- end
19
-
20
- test "cp_case" do
21
- assert_equal "BTW" , "btw".cp_case("VAT")
22
- assert_equal "huis" , "huis".cp_case("house")
23
- assert_equal "Welkom thuis" , "Welkom thuis".cp_case("Welcome home")
24
- assert_equal "Welkom bij CodeHero.es", "welkom bij CodeHero.es".cp_case("Welcome at CodeHero.es")
25
- end
26
-
27
- test "upcase_first!" do
28
- assert_equal nil , "".upcase_first!
29
- assert_equal "E9s", "e9s".upcase_first!
30
- assert_equal nil , "E9s".upcase_first!
31
- end
32
-
33
- # test "pluralize!" do
34
- # assert true
35
- # end
36
- end
37
- end
38
-
39
- end
40
- end
41
- end
42
- end
@@ -1,23 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "test_helper.rb"))
2
-
3
- module Rich
4
- module I18n
5
- module Test
6
- module Core
7
- module String
8
-
9
- class InternationalizationTest < ActiveSupport::TestCase
10
- setup do
11
- include Setup
12
- end
13
-
14
- # test "t" do
15
- # assert true
16
- # end
17
- end
18
-
19
- end
20
- end
21
- end
22
- end
23
- end
data/test/engine_test.rb DELETED
@@ -1,20 +0,0 @@
1
- require "test_helper"
2
-
3
- module Rich
4
- module I18n
5
- module Test
6
-
7
- class EngineTest < ActiveSupport::TestCase
8
- setup do
9
- include Setup
10
- I18n.locale = Engine.init(Locales::NL)
11
- end
12
-
13
- # test "something" do
14
- # assert true
15
- # end
16
- end
17
-
18
- end
19
- end
20
- end
@@ -1,47 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "test_helper.rb"))
2
-
3
- module Rich
4
- module I18n
5
- module Test
6
- module Locales
7
- module NL
8
-
9
- class InternationalizationTest < ActiveSupport::TestCase
10
- setup do
11
- include Setup
12
- I18n.locale = Engine.init(self)
13
- end
14
-
15
- test "dutch_translations" do
16
- assert_equal "huis" , "house".t
17
- assert_equal "straat", "street".t
18
- assert_equal "vraag" , "question".t
19
- assert_equal "vraag" , "word.question".t
20
- end
21
-
22
- test "dutch_cased_translations" do
23
- assert_equal "meer" , "more".t
24
- assert_equal "Huis" , "House".t
25
- # assert_equal "Straten", "Streets".t
26
- # assert_equal "VRAGEN" , "QUESTIONS".t
27
- end
28
-
29
- test "dutch_combined_translations" do
30
- assert_equal "vraag & antwoord" , "question & answer".t
31
- assert_equal "Vraag & antwoord" , "Question & answer".t
32
- assert_equal "Man / Vrouw" , "Male / Female".t
33
- assert_equal "één huis" , "one house".t
34
- # assert_equal "Één huis" , "One house".t
35
- # assert_equal "Meer huizen" , "More houses".t
36
- # assert_equal "MEER STRATEN" , "MORE STREETS".t
37
- # assert_equal "meer vragen" , "more questions".t
38
- # assert_equal "meer vragen" , "more questions".t
39
- # assert_equal "Vragen & Antwoorden", "Questions & Answers".t
40
- end
41
- end
42
-
43
- end
44
- end
45
- end
46
- end
47
- end
data/test/setup.rb DELETED
@@ -1,14 +0,0 @@
1
-
2
- module Rich
3
- module I18n
4
- module Test
5
- module Setup
6
-
7
- def self.included(base)
8
- require "rich/i18n"
9
- end
10
-
11
- end
12
- end
13
- end
14
- end
data/test/test_helper.rb DELETED
@@ -1,5 +0,0 @@
1
- require "rubygems"
2
- require "active_support"
3
- require "active_support/test_case"
4
-
5
- require File.join(File.dirname(__FILE__), "setup.rb")