activesupport 2.3.6.pre → 2.3.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activesupport might be problematic. Click here for more details.

Files changed (123) hide show
  1. data/CHANGELOG +9 -5
  2. data/lib/active_support/buffered_logger.rb +1 -1
  3. data/lib/active_support/cache/memory_store.rb +7 -1
  4. data/lib/active_support/cache/strategy/local_cache.rb +1 -1
  5. data/lib/active_support/core_ext/array/conversions.rb +1 -1
  6. data/lib/active_support/core_ext/array/random_access.rb +11 -1
  7. data/lib/active_support/core_ext/class/attribute_accessors.rb +35 -28
  8. data/lib/active_support/core_ext/date/calculations.rb +14 -4
  9. data/lib/active_support/core_ext/kernel/reporting.rb +1 -1
  10. data/lib/active_support/core_ext/module/aliasing.rb +1 -1
  11. data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +1 -1
  12. data/lib/active_support/core_ext/module/attribute_accessors.rb +33 -26
  13. data/lib/active_support/core_ext/module/synchronization.rb +1 -1
  14. data/lib/active_support/core_ext/object/blank.rb +20 -2
  15. data/lib/active_support/core_ext/string/output_safety.rb +10 -2
  16. data/lib/active_support/core_ext/string/starts_ends_with.rb +2 -4
  17. data/lib/active_support/core_ext/time.rb +8 -4
  18. data/lib/active_support/core_ext/time/calculations.rb +11 -2
  19. data/lib/active_support/deprecation.rb +3 -2
  20. data/lib/active_support/inflections.rb +1 -1
  21. data/lib/active_support/inflector.rb +4 -1
  22. data/lib/active_support/json/backends/yaml.rb +10 -7
  23. data/lib/active_support/json/decoding.rb +1 -1
  24. data/lib/active_support/memoizable.rb +1 -1
  25. data/lib/active_support/multibyte/unicode_database.rb +2 -2
  26. data/lib/active_support/multibyte/utils.rb +6 -7
  27. data/lib/active_support/ordered_hash.rb +24 -30
  28. data/lib/active_support/testing/assertions.rb +14 -0
  29. data/lib/active_support/values/time_zone.rb +84 -76
  30. data/lib/active_support/vendor.rb +1 -1
  31. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n.rb +92 -34
  32. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend.rb +2 -0
  33. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/active_record.rb +9 -13
  34. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/active_record/missing.rb +1 -1
  35. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/active_record/store_procs.rb +6 -6
  36. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/active_record/translation.rb +14 -9
  37. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/base.rb +23 -16
  38. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/cache.rb +1 -0
  39. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/cascade.rb +22 -8
  40. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/chain.rb +2 -1
  41. data/lib/active_support/vendor/i18n-0.3.7/i18n/backend/cldr.rb +100 -0
  42. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/fallbacks.rb +20 -3
  43. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/fast.rb +14 -13
  44. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/gettext.rb +1 -1
  45. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/helpers.rb +4 -16
  46. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/interpolation_compiler.rb +2 -2
  47. data/lib/active_support/vendor/i18n-0.3.7/i18n/backend/links.rb +34 -0
  48. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/metadata.rb +0 -0
  49. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/pluralization.rb +1 -1
  50. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/simple.rb +0 -0
  51. data/lib/active_support/vendor/i18n-0.3.7/i18n/core_ext/hash/except.rb +8 -0
  52. data/lib/active_support/vendor/i18n-0.3.7/i18n/core_ext/hash/slice.rb +8 -0
  53. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/core_ext/object/meta_class.rb +0 -0
  54. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/core_ext/string/interpolate.rb +1 -1
  55. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/exceptions.rb +1 -1
  56. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/gettext.rb +0 -0
  57. data/lib/active_support/vendor/{i18n-0.3.3/vendor → i18n-0.3.7/i18n/gettext}/po_parser.rb +0 -0
  58. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/helpers.rb +0 -0
  59. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/helpers/gettext.rb +3 -2
  60. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale.rb +0 -0
  61. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale/fallbacks.rb +0 -0
  62. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale/tag.rb +0 -0
  63. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale/tag/parents.rb +0 -0
  64. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale/tag/rfc4646.rb +0 -0
  65. data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale/tag/simple.rb +0 -0
  66. data/lib/active_support/vendor/i18n-0.3.7/i18n/version.rb +3 -0
  67. metadata +42 -96
  68. data/lib/active_support/vendor/i18n-0.3.3/CHANGELOG.textile +0 -76
  69. data/lib/active_support/vendor/i18n-0.3.3/MIT-LICENSE +0 -20
  70. data/lib/active_support/vendor/i18n-0.3.3/README.textile +0 -81
  71. data/lib/active_support/vendor/i18n-0.3.3/Rakefile +0 -24
  72. data/lib/active_support/vendor/i18n-0.3.3/benchmark/example.yml +0 -144
  73. data/lib/active_support/vendor/i18n-0.3.3/benchmark/run.rb +0 -71
  74. data/lib/active_support/vendor/i18n-0.3.3/contributors.txt +0 -17
  75. data/lib/active_support/vendor/i18n-0.3.3/i18n.gemspec +0 -165
  76. data/lib/active_support/vendor/i18n-0.3.3/init.rb +0 -1
  77. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/version.rb +0 -3
  78. data/lib/active_support/vendor/i18n-0.3.3/test/all.rb +0 -8
  79. data/lib/active_support/vendor/i18n-0.3.3/test/api/basics.rb +0 -15
  80. data/lib/active_support/vendor/i18n-0.3.3/test/api/defaults.rb +0 -40
  81. data/lib/active_support/vendor/i18n-0.3.3/test/api/interpolation.rb +0 -92
  82. data/lib/active_support/vendor/i18n-0.3.3/test/api/link.rb +0 -55
  83. data/lib/active_support/vendor/i18n-0.3.3/test/api/localization/date.rb +0 -91
  84. data/lib/active_support/vendor/i18n-0.3.3/test/api/localization/date_time.rb +0 -90
  85. data/lib/active_support/vendor/i18n-0.3.3/test/api/localization/procs.rb +0 -54
  86. data/lib/active_support/vendor/i18n-0.3.3/test/api/localization/time.rb +0 -84
  87. data/lib/active_support/vendor/i18n-0.3.3/test/api/lookup.rb +0 -45
  88. data/lib/active_support/vendor/i18n-0.3.3/test/api/pluralization.rb +0 -35
  89. data/lib/active_support/vendor/i18n-0.3.3/test/api/procs.rb +0 -40
  90. data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/active_record_test.rb +0 -29
  91. data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/all_features_test.rb +0 -40
  92. data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/cascade_test.rb +0 -31
  93. data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/chain_test.rb +0 -26
  94. data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/fallbacks_test.rb +0 -33
  95. data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/fast_test.rb +0 -31
  96. data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/pluralization_test.rb +0 -33
  97. data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/simple_test.rb +0 -21
  98. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/active_record/missing_test.rb +0 -60
  99. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/active_record_test.rb +0 -52
  100. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/cache_test.rb +0 -72
  101. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/cascade_test.rb +0 -66
  102. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/chain_test.rb +0 -64
  103. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/fallbacks_test.rb +0 -57
  104. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/fast_test.rb +0 -50
  105. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/helpers_test.rb +0 -26
  106. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/interpolation_compiler_test.rb +0 -107
  107. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/metadata_test.rb +0 -67
  108. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/pluralization_test.rb +0 -43
  109. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/simple_test.rb +0 -77
  110. data/lib/active_support/vendor/i18n-0.3.3/test/cases/core_ext/string/interpolate_test.rb +0 -94
  111. data/lib/active_support/vendor/i18n-0.3.3/test/cases/gettext/api_test.rb +0 -201
  112. data/lib/active_support/vendor/i18n-0.3.3/test/cases/gettext/backend_test.rb +0 -91
  113. data/lib/active_support/vendor/i18n-0.3.3/test/cases/i18n_exceptions_test.rb +0 -97
  114. data/lib/active_support/vendor/i18n-0.3.3/test/cases/i18n_load_path_test.rb +0 -23
  115. data/lib/active_support/vendor/i18n-0.3.3/test/cases/i18n_test.rb +0 -172
  116. data/lib/active_support/vendor/i18n-0.3.3/test/cases/locale/fallbacks_test.rb +0 -126
  117. data/lib/active_support/vendor/i18n-0.3.3/test/cases/locale/tag/rfc4646_test.rb +0 -143
  118. data/lib/active_support/vendor/i18n-0.3.3/test/cases/locale/tag/simple_test.rb +0 -33
  119. data/lib/active_support/vendor/i18n-0.3.3/test/fixtures/locales/de.po +0 -72
  120. data/lib/active_support/vendor/i18n-0.3.3/test/fixtures/locales/en.rb +0 -3
  121. data/lib/active_support/vendor/i18n-0.3.3/test/fixtures/locales/en.yml +0 -3
  122. data/lib/active_support/vendor/i18n-0.3.3/test/fixtures/locales/plurals.rb +0 -113
  123. data/lib/active_support/vendor/i18n-0.3.3/test/test_helper.rb +0 -100
@@ -1,71 +0,0 @@
1
- #! /usr/bin/ruby
2
- $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
3
-
4
- require 'i18n'
5
- require 'i18n/core_ext/object/meta_class'
6
- require 'benchmark'
7
- require 'yaml'
8
-
9
- # Load YAML example file
10
- YAML_HASH = YAML.load_file(File.expand_path("example.yml", File.dirname(__FILE__)))
11
-
12
- # Create benchmark backends
13
- def create_backend(*modules)
14
- Class.new do
15
- modules.unshift(:Base)
16
- modules.each { |m| include I18n::Backend.const_get(m) }
17
- end
18
- end
19
-
20
- BACKENDS = []
21
- BACKENDS << (SimpleBackend = create_backend)
22
- BACKENDS << (FastBackend = create_backend(:Fast))
23
- BACKENDS << (InterpolationBackend = create_backend(:InterpolationCompiler))
24
- BACKENDS << (FastInterpolBackend = create_backend(:Fast, :InterpolationCompiler))
25
-
26
- # Hack Report to print ms
27
- module Benchmark
28
- def self.ms(label = "", width=20, &blk) # :yield:
29
- print label.ljust(width)
30
- res = Benchmark::measure(&blk)
31
- print format("%10.6f ms\n", res.real * 1000)
32
- res
33
- end
34
- end
35
-
36
- # Run!
37
- BACKENDS.each do |backend|
38
- I18n.backend = backend.new
39
- puts "===> #{backend.name}\n\n"
40
-
41
- Benchmark.ms "store" do
42
- I18n.backend.store_translations *(YAML_HASH.to_a.first)
43
- I18n.backend.translate :en, :first
44
- end
45
-
46
- Benchmark.ms "t (depth=3)" do
47
- I18n.backend.translate :en, :"activerecord.models.user"
48
- end
49
-
50
- Benchmark.ms "t (depth=5)" do
51
- I18n.backend.translate :en, :"activerecord.attributes.admins.user.login"
52
- end
53
-
54
- Benchmark.ms "t (depth=7)" do
55
- I18n.backend.translate :en, :"activerecord.errors.models.user.attributes.login.blank"
56
- end
57
-
58
- Benchmark.ms "t w/ default" do
59
- I18n.backend.translate :en, :"activerecord.models.another", :default => "Another"
60
- end
61
-
62
- Benchmark.ms "t w/ interpolation" do
63
- I18n.backend.translate :en, :"activerecord.errors.models.user.blank", :model => "User", :attribute => "name"
64
- end
65
-
66
- Benchmark.ms "t subtree" do
67
- I18n.backend.translate :en, :"activerecord.errors.messages"
68
- end
69
-
70
- puts
71
- end
@@ -1,17 +0,0 @@
1
- Akira Matsuda
2
- Andrew Briening
3
- Clemens Kofler
4
- Frederick Cheung
5
- Jeremy Kemper
6
- Josh Harvey
7
- José Valim
8
- Lawrence Pit
9
- Luca Guidi
10
- M4SSIVE
11
- Marko Seppae
12
- Mathias Meyer
13
- Matt Aimonetti
14
- Michael Lang
15
- Sven Fuchs
16
- Theo Cushion
17
- Yaroslav Markin
@@ -1,165 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{i18n}
8
- s.version = "0.3.3"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Sven Fuchs", "Joshua Harvey", "Matt Aimonetti", "Stephan Soller", "Saimon Moore"]
12
- s.date = %q{2009-12-29}
13
- s.description = %q{Add Internationalization support to your Ruby application.}
14
- s.email = %q{rails-i18n@googlegroups.com}
15
- s.extra_rdoc_files = [
16
- "README.textile"
17
- ]
18
- s.files = [
19
- "CHANGELOG.textile",
20
- "MIT-LICENSE",
21
- "README.textile",
22
- "Rakefile",
23
- "lib/i18n.rb",
24
- "lib/i18n/backend.rb",
25
- "lib/i18n/backend/active_record.rb",
26
- "lib/i18n/backend/active_record/missing.rb",
27
- "lib/i18n/backend/active_record/store_procs.rb",
28
- "lib/i18n/backend/active_record/translation.rb",
29
- "lib/i18n/backend/base.rb",
30
- "lib/i18n/backend/cache.rb",
31
- "lib/i18n/backend/cascade.rb",
32
- "lib/i18n/backend/chain.rb",
33
- "lib/i18n/backend/fallbacks.rb",
34
- "lib/i18n/backend/fast.rb",
35
- "lib/i18n/backend/gettext.rb",
36
- "lib/i18n/backend/helpers.rb",
37
- "lib/i18n/backend/interpolation_compiler.rb",
38
- "lib/i18n/backend/metadata.rb",
39
- "lib/i18n/backend/pluralization.rb",
40
- "lib/i18n/backend/simple.rb",
41
- "lib/i18n/core_ext/object/meta_class.rb",
42
- "lib/i18n/core_ext/string/interpolate.rb",
43
- "lib/i18n/exceptions.rb",
44
- "lib/i18n/gettext.rb",
45
- "lib/i18n/helpers.rb",
46
- "lib/i18n/helpers/gettext.rb",
47
- "lib/i18n/locale.rb",
48
- "lib/i18n/locale/fallbacks.rb",
49
- "lib/i18n/locale/tag.rb",
50
- "lib/i18n/locale/tag/parents.rb",
51
- "lib/i18n/locale/tag/rfc4646.rb",
52
- "lib/i18n/locale/tag/simple.rb",
53
- "lib/i18n/version.rb",
54
- "test/all.rb",
55
- "test/api/basics.rb",
56
- "test/api/defaults.rb",
57
- "test/api/interpolation.rb",
58
- "test/api/link.rb",
59
- "test/api/localization/date.rb",
60
- "test/api/localization/date_time.rb",
61
- "test/api/localization/procs.rb",
62
- "test/api/localization/time.rb",
63
- "test/api/lookup.rb",
64
- "test/api/pluralization.rb",
65
- "test/api/procs.rb",
66
- "test/cases/api/active_record_test.rb",
67
- "test/cases/api/all_features_test.rb",
68
- "test/cases/api/cascade_test.rb",
69
- "test/cases/api/chain_test.rb",
70
- "test/cases/api/fallbacks_test.rb",
71
- "test/cases/api/fast_test.rb",
72
- "test/cases/api/pluralization_test.rb",
73
- "test/cases/api/simple_test.rb",
74
- "test/cases/backend/active_record/missing_test.rb",
75
- "test/cases/backend/active_record_test.rb",
76
- "test/cases/backend/cache_test.rb",
77
- "test/cases/backend/cascade_test.rb",
78
- "test/cases/backend/chain_test.rb",
79
- "test/cases/backend/fallbacks_test.rb",
80
- "test/cases/backend/fast_test.rb",
81
- "test/cases/backend/helpers_test.rb",
82
- "test/cases/backend/interpolation_compiler_test.rb",
83
- "test/cases/backend/metadata_test.rb",
84
- "test/cases/backend/pluralization_test.rb",
85
- "test/cases/backend/simple_test.rb",
86
- "test/cases/core_ext/string/interpolate_test.rb",
87
- "test/cases/gettext/api_test.rb",
88
- "test/cases/gettext/backend_test.rb",
89
- "test/cases/i18n_exceptions_test.rb",
90
- "test/cases/i18n_load_path_test.rb",
91
- "test/cases/i18n_test.rb",
92
- "test/cases/locale/fallbacks_test.rb",
93
- "test/cases/locale/tag/rfc4646_test.rb",
94
- "test/cases/locale/tag/simple_test.rb",
95
- "test/fixtures/locales/de.po",
96
- "test/fixtures/locales/en.rb",
97
- "test/fixtures/locales/en.yml",
98
- "test/fixtures/locales/plurals.rb",
99
- "test/test_helper.rb",
100
- "vendor/po_parser.rb"
101
- ]
102
- s.homepage = %q{http://rails-i18n.org}
103
- s.rdoc_options = ["--charset=UTF-8"]
104
- s.require_paths = ["lib"]
105
- s.rubyforge_project = %q{i18n}
106
- s.rubygems_version = %q{1.3.5}
107
- s.summary = %q{New wave Internationalization support for Ruby}
108
- s.test_files = [
109
- "test/all.rb",
110
- "test/api/basics.rb",
111
- "test/api/defaults.rb",
112
- "test/api/interpolation.rb",
113
- "test/api/link.rb",
114
- "test/api/localization/date.rb",
115
- "test/api/localization/date_time.rb",
116
- "test/api/localization/procs.rb",
117
- "test/api/localization/time.rb",
118
- "test/api/lookup.rb",
119
- "test/api/pluralization.rb",
120
- "test/api/procs.rb",
121
- "test/cases/api/active_record_test.rb",
122
- "test/cases/api/all_features_test.rb",
123
- "test/cases/api/cascade_test.rb",
124
- "test/cases/api/chain_test.rb",
125
- "test/cases/api/fallbacks_test.rb",
126
- "test/cases/api/fast_test.rb",
127
- "test/cases/api/pluralization_test.rb",
128
- "test/cases/api/simple_test.rb",
129
- "test/cases/backend/active_record/missing_test.rb",
130
- "test/cases/backend/active_record_test.rb",
131
- "test/cases/backend/cache_test.rb",
132
- "test/cases/backend/cascade_test.rb",
133
- "test/cases/backend/chain_test.rb",
134
- "test/cases/backend/fallbacks_test.rb",
135
- "test/cases/backend/fast_test.rb",
136
- "test/cases/backend/helpers_test.rb",
137
- "test/cases/backend/interpolation_compiler_test.rb",
138
- "test/cases/backend/metadata_test.rb",
139
- "test/cases/backend/pluralization_test.rb",
140
- "test/cases/backend/simple_test.rb",
141
- "test/cases/core_ext/string/interpolate_test.rb",
142
- "test/cases/gettext/api_test.rb",
143
- "test/cases/gettext/backend_test.rb",
144
- "test/cases/i18n_exceptions_test.rb",
145
- "test/cases/i18n_load_path_test.rb",
146
- "test/cases/i18n_test.rb",
147
- "test/cases/locale/fallbacks_test.rb",
148
- "test/cases/locale/tag/rfc4646_test.rb",
149
- "test/cases/locale/tag/simple_test.rb",
150
- "test/fixtures/locales/en.rb",
151
- "test/fixtures/locales/plurals.rb",
152
- "test/test_helper.rb"
153
- ]
154
-
155
- if s.respond_to? :specification_version then
156
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
157
- s.specification_version = 3
158
-
159
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
160
- else
161
- end
162
- else
163
- end
164
- end
165
-
@@ -1 +0,0 @@
1
- require File.dirname(__FILE__) + '/lib/i18n'
@@ -1,3 +0,0 @@
1
- module I18n
2
- VERSION = "0.3.3"
3
- end
@@ -1,8 +0,0 @@
1
- # encoding: utf-8
2
-
3
- dir = File.dirname(__FILE__)
4
- $LOAD_PATH.unshift(dir)
5
-
6
- Dir["#{dir}/**/*_test.rb"].sort.each do |file|
7
- require file.sub(/^#{dir}\/(.*)\.rb$/, '\1')
8
- end
@@ -1,15 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Tests
4
- module Api
5
- module Basics
6
- def test_available_locales
7
- store_translations('de', :foo => 'bar')
8
- store_translations('en', :foo => 'foo')
9
-
10
- assert I18n.available_locales.include?(:de)
11
- assert I18n.available_locales.include?(:en)
12
- end
13
- end
14
- end
15
- end
@@ -1,40 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Tests
4
- module Api
5
- module Defaults
6
- def setup
7
- super
8
- store_translations(:foo => { :bar => 'bar', :baz => 'baz' })
9
- end
10
-
11
- define_method "test defaults: given nil as a key it returns the given default" do
12
- assert_equal 'default', I18n.t(nil, :default => 'default')
13
- end
14
-
15
- define_method "test defaults: given a symbol as a default it translates the symbol" do
16
- assert_equal 'bar', I18n.t(nil, :default => :'foo.bar')
17
- end
18
-
19
- define_method "test defaults: given a symbol as a default and a scope it stays inside the scope when looking up the symbol" do
20
- assert_equal 'bar', I18n.t(:missing, :default => :bar, :scope => :foo)
21
- end
22
-
23
- define_method "test defaults: given an array as a default it returns the first match" do
24
- assert_equal 'bar', I18n.t(:does_not_exist, :default => [:does_not_exist_2, :'foo.bar'])
25
- end
26
-
27
- define_method "test defaults: given an array of missing keys it raises a MissingTranslationData exception" do
28
- assert_raises I18n::MissingTranslationData do
29
- I18n.t(:does_not_exist, :default => [:does_not_exist_2, :does_not_exist_3], :raise => true)
30
- end
31
- end
32
-
33
- define_method "test defaults: using a custom scope separator" do
34
- # data must have been stored using the custom separator when using the ActiveRecord backend
35
- I18n.backend.store_translations(:en, { :foo => { :bar => 'bar' } }, { :separator => '|' })
36
- assert_equal 'bar', I18n.t(nil, :default => :'foo|bar', :separator => '|')
37
- end
38
- end
39
- end
40
- end
@@ -1,92 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Tests
4
- module Api
5
- module Interpolation
6
- def interpolate(*args)
7
- options = args.last.is_a?(Hash) ? args.pop : {}
8
- key = args.pop
9
- I18n.backend.translate('en', key, options)
10
- end
11
-
12
- define_method "test interpolation: given no values it does not alter the string" do
13
- assert_equal 'Hi {{name}}!', interpolate(:default => 'Hi {{name}}!')
14
- end
15
-
16
- define_method "test interpolation: given values it interpolates them into the string" do
17
- assert_equal 'Hi David!', interpolate(:default => 'Hi {{name}}!', :name => 'David')
18
- end
19
-
20
- define_method "test interpolation: given a nil value it still interpolates it into the string" do
21
- assert_equal 'Hi !', interpolate(:default => 'Hi {{name}}!', :name => nil)
22
- end
23
-
24
- define_method "test interpolation: given a lambda as a value it calls it if the string contains the key" do
25
- assert_equal 'Hi David!', interpolate(:default => 'Hi {{name}}!', :name => lambda { |*args| 'David' })
26
- end
27
-
28
- define_method "test interpolation: given a lambda as a value it does not call it if the string does not contain the key" do
29
- assert_nothing_raised { interpolate(:default => 'Hi!', :name => lambda { |*args| raise 'fail' }) }
30
- end
31
-
32
- define_method "test interpolation: given values but missing a key it raises I18n::MissingInterpolationArgument" do
33
- assert_raises(I18n::MissingInterpolationArgument) do
34
- interpolate(:default => '{{foo}}', :bar => 'bar')
35
- end
36
- end
37
-
38
- define_method "test interpolation: it does not raise I18n::MissingInterpolationArgument for escaped variables" do
39
- assert_nothing_raised(I18n::MissingInterpolationArgument) do
40
- assert_equal 'Barr {{foo}}', interpolate(:default => '{{bar}} \{{foo}}', :bar => 'Barr')
41
- end
42
- end
43
-
44
- define_method "test interpolation: it does not change the original, stored translation string" do
45
- I18n.backend.store_translations(:en, :interpolate => 'Hi {{name}}!')
46
- assert_equal 'Hi David!', interpolate(:interpolate, :name => 'David')
47
- assert_equal 'Hi Yehuda!', interpolate(:interpolate, :name => 'Yehuda')
48
- end
49
-
50
- define_method "test interpolation: works with Ruby 1.9 syntax" do
51
- assert_equal 'Hi David!', interpolate(:default => 'Hi %{name}!', :name => 'David')
52
- end
53
-
54
- define_method "test interpolation: given the translation is in utf-8 it still works" do
55
- assert_equal 'Häi David!', interpolate(:default => 'Häi {{name}}!', :name => 'David')
56
- end
57
-
58
- define_method "test interpolation: given the value is in utf-8 it still works" do
59
- assert_equal 'Hi ゆきひろ!', interpolate(:default => 'Hi {{name}}!', :name => 'ゆきひろ')
60
- end
61
-
62
- define_method "test interpolation: given the translation and the value are in utf-8 it still works" do
63
- assert_equal 'こんにちは、ゆきひろさん!', interpolate(:default => 'こんにちは、{{name}}さん!', :name => 'ゆきひろ')
64
- end
65
-
66
- if Kernel.const_defined?(:Encoding)
67
- define_method "test interpolation: given a euc-jp translation and a utf-8 value it raises Encoding::CompatibilityError" do
68
- assert_raises(Encoding::CompatibilityError) do
69
- interpolate(:default => euc_jp('こんにちは、{{name}}さん!'), :name => 'ゆきひろ')
70
- end
71
- end
72
-
73
- # define_method "test interpolation: given a utf-8 translation and a euc-jp value it returns a translation in euc-jp" do
74
- # assert_equal euc_jp('Hi ゆきひろ!'), interpolate(:default => 'Hi {{name}}!', :name => euc_jp('ゆきひろ'))
75
- # end
76
- #
77
- # TODO should better explain how this relates to the test above with the simpler utf-8 default string
78
- define_method "test interpolation: given a utf-8 translation and a euc-jp value it raises Encoding::CompatibilityError" do
79
- assert_raises(Encoding::CompatibilityError) do
80
- interpolate(:default => 'こんにちは、{{name}}さん!', :name => euc_jp('ゆきひろ'))
81
- end
82
- end
83
- end
84
-
85
- define_method "test interpolation: given a translations containing a reserved key it raises I18n::ReservedInterpolationKey" do
86
- assert_raises(I18n::ReservedInterpolationKey) { interpolate(:default => '{{default}}', :foo => :bar) }
87
- assert_raises(I18n::ReservedInterpolationKey) { interpolate(:default => '{{scope}}', :foo => :bar) }
88
- assert_raises(I18n::ReservedInterpolationKey) { interpolate(:default => '{{separator}}', :foo => :bar) }
89
- end
90
- end
91
- end
92
- end
@@ -1,55 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Tests
4
- module Api
5
- module Link
6
- define_method "test linked lookup: if a key resolves to a symbol it looks up the symbol" do
7
- I18n.backend.store_translations 'en', {
8
- :link => :linked,
9
- :linked => 'linked'
10
- }
11
- assert_equal 'linked', I18n.backend.translate('en', :link)
12
- end
13
-
14
- define_method "test linked lookup: if a key resolves to a dot-separated symbol it looks up the symbol" do
15
- I18n.backend.store_translations 'en', {
16
- :link => :"foo.linked",
17
- :foo => { :linked => 'linked' }
18
- }
19
- assert_equal('linked', I18n.backend.translate('en', :link))
20
- end
21
-
22
- define_method "test linked lookup: if a dot-separated key resolves to a symbol it looks up the symbol" do
23
- I18n.backend.store_translations 'en', {
24
- :foo => { :link => :linked },
25
- :linked => 'linked'
26
- }
27
- assert_equal('linked', I18n.backend.translate('en', :'foo.link'))
28
- end
29
-
30
- define_method "test linked lookup: if a dot-separated key resolves to a dot-separated symbol it looks up the symbol" do
31
- I18n.backend.store_translations 'en', {
32
- :foo => { :link => :"bar.linked" },
33
- :bar => { :linked => 'linked' }
34
- }
35
- assert_equal('linked', I18n.backend.translate('en', :'foo.link'))
36
- end
37
-
38
- define_method "test linked lookup: links refer to absolute keys even if a scope was given" do
39
- I18n.backend.store_translations 'en', {
40
- :foo => { :link => :linked, :linked => 'linked in foo' },
41
- :linked => 'linked absolutely'
42
- }
43
- assert_equal 'linked absolutely', I18n.backend.translate('en', :link, :scope => :foo)
44
- end
45
-
46
- define_method "test linked lookup: a link can resolve to a namespace in the middle of a dot-separated key" do
47
- I18n.backend.store_translations 'en', {
48
- :activemodel => { :errors => { :messages => { :blank => "can't be blank" } } },
49
- :activerecord => { :errors => { :messages => :"activemodel.errors.messages" } }
50
- }
51
- assert_equal "can't be blank", I18n.t(:"activerecord.errors.messages.blank")
52
- end
53
- end
54
- end
55
- end