i18n 0.3.6 → 0.3.7

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

Potentially problematic release.


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

Files changed (62) hide show
  1. data/lib/i18n.rb +29 -4
  2. data/lib/i18n/backend/active_record/translation.rb +6 -4
  3. data/lib/i18n/backend/base.rb +1 -1
  4. data/lib/i18n/locale/fallbacks.rb +4 -4
  5. data/lib/i18n/version.rb +1 -1
  6. metadata +16 -116
  7. data/CHANGELOG.textile +0 -76
  8. data/MIT-LICENSE +0 -20
  9. data/README.textile +0 -104
  10. data/Rakefile +0 -29
  11. data/test/all.rb +0 -8
  12. data/test/api.rb +0 -18
  13. data/test/api/active_record_test.rb +0 -30
  14. data/test/api/all_features_test.rb +0 -59
  15. data/test/api/cascade_test.rb +0 -32
  16. data/test/api/chain_test.rb +0 -27
  17. data/test/api/fallbacks_test.rb +0 -34
  18. data/test/api/fast_test.rb +0 -32
  19. data/test/api/pluralization_test.rb +0 -34
  20. data/test/api/simple_test.rb +0 -23
  21. data/test/api/tests/basics.rb +0 -15
  22. data/test/api/tests/defaults.rb +0 -40
  23. data/test/api/tests/interpolation.rb +0 -92
  24. data/test/api/tests/link.rb +0 -56
  25. data/test/api/tests/localization/date.rb +0 -96
  26. data/test/api/tests/localization/date_time.rb +0 -93
  27. data/test/api/tests/localization/procs.rb +0 -60
  28. data/test/api/tests/localization/time.rb +0 -88
  29. data/test/api/tests/lookup.rb +0 -62
  30. data/test/api/tests/pluralization.rb +0 -35
  31. data/test/api/tests/procs.rb +0 -55
  32. data/test/backend/active_record/missing_test.rb +0 -51
  33. data/test/backend/active_record_test.rb +0 -57
  34. data/test/backend/cache_test.rb +0 -71
  35. data/test/backend/cascade_test.rb +0 -73
  36. data/test/backend/chain_test.rb +0 -63
  37. data/test/backend/cldr_test.rb +0 -151
  38. data/test/backend/exceptions_test.rb +0 -25
  39. data/test/backend/fallbacks_test.rb +0 -107
  40. data/test/backend/fast_test.rb +0 -50
  41. data/test/backend/helpers_test.rb +0 -27
  42. data/test/backend/interpolation_compiler_test.rb +0 -108
  43. data/test/backend/metadata_test.rb +0 -66
  44. data/test/backend/pluralization_test.rb +0 -47
  45. data/test/backend/simple_test.rb +0 -77
  46. data/test/core_ext/string/interpolate_test.rb +0 -99
  47. data/test/gettext/api_test.rb +0 -207
  48. data/test/gettext/backend_test.rb +0 -91
  49. data/test/i18n_exceptions_test.rb +0 -97
  50. data/test/i18n_load_path_test.rb +0 -23
  51. data/test/i18n_test.rb +0 -207
  52. data/test/locale/fallbacks_test.rb +0 -126
  53. data/test/locale/tag/rfc4646_test.rb +0 -143
  54. data/test/locale/tag/simple_test.rb +0 -33
  55. data/test/test_data/locales/cldr/de/calendars.yml +0 -152
  56. data/test/test_data/locales/cldr/de/currencies.yml +0 -8
  57. data/test/test_data/locales/cldr/de/numbers.yml +0 -31
  58. data/test/test_data/locales/de.po +0 -72
  59. data/test/test_data/locales/en.rb +0 -3
  60. data/test/test_data/locales/en.yml +0 -3
  61. data/test/test_data/locales/plurals.rb +0 -113
  62. data/test/test_helper.rb +0 -116
data/lib/i18n.rb CHANGED
@@ -256,10 +256,10 @@ module I18n
256
256
  # Splits keys that contain dots into multiple keys. Makes sure all
257
257
  # keys are Symbols.
258
258
  def normalize_keys(locale, key, scope, separator = nil)
259
- keys = [locale] + Array(scope) + Array(key)
260
- keys = keys.map { |k| k.to_s.split(separator || I18n.default_separator) }
261
- keys = keys.flatten - ['']
262
- keys.map { |k| k.to_sym }
259
+ separator ||= I18n.default_separator
260
+ normalize_key(locale, separator) +
261
+ normalize_key(scope, separator) +
262
+ normalize_key(key, separator)
263
263
  end
264
264
 
265
265
  # making these private until Ruby 1.9.2 can send to protected methods again
@@ -306,5 +306,30 @@ module I18n
306
306
  def normalize_translation_keys(locale, key, scope, separator = nil)
307
307
  normalize_keys(locale, key, scope, separator)
308
308
  end
309
+
310
+ def normalize_key(key, separator)
311
+ normalized_key_cache(separator)[key] ||=
312
+ case key
313
+ when Array
314
+ key.map { |k| normalize_key(k, separator) }.flatten
315
+ when nil
316
+ []
317
+ else
318
+ key = key.to_s
319
+ if key == ''
320
+ []
321
+ elsif key.include?(separator)
322
+ keys = key.split(separator) - ['']
323
+ keys.map { |k| k.to_sym }
324
+ else
325
+ [key.to_sym]
326
+ end
327
+ end
328
+ end
329
+
330
+ def normalized_key_cache(separator)
331
+ @normalized_key_cache ||= Hash.new { |h,k| h[k] = {} }
332
+ @normalized_key_cache[separator]
333
+ end
309
334
  end
310
335
  end
@@ -48,15 +48,17 @@ module I18n
48
48
  class Translation < ::ActiveRecord::Base
49
49
  set_table_name 'translations'
50
50
  attr_protected :is_proc, :interpolations
51
-
51
+
52
52
  serialize :value
53
53
  serialize :interpolations, Array
54
54
 
55
- named_scope :locale, lambda { |locale|
55
+ scope_method = ::ActiveRecord::VERSION::MAJOR == 2 ? :named_scope : :scope
56
+
57
+ send scope_method, :locale, lambda { |locale|
56
58
  { :conditions => { :locale => locale.to_s } }
57
59
  }
58
60
 
59
- named_scope :lookup, lambda { |keys, *separator|
61
+ send scope_method, :lookup, lambda { |keys, *separator|
60
62
  column_name = connection.quote_column_name('key')
61
63
  keys = Array(keys).map! { |key| key.to_s }
62
64
  separator = separator.first || I18n.default_separator
@@ -67,7 +69,7 @@ module I18n
67
69
  def self.available_locales
68
70
  Translation.find(:all, :select => 'DISTINCT locale').map { |t| t.locale.to_sym }
69
71
  end
70
-
72
+
71
73
  def interpolates?(key)
72
74
  self.interpolations.include?(key) if self.interpolations
73
75
  end
@@ -117,7 +117,7 @@ module I18n
117
117
  return nil unless result.is_a?(Hash) && result.has_key?(key)
118
118
  result = result[key]
119
119
  result = resolve(locale, key, result, options) if result.is_a?(Symbol)
120
- result
120
+ String === result ? result.dup : result
121
121
  end
122
122
  end
123
123
 
@@ -28,7 +28,7 @@
28
28
  #
29
29
  # I18n.default_locale = :"en-US"
30
30
  # I18n.fallbacks = I18n::Fallbacks.new(:"de-AT" => :"de-DE")
31
- # I18n.fallbacks[:"de-AT"] # => [:"de-AT", :"de-DE", :de, :"en-US", :en]
31
+ # I18n.fallbacks[:"de-AT"] # => [:"de-AT", :"de-DE", :de, :"en-US", :en] # TODO does not seem to work this way?
32
32
  #
33
33
  # # using a custom locale as default fallback locale
34
34
  #
@@ -55,10 +55,10 @@
55
55
  module I18n
56
56
  module Locale
57
57
  class Fallbacks < Hash
58
- def initialize(*mappings)
58
+ def initialize(*args)
59
59
  @map = {}
60
- map(mappings.pop) if mappings.last.is_a?(Hash)
61
- self.defaults = mappings.empty? ? [I18n.default_locale.to_sym] : mappings
60
+ map(args.pop) if args.last.is_a?(Hash) # TODO allow mappings anywhere in the args array
61
+ self.defaults = args.empty? ? [I18n.default_locale.to_sym] : args
62
62
  end
63
63
 
64
64
  def defaults=(defaults)
data/lib/i18n/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module I18n
2
- VERSION = "0.3.6"
2
+ VERSION = "0.3.7"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 6
9
- version: 0.3.6
8
+ - 7
9
+ version: 0.3.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sven Fuchs
@@ -18,23 +18,19 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2010-03-23 00:00:00 +01:00
21
+ date: 2010-04-17 00:00:00 +02:00
22
22
  default_executable:
23
23
  dependencies: []
24
24
 
25
- description: Add Internationalization support to your Ruby application.
25
+ description: New wave Internationalization support for Ruby.
26
26
  email: rails-i18n@googlegroups.com
27
27
  executables: []
28
28
 
29
29
  extensions: []
30
30
 
31
- extra_rdoc_files:
32
- - README.textile
31
+ extra_rdoc_files: []
32
+
33
33
  files:
34
- - CHANGELOG.textile
35
- - MIT-LICENSE
36
- - README.textile
37
- - Rakefile
38
34
  - lib/i18n.rb
39
35
  - lib/i18n/backend.rb
40
36
  - lib/i18n/backend/active_record.rb
@@ -71,65 +67,13 @@ files:
71
67
  - lib/i18n/locale/tag/rfc4646.rb
72
68
  - lib/i18n/locale/tag/simple.rb
73
69
  - lib/i18n/version.rb
74
- - test/all.rb
75
- - test/api.rb
76
- - test/api/active_record_test.rb
77
- - test/api/all_features_test.rb
78
- - test/api/cascade_test.rb
79
- - test/api/chain_test.rb
80
- - test/api/fallbacks_test.rb
81
- - test/api/fast_test.rb
82
- - test/api/pluralization_test.rb
83
- - test/api/simple_test.rb
84
- - test/api/tests/basics.rb
85
- - test/api/tests/defaults.rb
86
- - test/api/tests/interpolation.rb
87
- - test/api/tests/link.rb
88
- - test/api/tests/localization/date.rb
89
- - test/api/tests/localization/date_time.rb
90
- - test/api/tests/localization/procs.rb
91
- - test/api/tests/localization/time.rb
92
- - test/api/tests/lookup.rb
93
- - test/api/tests/pluralization.rb
94
- - test/api/tests/procs.rb
95
- - test/backend/active_record/missing_test.rb
96
- - test/backend/active_record_test.rb
97
- - test/backend/cache_test.rb
98
- - test/backend/cascade_test.rb
99
- - test/backend/chain_test.rb
100
- - test/backend/cldr_test.rb
101
- - test/backend/exceptions_test.rb
102
- - test/backend/fallbacks_test.rb
103
- - test/backend/fast_test.rb
104
- - test/backend/helpers_test.rb
105
- - test/backend/interpolation_compiler_test.rb
106
- - test/backend/metadata_test.rb
107
- - test/backend/pluralization_test.rb
108
- - test/backend/simple_test.rb
109
- - test/core_ext/string/interpolate_test.rb
110
- - test/gettext/api_test.rb
111
- - test/gettext/backend_test.rb
112
- - test/i18n_exceptions_test.rb
113
- - test/i18n_load_path_test.rb
114
- - test/i18n_test.rb
115
- - test/locale/fallbacks_test.rb
116
- - test/locale/tag/rfc4646_test.rb
117
- - test/locale/tag/simple_test.rb
118
- - test/test_data/locales/cldr/de/calendars.yml
119
- - test/test_data/locales/cldr/de/currencies.yml
120
- - test/test_data/locales/cldr/de/numbers.yml
121
- - test/test_data/locales/de.po
122
- - test/test_data/locales/en.rb
123
- - test/test_data/locales/en.yml
124
- - test/test_data/locales/plurals.rb
125
- - test/test_helper.rb
126
70
  has_rdoc: true
127
- homepage: http://rails-i18n.org
71
+ homepage: http://github.com/svenfuchs/i18n
128
72
  licenses: []
129
73
 
130
74
  post_install_message:
131
- rdoc_options:
132
- - --charset=UTF-8
75
+ rdoc_options: []
76
+
133
77
  require_paths:
134
78
  - lib
135
79
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -144,60 +88,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
88
  - - ">="
145
89
  - !ruby/object:Gem::Version
146
90
  segments:
147
- - 0
148
- version: "0"
91
+ - 1
92
+ - 3
93
+ - 6
94
+ version: 1.3.6
149
95
  requirements: []
150
96
 
151
- rubyforge_project: i18n
97
+ rubyforge_project: "[none]"
152
98
  rubygems_version: 1.3.6
153
99
  signing_key:
154
100
  specification_version: 3
155
101
  summary: New wave Internationalization support for Ruby
156
- test_files:
157
- - test/all.rb
158
- - test/api/active_record_test.rb
159
- - test/api/all_features_test.rb
160
- - test/api/cascade_test.rb
161
- - test/api/chain_test.rb
162
- - test/api/fallbacks_test.rb
163
- - test/api/fast_test.rb
164
- - test/api/pluralization_test.rb
165
- - test/api/simple_test.rb
166
- - test/api/tests/basics.rb
167
- - test/api/tests/defaults.rb
168
- - test/api/tests/interpolation.rb
169
- - test/api/tests/link.rb
170
- - test/api/tests/localization/date.rb
171
- - test/api/tests/localization/date_time.rb
172
- - test/api/tests/localization/procs.rb
173
- - test/api/tests/localization/time.rb
174
- - test/api/tests/lookup.rb
175
- - test/api/tests/pluralization.rb
176
- - test/api/tests/procs.rb
177
- - test/api.rb
178
- - test/backend/active_record/missing_test.rb
179
- - test/backend/active_record_test.rb
180
- - test/backend/cache_test.rb
181
- - test/backend/cascade_test.rb
182
- - test/backend/chain_test.rb
183
- - test/backend/cldr_test.rb
184
- - test/backend/exceptions_test.rb
185
- - test/backend/fallbacks_test.rb
186
- - test/backend/fast_test.rb
187
- - test/backend/helpers_test.rb
188
- - test/backend/interpolation_compiler_test.rb
189
- - test/backend/metadata_test.rb
190
- - test/backend/pluralization_test.rb
191
- - test/backend/simple_test.rb
192
- - test/core_ext/string/interpolate_test.rb
193
- - test/gettext/api_test.rb
194
- - test/gettext/backend_test.rb
195
- - test/i18n_exceptions_test.rb
196
- - test/i18n_load_path_test.rb
197
- - test/i18n_test.rb
198
- - test/locale/fallbacks_test.rb
199
- - test/locale/tag/rfc4646_test.rb
200
- - test/locale/tag/simple_test.rb
201
- - test/test_data/locales/en.rb
202
- - test/test_data/locales/plurals.rb
203
- - test/test_helper.rb
102
+ test_files: []
103
+
data/CHANGELOG.textile DELETED
@@ -1,76 +0,0 @@
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
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2008 The Ruby I18n team
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile DELETED
@@ -1,104 +0,0 @@
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. Tests
55
-
56
- You can run tests both with
57
-
58
- * `rake test` or just `rake`
59
- * run any test file directly, e.g. `ruby test/api/simple_test.rb`
60
- * run all tests with `ruby test/all.rb`
61
-
62
- The structure of the test suite is a bit unusual as it uses modules to reuse
63
- particular tests in different test cases.
64
-
65
- The reason for this is that we need to enforce the I18n API across various
66
- combinations of extensions. E.g. the Simple backend alone needs to support
67
- the same API as any combination of feature and/or optimization modules included
68
- to the Simple backend. We test this by reusing the same API defition (implemented
69
- as test methods) in test cases with different setups.
70
-
71
- You can find the test cases that enforce the API in test/api. And you can find
72
- the API definition test methods in test/api/tests.
73
-
74
- All other test cases (e.g. as defined in test/backend, test/core\_ext) etc.
75
- follow the usual test setup and should be easy to grok.
76
-
77
- h2. Authors
78
-
79
- * "Sven Fuchs":http://www.artweb-design.de
80
- * "Joshua Harvey":http://www.workingwithrails.com/person/759-joshua-harvey
81
- * "Stephan Soller":http://www.arkanis-development.de
82
- * "Saimon Moore":http://saimonmoore.net
83
- * "Matt Aimonetti":http://railsontherun.com
84
-
85
- h2. Contributors
86
-
87
- * Akira Matsuda
88
- * Andrew Briening
89
- * Clemens Kofler
90
- * Frederick Cheung
91
- * Jeremy Kemper
92
- * José Valim
93
- * Lawrence Pit
94
- * Luca Guidi
95
- * M4SSIVE
96
- * Marko Seppae
97
- * Mathias Meyer
98
- * Michael Lang
99
- * Theo Cushion
100
- * Yaroslav Markin
101
-
102
- h2. License
103
-
104
- MIT License. See the included MIT-LICENSE file.