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
@@ -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
|
data/lib/rich/i18n/core/hash.rb
DELETED
@@ -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