activesupport 2.3.5 → 2.3.6.pre

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 (121) hide show
  1. data/CHANGELOG +23 -0
  2. data/lib/active_support.rb +1 -0
  3. data/lib/active_support/core_ext/date_time/conversions.rb +14 -3
  4. data/lib/active_support/core_ext/enumerable.rb +6 -0
  5. data/lib/active_support/core_ext/file/atomic.rb +2 -1
  6. data/lib/active_support/core_ext/numeric/conversions.rb +2 -2
  7. data/lib/active_support/core_ext/object.rb +1 -0
  8. data/lib/active_support/core_ext/object/metaclass.rb +6 -5
  9. data/lib/active_support/core_ext/object/singleton_class.rb +13 -0
  10. data/lib/active_support/core_ext/string.rb +0 -1
  11. data/lib/active_support/core_ext/string/output_safety.rb +148 -44
  12. data/lib/active_support/core_ext/time/calculations.rb +1 -1
  13. data/lib/active_support/inflector.rb +1 -1
  14. data/lib/active_support/json/backends/yajl.rb +40 -0
  15. data/lib/active_support/json/decoding.rb +16 -1
  16. data/lib/active_support/json/encoding.rb +11 -2
  17. data/lib/active_support/ordered_hash.rb +24 -1
  18. data/lib/active_support/vendor.rb +10 -2
  19. data/lib/active_support/vendor/i18n-0.3.3/CHANGELOG.textile +76 -0
  20. data/lib/active_support/vendor/{i18n-0.1.3 → i18n-0.3.3}/MIT-LICENSE +0 -0
  21. data/lib/active_support/vendor/i18n-0.3.3/README.textile +81 -0
  22. data/lib/active_support/vendor/i18n-0.3.3/Rakefile +24 -0
  23. data/lib/active_support/vendor/i18n-0.3.3/benchmark/example.yml +144 -0
  24. data/lib/active_support/vendor/i18n-0.3.3/benchmark/run.rb +71 -0
  25. data/lib/active_support/vendor/i18n-0.3.3/contributors.txt +17 -0
  26. data/lib/active_support/vendor/i18n-0.3.3/i18n.gemspec +165 -0
  27. data/lib/active_support/vendor/i18n-0.3.3/init.rb +1 -0
  28. data/lib/active_support/vendor/{i18n-0.1.3 → i18n-0.3.3}/lib/i18n.rb +99 -21
  29. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend.rb +17 -0
  30. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/active_record.rb +70 -0
  31. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/active_record/missing.rb +67 -0
  32. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/active_record/store_procs.rb +38 -0
  33. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/active_record/translation.rb +83 -0
  34. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/base.rb +259 -0
  35. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/cache.rb +75 -0
  36. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/cascade.rb +44 -0
  37. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/chain.rb +74 -0
  38. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/fallbacks.rb +52 -0
  39. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/fast.rb +68 -0
  40. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/gettext.rb +75 -0
  41. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/helpers.rb +80 -0
  42. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/interpolation_compiler.rb +119 -0
  43. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/metadata.rb +73 -0
  44. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/pluralization.rb +57 -0
  45. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/backend/simple.rb +22 -0
  46. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/core_ext/object/meta_class.rb +5 -0
  47. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/core_ext/string/interpolate.rb +99 -0
  48. data/lib/active_support/vendor/{i18n-0.1.3 → i18n-0.3.3}/lib/i18n/exceptions.rb +14 -6
  49. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/gettext.rb +25 -0
  50. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/helpers.rb +5 -0
  51. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/helpers/gettext.rb +64 -0
  52. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/locale.rb +6 -0
  53. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/locale/fallbacks.rb +98 -0
  54. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/locale/tag.rb +28 -0
  55. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/locale/tag/parents.rb +24 -0
  56. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/locale/tag/rfc4646.rb +76 -0
  57. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/locale/tag/simple.rb +41 -0
  58. data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/version.rb +3 -0
  59. data/lib/active_support/vendor/i18n-0.3.3/test/all.rb +8 -0
  60. data/lib/active_support/vendor/i18n-0.3.3/test/api/basics.rb +15 -0
  61. data/lib/active_support/vendor/i18n-0.3.3/test/api/defaults.rb +40 -0
  62. data/lib/active_support/vendor/i18n-0.3.3/test/api/interpolation.rb +92 -0
  63. data/lib/active_support/vendor/i18n-0.3.3/test/api/link.rb +55 -0
  64. data/lib/active_support/vendor/i18n-0.3.3/test/api/localization/date.rb +91 -0
  65. data/lib/active_support/vendor/i18n-0.3.3/test/api/localization/date_time.rb +90 -0
  66. data/lib/active_support/vendor/i18n-0.3.3/test/api/localization/procs.rb +54 -0
  67. data/lib/active_support/vendor/i18n-0.3.3/test/api/localization/time.rb +84 -0
  68. data/lib/active_support/vendor/i18n-0.3.3/test/api/lookup.rb +45 -0
  69. data/lib/active_support/vendor/i18n-0.3.3/test/api/pluralization.rb +35 -0
  70. data/lib/active_support/vendor/i18n-0.3.3/test/api/procs.rb +40 -0
  71. data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/active_record_test.rb +29 -0
  72. data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/all_features_test.rb +40 -0
  73. data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/cascade_test.rb +31 -0
  74. data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/chain_test.rb +26 -0
  75. data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/fallbacks_test.rb +33 -0
  76. data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/fast_test.rb +31 -0
  77. data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/pluralization_test.rb +33 -0
  78. data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/simple_test.rb +21 -0
  79. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/active_record/missing_test.rb +60 -0
  80. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/active_record_test.rb +52 -0
  81. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/cache_test.rb +72 -0
  82. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/cascade_test.rb +66 -0
  83. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/chain_test.rb +64 -0
  84. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/fallbacks_test.rb +57 -0
  85. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/fast_test.rb +50 -0
  86. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/helpers_test.rb +26 -0
  87. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/interpolation_compiler_test.rb +107 -0
  88. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/metadata_test.rb +67 -0
  89. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/pluralization_test.rb +43 -0
  90. data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/simple_test.rb +77 -0
  91. data/lib/active_support/vendor/i18n-0.3.3/test/cases/core_ext/string/interpolate_test.rb +94 -0
  92. data/lib/active_support/vendor/i18n-0.3.3/test/cases/gettext/api_test.rb +201 -0
  93. data/lib/active_support/vendor/i18n-0.3.3/test/cases/gettext/backend_test.rb +91 -0
  94. data/lib/active_support/vendor/{i18n-0.1.3/test → i18n-0.3.3/test/cases}/i18n_exceptions_test.rb +8 -10
  95. data/lib/active_support/vendor/i18n-0.3.3/test/cases/i18n_load_path_test.rb +23 -0
  96. data/lib/active_support/vendor/i18n-0.3.3/test/cases/i18n_test.rb +172 -0
  97. data/lib/active_support/vendor/i18n-0.3.3/test/cases/locale/fallbacks_test.rb +126 -0
  98. data/lib/active_support/vendor/i18n-0.3.3/test/cases/locale/tag/rfc4646_test.rb +143 -0
  99. data/lib/active_support/vendor/i18n-0.3.3/test/cases/locale/tag/simple_test.rb +33 -0
  100. data/lib/active_support/vendor/i18n-0.3.3/test/fixtures/locales/de.po +72 -0
  101. data/lib/active_support/vendor/i18n-0.3.3/test/fixtures/locales/en.rb +3 -0
  102. data/lib/active_support/vendor/i18n-0.3.3/test/fixtures/locales/en.yml +3 -0
  103. data/lib/active_support/vendor/i18n-0.3.3/test/fixtures/locales/plurals.rb +113 -0
  104. data/lib/active_support/vendor/i18n-0.3.3/test/test_helper.rb +100 -0
  105. data/lib/active_support/vendor/i18n-0.3.3/vendor/po_parser.rb +329 -0
  106. data/lib/active_support/version.rb +1 -1
  107. data/lib/active_support/whiny_nil.rb +1 -1
  108. data/lib/active_support/xml_mini/libxml.rb +23 -83
  109. data/lib/active_support/xml_mini/libxmlsax.rb +74 -0
  110. data/lib/active_support/xml_mini/nokogiri.rb +25 -22
  111. data/lib/active_support/xml_mini/nokogirisax.rb +73 -0
  112. metadata +108 -20
  113. data/lib/active_support/vendor/i18n-0.1.3/README.textile +0 -20
  114. data/lib/active_support/vendor/i18n-0.1.3/Rakefile +0 -5
  115. data/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec +0 -27
  116. data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb +0 -214
  117. data/lib/active_support/vendor/i18n-0.1.3/test/all.rb +0 -5
  118. data/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +0 -124
  119. data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb +0 -1
  120. data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml +0 -3
  121. data/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +0 -567
@@ -22,6 +22,15 @@ module ActiveSupport
22
22
  end
23
23
 
24
24
  ESCAPED_CHARS = {
25
+ "\x00" => '\u0000', "\x01" => '\u0001', "\x02" => '\u0002',
26
+ "\x03" => '\u0003', "\x04" => '\u0004', "\x05" => '\u0005',
27
+ "\x06" => '\u0006', "\x07" => '\u0007', "\x0B" => '\u000B',
28
+ "\x0E" => '\u000E', "\x0F" => '\u000F', "\x10" => '\u0010',
29
+ "\x11" => '\u0011', "\x12" => '\u0012', "\x13" => '\u0013',
30
+ "\x14" => '\u0014', "\x15" => '\u0015', "\x16" => '\u0016',
31
+ "\x17" => '\u0017', "\x18" => '\u0018', "\x19" => '\u0019',
32
+ "\x1A" => '\u001A', "\x1B" => '\u001B', "\x1C" => '\u001C',
33
+ "\x1D" => '\u001D', "\x1E" => '\u001E', "\x1F" => '\u001F',
25
34
  "\010" => '\b',
26
35
  "\f" => '\f',
27
36
  "\n" => '\n',
@@ -43,9 +52,9 @@ module ActiveSupport
43
52
  def escape_html_entities_in_json=(value)
44
53
  self.escape_regex = \
45
54
  if @escape_html_entities_in_json = value
46
- /[\010\f\n\r\t"\\><&]/
55
+ /[\x00-\x1F"\\><&]/
47
56
  else
48
- /[\010\f\n\r\t"\\]/
57
+ /[\x00-\x1F"\\]/
49
58
  end
50
59
  end
51
60
 
@@ -1,8 +1,11 @@
1
+ require 'yaml'
2
+
1
3
  # OrderedHash is namespaced to prevent conflicts with other implementations
2
4
  module ActiveSupport
3
5
  # Hash is ordered in Ruby 1.9!
4
6
  if RUBY_VERSION >= '1.9'
5
- OrderedHash = ::Hash
7
+ class OrderedHash < ::Hash #:nodoc:
8
+ end
6
9
  else
7
10
  class OrderedHash < Hash #:nodoc:
8
11
  def initialize(*args, &block)
@@ -138,4 +141,24 @@ module ActiveSupport
138
141
  end
139
142
  end
140
143
  end
144
+
145
+ class OrderedHash #:nodoc:
146
+ def to_yaml_type
147
+ "!tag:yaml.org,2002:omap"
148
+ end
149
+
150
+ def to_yaml(opts = {})
151
+ YAML.quick_emit(self, opts) do |out|
152
+ out.seq(taguri, to_yaml_style) do |seq|
153
+ each do |k, v|
154
+ seq.add(k => v)
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end
160
+
161
+ YAML.add_builtin_type("omap") do |type, val|
162
+ ActiveSupport::OrderedHash[val.map(&:to_a).map(&:first)]
163
+ end
141
164
  end
@@ -21,8 +21,16 @@ rescue Gem::LoadError
21
21
  end
22
22
 
23
23
  begin
24
- gem 'i18n', '>= 0.1.3'
24
+ gem 'i18n', '>= 0.3.3'
25
25
  rescue Gem::LoadError
26
- $:.unshift "#{File.dirname(__FILE__)}/vendor/i18n-0.1.3/lib"
26
+ $:.unshift "#{File.dirname(__FILE__)}/vendor/i18n-0.3.3/lib"
27
27
  end
28
28
  require 'i18n'
29
+
30
+ module I18n
31
+ if !respond_to?(:normalize_translation_keys) && respond_to?(:normalize_keys)
32
+ def self.normalize_translation_keys(*args)
33
+ normalize_keys(*args)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,76 @@
1
+ h1. Changelog
2
+
3
+ h2. master
4
+
5
+ * (no changes)
6
+
7
+ h2. 0.3.1 (2009-12-11)
8
+
9
+ * "Add PoParser to gemspec":http://github.com/svenfuchs/i18n/commit/d6b2763f39c932f66adb039b96882a472f883c51
10
+ * "Enable custom separators for ActiveRecord backend":http://github.com/svenfuchs/i18n/commit/9341d3fcfc951cc31807ba672d2b5d90909ef3e5
11
+ * "Pass interpolation values to interpolation procs":http://github.com/svenfuchs/i18n/commit/39c2ed8fbad645671cd5520ce7ad0aeefe2b0cca
12
+ * "Fix that ngettext supports keys with dots":http://github.com/svenfuchs/i18n/commit/7362a43c34364d500de8899cfcca6bf1a5e6d1c8
13
+
14
+ h2. 0.3.0 (2009-11-30)
15
+
16
+ * "Gettext backend and helpers":http://github.com/svenfuchs/i18n/commit/35a1740d2f10b808548af352006950da4017e374
17
+ * "Metadata module":http://github.com/svenfuchs/i18n/commit/2677208555179b36fcbe958c0e8bc642cf5bc020
18
+ * "Basic ActiveRecord backend":http://github.com/svenfuchs/i18n/commit/786632d0b42de423ecf0969622efc87f1691e2a2
19
+ * "Set encoding to UTF8 for all files":http://github.com/svenfuchs/i18n/commit/9be3d4a311b5bf583eec5d39986176cc40c112f2
20
+ * "Chain backend":http://github.com/svenfuchs/i18n/commit/08259ffb88b3005403648d77bc1cbca0b92f3cf5
21
+ * "Backend/cache implementation":http://github.com/svenfuchs/i18n/commit/e7bf15351cd2e27f5972eb40e65a5dd6f4a0feed
22
+ * "Pluralization module":http://github.com/svenfuchs/i18n/commit/9ca4c9ed52d4706566a6abeb2d78722dcc5d4764
23
+ * "add and adapt Globalize2 fallback implementation":http://github.com/svenfuchs/i18n/commit/1b37a303b27d6222b17162804b06323e5628768f
24
+ * "move Simple backend implementation to a Base backend class and extend Simple from Base.":http://github.com/svenfuchs/i18n/commit/32ddc80a04e6aa247f6d6613bde7f78c73396cb4
25
+
26
+ h2. 0.2.0 (2009-07-12)
27
+
28
+ * "Allow using Ruby 1.9 syntax for string interpolation (API addition)":http://github.com/svenfuchs/i18n/commit/c6e0b06d512f2af57199a843a1d8a40241b32861
29
+ * "Allow configuring the default scope separator, allow to pass a custom scope separator(API addition)":http://github.com/svenfuchs/i18n/commit/5b75bfbc348061adc11e3790187a187275bfd471 (e.g. I18n.t(:'foo|bar', :separator => '|')
30
+ * "Pass :format option to #translate for #localize more useful lambda support":http://github.com/svenfuchs/i18n/commit/e277711b3c844fe7589b8d3f9af0f7d1b969a273
31
+ * "Refactor Simple backend #resolve to #default and #resolve for more consistency. Now allows to pass lambdas as defaults and re-resolve Symbols":http://github.com/svenfuchs/i18n/commit/8c4ce3d923ce5fa73e973fe28217e18165549aba
32
+ * "Add lambda support to #translate (API addition)":http://github.com/svenfuchs/i18n/commit/c90e62d8f7d3d5b78f34cfe328d871b58884f115
33
+ * "Add lambda support to #localize (API addition)":http://github.com/svenfuchs/i18n/commit/9d390afcf33f3f469bb95e6888147152f6cc7442
34
+
35
+ h2. 0.1.3 (2009-02-27)
36
+
37
+ * "Remove unnecessary string encoding handling in the i18n simple backend which made the backend break on Ruby 1.9":http://github.com/svenfuchs/i18n/commit/4c3a970783861a94f2e89f46714fb3434e4f4f8d
38
+
39
+ h2. 0.1.2 (2009-01-09)
40
+
41
+ * "added #available_locales (returns an array of locales for which translations are available)":http://github.com/svenfuchs/i18n/commit/411f8fe7c8f3f89e9b6b921fa62ed66cb92f3af4
42
+ * "flatten load_path before using it so that a nested array of paths won't throw up":http://github.com/svenfuchs/i18n/commit/d473a068a2b90aba98135deb225d6eb6d8104d70
43
+
44
+ h2. 0.1.1 (2008-11-20)
45
+
46
+ * "Use :'en' as a default locale (in favor of :'en-US')":http://github.com/svenfuchs/i18n/commit/c4b10b246aecf7da78cb2568dd0d2ab7e6b8a230
47
+ * "Add #reload! to Simple backend":http://github.com/svenfuchs/i18n/commit/36dd2bd9973b9e1559728749a9daafa44693e964
48
+
49
+ h2. 0.1.0 (2008-10-25)
50
+
51
+ * "Fix Simple backend to distinguish false from nil values":http://github.com/svenfuchs/i18n/commit/39d9a47da14b5f3ba126af48923af8c30e135166
52
+ * "Add #load_path to public api, add initialize to simple backend and remove #load_translations from public api":http://github.com/svenfuchs/i18n/commit/c4c5649e6bc8f020f1aaf5a5470bde048e22c82d
53
+ * "Speed up Backend::Simple#interpolate":http://github.com/svenfuchs/i18n/commit/9e1ac6bf8833304e036323ec9932b9f33c468a35
54
+ * "Remove #populate and #store_translations from public API":http://github.com/svenfuchs/i18n/commit/f4e514a80be7feb509f66824ee311905e2940900
55
+ * "Use :other instead of :many as a plural key":http://github.com/svenfuchs/i18n/commit/0f8f20a2552bf6a2aa758d8fdd62a7154e4a1bf6
56
+ * "Use a class instead of a module for Simple backend":http://github.com/svenfuchs/i18n/commit/08f051aa61320c17debde24a83268bc74e33b995
57
+ * "Make Simple backend #interpolate deal with non-ASCII string encodings":http://github.com/svenfuchs/i18n/commit/d84a3f3f55543c084d5dc5d1fed613b8df148789
58
+ * "Fix default arrays of non-existant keys returning the default array":http://github.com/svenfuchs/i18n/commit/6c04ca86c87f97dc78f07c2a4023644e5ba8b839
59
+
60
+ h2. Initial implementation (June/July 2008)
61
+
62
+ Initial implementation by "Sven Fuchs":http://www.workingwithrails.com/person/9963-sven-fuchs based on previous discussion/consensus of the rails-i18n team (alphabetical order) and many others:
63
+
64
+ * "Matt Aimonetti":http://railsontherun.com
65
+ * "Sven Fuchs":http://www.workingwithrails.com/person/9963-sven-fuchs
66
+ * "Joshua Harvey":http://www.workingwithrails.com/person/759-joshua-harvey
67
+ * "Saimon Moore":http://saimonmoore.net
68
+ * "Stephan Soller":http://www.arkanis-development.de
69
+
70
+ h2. More information
71
+
72
+ * "Homepage":http://rails-i18n.org
73
+ * "Wiki":http://rails-i18n.org/wiki
74
+ * "Mailinglist":http://groups.google.com/group/rails-i18n
75
+ * "About the project/history":http://www.artweb-design.de/2008/7/18/finally-ruby-on-rails-gets-internationalized
76
+ * "Initial API Intro":http://www.artweb-design.de/2008/7/18/the-ruby-on-rails-i18n-core-api
@@ -0,0 +1,81 @@
1
+ h1. Ruby I18n
2
+
3
+ Ruby Internationalization and localization solution.
4
+
5
+ Features:
6
+
7
+ * translation and localization
8
+ * interpolation of values to translations (Ruby 1.9 compatible syntax)
9
+ * pluralization (CLDR compatible)
10
+ * flexible defaults
11
+ * bulk lookup
12
+ * lambdas as translation data
13
+ * custom key/scope separator
14
+ * custom exception handlers
15
+ * extensible architecture with a swappable backend
16
+
17
+ Pluggable features:
18
+
19
+ * Cache
20
+ * Pluralization: lambda pluralizers stored as translation data
21
+ * Locale fallbacks, RFC4647 compliant (optionally: RFC4646 locale validation)
22
+ * Gettext support
23
+ * Translation metadata
24
+
25
+ Alternative backends:
26
+
27
+ * Chain
28
+ * ActiveRecord (optionally: ActiveRecordMissing)
29
+
30
+ For more information and lots of resources see: "http://rails-i18n.org/wiki":http://rails-i18n.org/wiki
31
+
32
+ h2. Installation
33
+
34
+ gem install i18n
35
+
36
+ h3. Installation on Rails < 2.3.5 (deprecated)
37
+
38
+ Up to version 2.3.4 Rails will not accept i18n gems > 0.1.3. There is an unpacked
39
+ gem inside of active_support/lib/vendor which gets loaded unless gem 'i18n', '~> 0.1.3'.
40
+ This requirement is relaxed in "6da03653":http://github.com/rails/rails/commit/6da03653
41
+
42
+ The new i18n gem can be loaded from vendor/plugins like this:
43
+
44
+ def reload_i18n!
45
+ raise "Move to i18n version 0.2.0 or greater" if Rails.version > "2.3.4"
46
+
47
+ $:.grep(/i18n/).each { |path| $:.delete(path) }
48
+ I18n::Backend.send :remove_const, "Simple"
49
+ $: << Rails.root.join('vendor', 'plugins', 'i18n', 'lib').to_s
50
+ end
51
+
52
+ Then you can `reload_i18n!` inside an i18n initializer.
53
+
54
+ h2. Authors
55
+
56
+ * "Sven Fuchs":http://www.artweb-design.de
57
+ * "Joshua Harvey":http://www.workingwithrails.com/person/759-joshua-harvey
58
+ * "Stephan Soller":http://www.arkanis-development.de
59
+ * "Saimon Moore":http://saimonmoore.net
60
+ * "Matt Aimonetti":http://railsontherun.com
61
+
62
+ h2. Contributors
63
+
64
+ * Akira Matsuda
65
+ * Andrew Briening
66
+ * Clemens Kofler
67
+ * Frederick Cheung
68
+ * Jeremy Kemper
69
+ * José Valim
70
+ * Lawrence Pit
71
+ * Luca Guidi
72
+ * M4SSIVE
73
+ * Marko Seppae
74
+ * Mathias Meyer
75
+ * Michael Lang
76
+ * Theo Cushion
77
+ * Yaroslav Markin
78
+
79
+ h2. License
80
+
81
+ MIT License. See the included MIT-LICENCE file.
@@ -0,0 +1,24 @@
1
+ task :default => [:test]
2
+
3
+ task :test do
4
+ ruby "test/all.rb"
5
+ end
6
+
7
+ require File.expand_path("lib/i18n/version", File.dirname(__FILE__))
8
+
9
+ begin
10
+ require 'jeweler'
11
+ Jeweler::Tasks.new do |s|
12
+ s.name = "i18n"
13
+ s.version = I18n::VERSION
14
+ s.rubyforge_project = "i18n"
15
+ s.summary = "New wave Internationalization support for Ruby"
16
+ s.email = "rails-i18n@googlegroups.com"
17
+ s.homepage = "http://rails-i18n.org"
18
+ s.description = "Add Internationalization support to your Ruby application."
19
+ s.authors = ['Sven Fuchs', 'Joshua Harvey', 'Matt Aimonetti', 'Stephan Soller', 'Saimon Moore']
20
+ s.files = FileList["[A-Z]*", "{lib,test,vendor}/**/*"]
21
+ end
22
+ rescue LoadError
23
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
24
+ end
@@ -0,0 +1,144 @@
1
+ en:
2
+ first: "First"
3
+ activerecord:
4
+ errors:
5
+ messages:
6
+ inclusion: "is not included in the list"
7
+ exclusion: "is reserved"
8
+ invalid: "is invalid"
9
+ confirmation: "doesn't match confirmation"
10
+ accepted: "must be accepted"
11
+ empty: "can't be empty"
12
+ blank: "can't be blank"
13
+ too_long: "is too long (maximum is {{count}} characters)"
14
+ too_short: "is too short (minimum is {{count}} characters)"
15
+ wrong_length: "is the wrong length (should be {{count}} characters)"
16
+ taken: "has already been taken"
17
+ not_a_number: "is not a number"
18
+ greater_than: "must be greater than {{count}}"
19
+ greater_than_or_equal_to: "must be greater than or equal to {{count}}"
20
+ equal_to: "must be equal to {{count}}"
21
+ less_than: "must be less than {{count}}"
22
+ less_than_or_equal_to: "must be less than or equal to {{count}}"
23
+ odd: "must be odd"
24
+ even: "must be even"
25
+ record_invalid: "Validation failed: {{errors}}"
26
+
27
+ models:
28
+ user:
29
+ blank: "This is a custom blank message for {{model}}: {{attribute}}"
30
+ attributes:
31
+ login:
32
+ blank: "This is a custom blank message for User login"
33
+
34
+
35
+ models:
36
+ user: "Dude"
37
+
38
+ attributes:
39
+ admins:
40
+ user:
41
+ login: "Handle"
42
+
43
+ date:
44
+ formats:
45
+ # Use the strftime parameters for formats.
46
+ # When no format has been given, it uses default.
47
+ # You can provide other formats here if you like!
48
+ default: "%Y-%m-%d"
49
+ short: "%b %d"
50
+ long: "%B %d, %Y"
51
+
52
+ day_names: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]
53
+ abbr_day_names: [Sun, Mon, Tue, Wed, Thu, Fri, Sat]
54
+
55
+ # Don't forget the nil at the beginning; there's no such thing as a 0th month
56
+ month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December]
57
+ abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]
58
+ # Used in date_select and datime_select.
59
+ order: [ :year, :month, :day ]
60
+
61
+ time:
62
+ formats:
63
+ default: "%a, %d %b %Y %H:%M:%S %z"
64
+ short: "%d %b %H:%M"
65
+ long: "%B %d, %Y %H:%M"
66
+ am: "am"
67
+ pm: "pm"
68
+
69
+ support:
70
+ array:
71
+ words_connector: ", "
72
+ two_words_connector: " and "
73
+ last_word_connector: ", and "
74
+
75
+ activemodel:
76
+ errors:
77
+ messages:
78
+ inclusion: "is not included in the list"
79
+ exclusion: "is reserved"
80
+ invalid: "is invalid"
81
+ confirmation: "doesn't match confirmation"
82
+ accepted: "must be accepted"
83
+ empty: "can't be empty"
84
+ blank: "can't be blank"
85
+ too_long: "is too long (maximum is {{count}} characters)"
86
+ too_short: "is too short (minimum is {{count}} characters)"
87
+ wrong_length: "is the wrong length (should be {{count}} characters)"
88
+ taken: "has already been taken"
89
+ not_a_number: "is not a number"
90
+ greater_than: "must be greater than {{count}}"
91
+ greater_than_or_equal_to: "must be greater than or equal to {{count}}"
92
+ equal_to: "must be equal to {{count}}"
93
+ less_than: "must be less than {{count}}"
94
+ less_than_or_equal_to: "must be less than or equal to {{count}}"
95
+ odd: "must be odd"
96
+ even: "must be even"
97
+ record_invalid: "Validation failed: {{errors}}"
98
+
99
+ models:
100
+ user:
101
+ blank: "This is a custom blank message for {{model}}: {{attribute}}"
102
+ attributes:
103
+ login:
104
+ blank: "This is a custom blank message for User login"
105
+
106
+ models:
107
+ user: "Dude"
108
+
109
+ attributes:
110
+ user:
111
+ login: "Handle"
112
+
113
+ model_data:
114
+ date:
115
+ formats:
116
+ # Use the strftime parameters for formats.
117
+ # When no format has been given, it uses default.
118
+ # You can provide other formats here if you like!
119
+ default: "%Y-%m-%d"
120
+ short: "%b %d"
121
+ long: "%B %d, %Y"
122
+
123
+ day_names: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]
124
+ abbr_day_names: [Sun, Mon, Tue, Wed, Thu, Fri, Sat]
125
+
126
+ # Don't forget the nil at the beginning; there's no such thing as a 0th month
127
+ month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December]
128
+ abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]
129
+ # Used in date_select and datime_select.
130
+ order: [ :year, :month, :day ]
131
+
132
+ time:
133
+ formats:
134
+ default: "%a, %d %b %Y %H:%M:%S %z"
135
+ short: "%d %b %H:%M"
136
+ long: "%B %d, %Y %H:%M"
137
+ am: "am"
138
+ pm: "pm"
139
+
140
+ support:
141
+ array:
142
+ words_connector: ", "
143
+ two_words_connector: " and "
144
+ last_word_connector: ", and "
@@ -0,0 +1,71 @@
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