globalize2 0.1.0
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/.gitignore +4 -0
- data/LICENSE +21 -0
- data/README.textile +202 -0
- data/Rakefile +39 -0
- data/VERSION +1 -0
- data/generators/db_backend.rb +0 -0
- data/generators/templates/db_backend_migration.rb +25 -0
- data/globalize2.gemspec +100 -0
- data/init.rb +8 -0
- data/lib/globalize/backend/chain.rb +102 -0
- data/lib/globalize/backend/pluralizing.rb +37 -0
- data/lib/globalize/backend/static.rb +61 -0
- data/lib/globalize/i18n/missing_translations_log_handler.rb +41 -0
- data/lib/globalize/i18n/missing_translations_raise_handler.rb +27 -0
- data/lib/globalize/load_path.rb +63 -0
- data/lib/globalize/locale/fallbacks.rb +63 -0
- data/lib/globalize/locale/language_tag.rb +81 -0
- data/lib/globalize/model/active_record.rb +56 -0
- data/lib/globalize/model/active_record/adapter.rb +100 -0
- data/lib/globalize/model/active_record/translated.rb +174 -0
- data/lib/globalize/translation.rb +32 -0
- data/lib/locale/root.yml +3 -0
- data/lib/rails_edge_load_path_patch.rb +40 -0
- data/notes.textile +51 -0
- data/test/all.rb +2 -0
- data/test/backends/chained_test.rb +175 -0
- data/test/backends/pluralizing_test.rb +63 -0
- data/test/backends/static_test.rb +147 -0
- data/test/data/locale/all.yml +2 -0
- data/test/data/locale/de-DE.yml +2 -0
- data/test/data/locale/en-US.yml +2 -0
- data/test/data/locale/en-US/module.yml +2 -0
- data/test/data/locale/fi-FI/module.yml +2 -0
- data/test/data/locale/root.yml +0 -0
- data/test/data/models.rb +40 -0
- data/test/data/no_globalize_schema.rb +11 -0
- data/test/data/schema.rb +39 -0
- data/test/i18n/missing_translations_test.rb +36 -0
- data/test/load_path_test.rb +49 -0
- data/test/locale/fallbacks_test.rb +154 -0
- data/test/locale/language_tag_test.rb +130 -0
- data/test/model/active_record/migration_test.rb +123 -0
- data/test/model/active_record/sti_translated_test.rb +75 -0
- data/test/model/active_record/translated_test.rb +487 -0
- data/test/test_helper.rb +36 -0
- data/test/translation_test.rb +54 -0
- metadata +116 -0
data/test/test_helper.rb
ADDED
@@ -0,0 +1,36 @@
|
|
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
|
+
:database => ':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
|
27
|
+
|
28
|
+
module ActiveRecord
|
29
|
+
module ConnectionAdapters
|
30
|
+
class AbstractAdapter
|
31
|
+
def index_exists?(table_name, column_name)
|
32
|
+
indexes(table_name).any? { |index| index.name == index_name(table_name, column_name) }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
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,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: globalize2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sven Fuchs, Joshua Harvey, Clemens Kofler
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-08 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: "Rails I18n: de-facto standard library for ActiveRecord data translation"
|
17
|
+
email: joshmh@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.textile
|
25
|
+
files:
|
26
|
+
- .gitignore
|
27
|
+
- LICENSE
|
28
|
+
- README.textile
|
29
|
+
- Rakefile
|
30
|
+
- VERSION
|
31
|
+
- generators/db_backend.rb
|
32
|
+
- generators/templates/db_backend_migration.rb
|
33
|
+
- globalize2.gemspec
|
34
|
+
- init.rb
|
35
|
+
- lib/globalize/backend/chain.rb
|
36
|
+
- lib/globalize/backend/pluralizing.rb
|
37
|
+
- lib/globalize/backend/static.rb
|
38
|
+
- lib/globalize/i18n/missing_translations_log_handler.rb
|
39
|
+
- lib/globalize/i18n/missing_translations_raise_handler.rb
|
40
|
+
- lib/globalize/load_path.rb
|
41
|
+
- lib/globalize/locale/fallbacks.rb
|
42
|
+
- lib/globalize/locale/language_tag.rb
|
43
|
+
- lib/globalize/model/active_record.rb
|
44
|
+
- lib/globalize/model/active_record/adapter.rb
|
45
|
+
- lib/globalize/model/active_record/translated.rb
|
46
|
+
- lib/globalize/translation.rb
|
47
|
+
- lib/locale/root.yml
|
48
|
+
- lib/rails_edge_load_path_patch.rb
|
49
|
+
- notes.textile
|
50
|
+
- test/all.rb
|
51
|
+
- test/backends/chained_test.rb
|
52
|
+
- test/backends/pluralizing_test.rb
|
53
|
+
- test/backends/static_test.rb
|
54
|
+
- test/data/locale/all.yml
|
55
|
+
- test/data/locale/de-DE.yml
|
56
|
+
- test/data/locale/en-US.yml
|
57
|
+
- test/data/locale/en-US/module.yml
|
58
|
+
- test/data/locale/fi-FI/module.yml
|
59
|
+
- test/data/locale/root.yml
|
60
|
+
- test/data/models.rb
|
61
|
+
- test/data/no_globalize_schema.rb
|
62
|
+
- test/data/schema.rb
|
63
|
+
- test/i18n/missing_translations_test.rb
|
64
|
+
- test/load_path_test.rb
|
65
|
+
- test/locale/fallbacks_test.rb
|
66
|
+
- test/locale/language_tag_test.rb
|
67
|
+
- test/model/active_record/migration_test.rb
|
68
|
+
- test/model/active_record/sti_translated_test.rb
|
69
|
+
- test/model/active_record/translated_test.rb
|
70
|
+
- test/test_helper.rb
|
71
|
+
- test/translation_test.rb
|
72
|
+
has_rdoc: true
|
73
|
+
homepage: http://github.com/joshmh/globalize2
|
74
|
+
licenses: []
|
75
|
+
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options:
|
78
|
+
- --charset=UTF-8
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
version:
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: "0"
|
92
|
+
version:
|
93
|
+
requirements: []
|
94
|
+
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 1.3.5
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: "Rails I18n: de-facto standard library for ActiveRecord data translation"
|
100
|
+
test_files:
|
101
|
+
- test/all.rb
|
102
|
+
- test/backends/chained_test.rb
|
103
|
+
- test/backends/pluralizing_test.rb
|
104
|
+
- test/backends/static_test.rb
|
105
|
+
- test/data/models.rb
|
106
|
+
- test/data/no_globalize_schema.rb
|
107
|
+
- test/data/schema.rb
|
108
|
+
- test/i18n/missing_translations_test.rb
|
109
|
+
- test/load_path_test.rb
|
110
|
+
- test/locale/fallbacks_test.rb
|
111
|
+
- test/locale/language_tag_test.rb
|
112
|
+
- test/model/active_record/migration_test.rb
|
113
|
+
- test/model/active_record/sti_translated_test.rb
|
114
|
+
- test/model/active_record/translated_test.rb
|
115
|
+
- test/test_helper.rb
|
116
|
+
- test/translation_test.rb
|