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/Rakefile DELETED
@@ -1,29 +0,0 @@
1
- require 'rake/testtask'
2
-
3
- task :default => [:test]
4
-
5
- Rake::TestTask.new(:test) do |t|
6
- t.pattern = "#{File.dirname(__FILE__)}/test/all.rb"
7
- t.verbose = true
8
- end
9
- Rake::Task['test'].comment = "Run all i18n tests"
10
-
11
- require File.expand_path("lib/i18n/version", File.dirname(__FILE__))
12
-
13
- begin
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |s|
16
- s.name = "i18n"
17
- s.version = I18n::VERSION
18
- s.rubyforge_project = "i18n"
19
- s.summary = "New wave Internationalization support for Ruby"
20
- s.email = "rails-i18n@googlegroups.com"
21
- s.homepage = "http://rails-i18n.org"
22
- s.description = "Add Internationalization support to your Ruby application."
23
- s.authors = ['Sven Fuchs', 'Joshua Harvey', 'Matt Aimonetti', 'Stephan Soller', 'Saimon Moore']
24
- s.files = FileList["[A-Z]*", "{lib,test}/**/*"]
25
- end
26
- Jeweler::GemcutterTasks.new
27
- rescue LoadError
28
- puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
29
- end
data/test/all.rb DELETED
@@ -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
data/test/api.rb DELETED
@@ -1,18 +0,0 @@
1
- module Tests
2
- module Api
3
- autoload :Basics, 'api/tests/basics'
4
- autoload :Defaults, 'api/tests/defaults'
5
- autoload :Interpolation, 'api/tests/interpolation'
6
- autoload :Link, 'api/tests/link'
7
- autoload :Lookup, 'api/tests/lookup'
8
- autoload :Pluralization, 'api/tests/pluralization'
9
- autoload :Procs, 'api/tests/procs'
10
-
11
- module Localization
12
- autoload :Date, 'api/tests/localization/date'
13
- autoload :DateTime, 'api/tests/localization/date_time'
14
- autoload :Procs, 'api/tests/localization/procs'
15
- autoload :Time, 'api/tests/localization/time'
16
- end
17
- end
18
- end
@@ -1,30 +0,0 @@
1
- # encoding: utf-8
2
- $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../')); $:.uniq!
3
- require 'test_helper'
4
- require 'api'
5
-
6
- require_active_record!
7
-
8
- class I18nActiveRecordApiTest < Test::Unit::TestCase
9
- def setup
10
- I18n.backend = I18n::Backend::ActiveRecord.new
11
- super
12
- end
13
-
14
- include Tests::Api::Basics
15
- include Tests::Api::Defaults
16
- include Tests::Api::Interpolation
17
- include Tests::Api::Link
18
- include Tests::Api::Lookup
19
- include Tests::Api::Pluralization
20
- include Tests::Api::Procs # unless RUBY_VERSION >= '1.9.1'
21
-
22
- include Tests::Api::Localization::Date
23
- include Tests::Api::Localization::DateTime
24
- include Tests::Api::Localization::Time
25
- include Tests::Api::Localization::Procs # unless RUBY_VERSION >= '1.9.1'
26
-
27
- test "make sure we use an ActiveRecord backend" do
28
- assert_equal I18n::Backend::ActiveRecord, I18n.backend.class
29
- end
30
- end if defined?(ActiveRecord)
@@ -1,59 +0,0 @@
1
- # encoding: utf-8
2
- $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../')); $:.uniq!
3
- begin
4
- require 'rubygems'
5
- require 'active_support'
6
- rescue LoadError
7
- puts "not testing with Cache enabled because active_support can not be found"
8
- end
9
-
10
- require 'test_helper'
11
- require 'api'
12
-
13
- class I18nAllFeaturesApiTest < Test::Unit::TestCase
14
- class Backend
15
- include I18n::Backend::Base
16
- include I18n::Backend::Cache
17
- include I18n::Backend::Metadata
18
- include I18n::Backend::Cascade
19
- include I18n::Backend::Fallbacks
20
- include I18n::Backend::Pluralization
21
- include I18n::Backend::Fast
22
- include I18n::Backend::InterpolationCompiler
23
- end
24
-
25
- def setup
26
- I18n.backend = I18n::Backend::Chain.new(Backend.new, I18n::Backend::Simple.new)
27
- I18n.cache_store = cache_store
28
- super
29
- end
30
-
31
- def teardown
32
- I18n.cache_store.clear
33
- I18n.cache_store = nil
34
- super
35
- end
36
-
37
- def cache_store
38
- ActiveSupport::Cache.lookup_store(:memory_store) if defined?(ActiveSupport) && defined?(ActiveSupport::Cache)
39
- end
40
-
41
- include Tests::Api::Basics
42
- include Tests::Api::Defaults
43
- include Tests::Api::Interpolation
44
- include Tests::Api::Link
45
- include Tests::Api::Lookup
46
- include Tests::Api::Pluralization
47
- include Tests::Api::Procs
48
- include Tests::Api::Localization::Date
49
- include Tests::Api::Localization::DateTime
50
- include Tests::Api::Localization::Time
51
- include Tests::Api::Localization::Procs
52
-
53
- test "make sure we use a Chain backend with an all features backend" do
54
- assert_equal I18n::Backend::Chain, I18n.backend.class
55
- assert_equal Backend, I18n.backend.backends.first.class
56
- end
57
-
58
- # links: test that keys stored on one backend can link to keys stored on another backend
59
- end
@@ -1,32 +0,0 @@
1
- # encoding: utf-8
2
- $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../')); $:.uniq!
3
- require 'test_helper'
4
- require 'api'
5
-
6
- class I18nCascadeApiTest < Test::Unit::TestCase
7
- class Backend
8
- include I18n::Backend::Base
9
- include I18n::Backend::Cascade
10
- end
11
-
12
- def setup
13
- I18n.backend = Backend.new
14
- super
15
- end
16
-
17
- include Tests::Api::Basics
18
- include Tests::Api::Defaults
19
- include Tests::Api::Interpolation
20
- include Tests::Api::Link
21
- include Tests::Api::Lookup
22
- include Tests::Api::Pluralization
23
- include Tests::Api::Procs
24
- include Tests::Api::Localization::Date
25
- include Tests::Api::Localization::DateTime
26
- include Tests::Api::Localization::Time
27
- include Tests::Api::Localization::Procs
28
-
29
- test "make sure we use a backend with Cascade included" do
30
- assert_equal Backend, I18n.backend.class
31
- end
32
- end
@@ -1,27 +0,0 @@
1
- # encoding: utf-8
2
- $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../')); $:.uniq!
3
- require 'test_helper'
4
- require 'api'
5
-
6
- class I18nApiChainTest < Test::Unit::TestCase
7
- def setup
8
- super
9
- I18n.backend = I18n::Backend::Chain.new(I18n::Backend::Simple.new, I18n.backend)
10
- end
11
-
12
- include Tests::Api::Basics
13
- include Tests::Api::Defaults
14
- include Tests::Api::Interpolation
15
- include Tests::Api::Link
16
- include Tests::Api::Lookup
17
- include Tests::Api::Pluralization
18
- include Tests::Api::Procs
19
- include Tests::Api::Localization::Date
20
- include Tests::Api::Localization::DateTime
21
- include Tests::Api::Localization::Time
22
- include Tests::Api::Localization::Procs
23
-
24
- test "make sure we use the Chain backend" do
25
- assert_equal I18n::Backend::Chain, I18n.backend.class
26
- end
27
- end
@@ -1,34 +0,0 @@
1
- # encoding: utf-8
2
- $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../')); $:.uniq!
3
- require 'test_helper'
4
- require 'api'
5
-
6
- class I18nFallbacksApiTest < Test::Unit::TestCase
7
- class Backend
8
- include I18n::Backend::Base
9
- include I18n::Backend::Fallbacks
10
- end
11
-
12
- def setup
13
- I18n.backend = Backend.new
14
- super
15
- end
16
-
17
- include Tests::Api::Basics
18
- include Tests::Api::Defaults
19
- include Tests::Api::Interpolation
20
- include Tests::Api::Link
21
- include Tests::Api::Lookup
22
- include Tests::Api::Pluralization
23
- include Tests::Api::Procs
24
- include Tests::Api::Localization::Date
25
- include Tests::Api::Localization::DateTime
26
- include Tests::Api::Localization::Time
27
- include Tests::Api::Localization::Procs
28
-
29
- test "make sure we use a backend with Fallbacks included" do
30
- assert_equal Backend, I18n.backend.class
31
- end
32
-
33
- # links: test that keys stored on one backend can link to keys stored on another backend
34
- end
@@ -1,32 +0,0 @@
1
- # encoding: utf-8
2
- $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../')); $:.uniq!
3
- require 'test_helper'
4
- require 'api'
5
-
6
- class I18nFastBackendApiTest < Test::Unit::TestCase
7
- include Tests::Api::Basics
8
- include Tests::Api::Defaults
9
- include Tests::Api::Interpolation
10
- include Tests::Api::Link
11
- include Tests::Api::Lookup
12
- include Tests::Api::Pluralization
13
- include Tests::Api::Procs
14
- include Tests::Api::Localization::Date
15
- include Tests::Api::Localization::DateTime
16
- include Tests::Api::Localization::Time
17
- include Tests::Api::Localization::Procs
18
-
19
- class FastBackend
20
- include I18n::Backend::Base
21
- include I18n::Backend::Fast
22
- end
23
-
24
- def setup
25
- I18n.backend = FastBackend.new
26
- super
27
- end
28
-
29
- test "make sure we use the FastBackend backend" do
30
- assert_equal FastBackend, I18n.backend.class
31
- end
32
- end
@@ -1,34 +0,0 @@
1
- # encoding: utf-8
2
- $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../')); $:.uniq!
3
- require 'test_helper'
4
- require 'api'
5
-
6
- class I18nPluralizationApiTest < Test::Unit::TestCase
7
- class Backend
8
- include I18n::Backend::Base
9
- include I18n::Backend::Pluralization
10
- end
11
-
12
- def setup
13
- I18n.backend = Backend.new
14
- super
15
- end
16
-
17
- include Tests::Api::Basics
18
- include Tests::Api::Defaults
19
- include Tests::Api::Interpolation
20
- include Tests::Api::Link
21
- include Tests::Api::Lookup
22
- include Tests::Api::Pluralization
23
- include Tests::Api::Procs
24
- include Tests::Api::Localization::Date
25
- include Tests::Api::Localization::DateTime
26
- include Tests::Api::Localization::Time
27
- include Tests::Api::Localization::Procs
28
-
29
- test "make sure we use a backend with Pluralization included" do
30
- assert_equal Backend, I18n.backend.class
31
- end
32
-
33
- # links: test that keys stored on one backend can link to keys stored on another backend
34
- end
@@ -1,23 +0,0 @@
1
- # encoding: utf-8
2
- $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../')); $:.uniq!
3
- require 'test_helper'
4
- require 'api'
5
- require 'api'
6
-
7
- class I18nSimpleBackendApiTest < Test::Unit::TestCase
8
- include Tests::Api::Basics
9
- include Tests::Api::Defaults
10
- include Tests::Api::Interpolation
11
- include Tests::Api::Link
12
- include Tests::Api::Lookup
13
- include Tests::Api::Pluralization
14
- include Tests::Api::Procs
15
- include Tests::Api::Localization::Date
16
- include Tests::Api::Localization::DateTime
17
- include Tests::Api::Localization::Time
18
- include Tests::Api::Localization::Procs
19
-
20
- test "make sure we use the Simple backend" do
21
- assert_equal I18n::Backend::Simple, I18n.backend.class
22
- end
23
- 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_raise 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_raise(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_raise(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_raise(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_raise(I18n::ReservedInterpolationKey) { interpolate(:default => '{{default}}', :foo => :bar) }
87
- assert_raise(I18n::ReservedInterpolationKey) { interpolate(:default => '{{scope}}', :foo => :bar) }
88
- assert_raise(I18n::ReservedInterpolationKey) { interpolate(:default => '{{separator}}', :foo => :bar) }
89
- end
90
- end
91
- end
92
- end