simonmenke-globalize2 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/LICENSE +21 -0
  2. data/README.textile +202 -0
  3. data/generators/db_backend.rb +0 -0
  4. data/generators/templates/db_backend_migration.rb +25 -0
  5. data/init.rb +1 -0
  6. data/lib/globalize/backend/chain.rb +102 -0
  7. data/lib/globalize/backend/pluralizing.rb +37 -0
  8. data/lib/globalize/backend/static.rb +60 -0
  9. data/lib/globalize/i18n/missing_translations_log_handler.rb +41 -0
  10. data/lib/globalize/i18n/missing_translations_raise_handler.rb +27 -0
  11. data/lib/globalize/load_path.rb +63 -0
  12. data/lib/globalize/locale/fallbacks.rb +63 -0
  13. data/lib/globalize/locale/language_tag.rb +81 -0
  14. data/lib/globalize/model/active_record.rb +38 -0
  15. data/lib/globalize/model/active_record/adapter.rb +96 -0
  16. data/lib/globalize/model/active_record/translated.rb +154 -0
  17. data/lib/globalize/translation.rb +32 -0
  18. data/lib/locale/root.yml +3 -0
  19. data/lib/rails_edge_load_path_patch.rb +40 -0
  20. data/notes.textile +51 -0
  21. data/rails/init.rb +9 -0
  22. data/test/backends/chained_test.rb +175 -0
  23. data/test/backends/pluralizing_test.rb +63 -0
  24. data/test/backends/static_test.rb +143 -0
  25. data/test/data/locale/all.yml +2 -0
  26. data/test/data/locale/de-DE.yml +2 -0
  27. data/test/data/locale/en-US.yml +2 -0
  28. data/test/data/locale/en-US/module.yml +2 -0
  29. data/test/data/locale/fi-FI/module.yml +2 -0
  30. data/test/data/locale/root.yml +0 -0
  31. data/test/data/no_globalize_schema.rb +11 -0
  32. data/test/data/post.rb +24 -0
  33. data/test/data/schema.rb +39 -0
  34. data/test/i18n/missing_translations_test.rb +36 -0
  35. data/test/load_path_test.rb +49 -0
  36. data/test/locale/fallbacks_test.rb +154 -0
  37. data/test/locale/language_tag_test.rb +130 -0
  38. data/test/model/active_record/migration_test.rb +73 -0
  39. data/test/model/active_record/sti_translated_test.rb +75 -0
  40. data/test/model/active_record/translated_test.rb +458 -0
  41. data/test/test_helper.rb +26 -0
  42. data/test/translation_test.rb +54 -0
  43. metadata +114 -0
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'active_support'
4
+ require 'active_support/test_case'
5
+ require 'mocha'
6
+
7
+ $LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '/../lib' )
8
+
9
+ class ActiveSupport::TestCase
10
+ def reset_db!( schema_path )
11
+ ::ActiveRecord::Migration.verbose = false # Quiet down the migration engine
12
+ ::ActiveRecord::Base.establish_connection({
13
+ :adapter => 'sqlite3',
14
+ :dbfile => ':memory:'
15
+ })
16
+ ::ActiveRecord::Base.silence do
17
+ load schema_path
18
+ end
19
+ end
20
+
21
+ def assert_member(item, arr)
22
+ assert_block "Item #{item} is not in array #{arr}" do
23
+ arr.member? item
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,54 @@
1
+ require File.join( File.dirname(__FILE__), 'test_helper' )
2
+ require 'globalize/translation'
3
+
4
+ class TranslationTest < ActiveSupport::TestCase
5
+ include Globalize
6
+
7
+ def setup
8
+ @translation = Translation::Static.new 'foo', :locale => :'en-US'
9
+ end
10
+
11
+ test "responds to fallback?" do
12
+ assert @translation.respond_to?( :fallback? )
13
+ end
14
+
15
+ test "returns true when :locale and :requested_locale are not equal" do
16
+ @translation.requested_locale = :'de-DE'
17
+ assert @translation.fallback?
18
+ end
19
+
20
+ test "returns false when :locale and :requested_locale are equal" do
21
+ @translation.requested_locale = :'en-US'
22
+ assert !@translation.fallback?
23
+ end
24
+
25
+ test "has the attribute :locale" do
26
+ assert @translation.respond_to?( :locale )
27
+ end
28
+
29
+ test "has the attribute :requested_locale" do
30
+ assert @translation.respond_to?( :requested_locale )
31
+ end
32
+
33
+ test "has the attribute :options" do
34
+ assert @translation.respond_to?( :options )
35
+ end
36
+
37
+ test "has the attribute :plural_key" do
38
+ assert @translation.respond_to?( :plural_key )
39
+ end
40
+
41
+ test "has the attribute :original" do
42
+ assert @translation.respond_to?( :original )
43
+ end
44
+
45
+ test "Translation::Attribute has the attribute :locale" do
46
+ translation = Translation::Attribute.new 'foo'
47
+ assert translation.respond_to?( :locale )
48
+ end
49
+
50
+ test "Translation::Attribute has the attribute :requested_locale" do
51
+ translation = Translation::Attribute.new 'foo'
52
+ assert translation.respond_to?( :requested_locale )
53
+ end
54
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simonmenke-globalize2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Josh Harvey
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-26 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: The second incarnation of Globalize for Rails
17
+ email: joshmh@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - lib/globalize/backend/chain.rb
26
+ - lib/globalize/backend/pluralizing.rb
27
+ - lib/globalize/backend/static.rb
28
+ - lib/globalize/i18n/missing_translations_log_handler.rb
29
+ - lib/globalize/i18n/missing_translations_raise_handler.rb
30
+ - lib/globalize/load_path.rb
31
+ - lib/globalize/locale/fallbacks.rb
32
+ - lib/globalize/locale/language_tag.rb
33
+ - lib/globalize/model/active_record/adapter.rb
34
+ - lib/globalize/model/active_record/translated.rb
35
+ - lib/globalize/model/active_record.rb
36
+ - lib/globalize/translation.rb
37
+ - lib/rails_edge_load_path_patch.rb
38
+ - rails/init.rb
39
+ - test/backends/chained_test.rb
40
+ - test/backends/pluralizing_test.rb
41
+ - test/backends/static_test.rb
42
+ - test/data/no_globalize_schema.rb
43
+ - test/data/post.rb
44
+ - test/data/schema.rb
45
+ - test/i18n/missing_translations_test.rb
46
+ - test/load_path_test.rb
47
+ - test/locale/fallbacks_test.rb
48
+ - test/locale/language_tag_test.rb
49
+ - test/model/active_record/migration_test.rb
50
+ - test/model/active_record/sti_translated_test.rb
51
+ - test/model/active_record/translated_test.rb
52
+ - test/test_helper.rb
53
+ - test/translation_test.rb
54
+ - generators/db_backend.rb
55
+ - generators/templates/db_backend_migration.rb
56
+ - LICENSE
57
+ - README.textile
58
+ - notes.textile
59
+ - init.rb
60
+ - lib/locale/root.yml
61
+ - test/data/locale/all.yml
62
+ - test/data/locale/de-DE.yml
63
+ - test/data/locale/en-US/module.yml
64
+ - test/data/locale/en-US.yml
65
+ - test/data/locale/fi-FI/module.yml
66
+ - test/data/locale/root.yml
67
+ has_rdoc: false
68
+ homepage: http://github.com/joshmh/globalize2
69
+ post_install_message:
70
+ rdoc_options: []
71
+
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: "0"
85
+ version:
86
+ requirements: []
87
+
88
+ rubyforge_project:
89
+ rubygems_version: 1.2.0
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: The second incarnation of Globalize for Rails
93
+ test_files:
94
+ - test/backends/chained_test.rb
95
+ - test/backends/pluralizing_test.rb
96
+ - test/backends/static_test.rb
97
+ - test/data/no_globalize_schema.rb
98
+ - test/data/post.rb
99
+ - test/data/schema.rb
100
+ - test/i18n/missing_translations_test.rb
101
+ - test/load_path_test.rb
102
+ - test/locale/fallbacks_test.rb
103
+ - test/locale/language_tag_test.rb
104
+ - test/model/active_record/migration_test.rb
105
+ - test/model/active_record/sti_translated_test.rb
106
+ - test/model/active_record/translated_test.rb
107
+ - test/test_helper.rb
108
+ - test/translation_test.rb
109
+ - test/data/locale/all.yml
110
+ - test/data/locale/de-DE.yml
111
+ - test/data/locale/en-US/module.yml
112
+ - test/data/locale/en-US.yml
113
+ - test/data/locale/fi-FI/module.yml
114
+ - test/data/locale/root.yml