i18n 0.3.0 → 0.3.1

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 (68) hide show
  1. data/CHANGELOG.textile +19 -0
  2. data/README.textile +41 -15
  3. data/Rakefile +1 -1
  4. data/VERSION +1 -1
  5. data/lib/i18n.rb +1 -1
  6. data/lib/i18n/backend/active_record.rb +6 -5
  7. data/lib/i18n/backend/active_record/missing.rb +64 -0
  8. data/lib/i18n/backend/active_record/translation.rb +2 -2
  9. data/lib/i18n/backend/base.rb +2 -2
  10. data/lib/i18n/backend/chain.rb +3 -3
  11. data/lib/i18n/helpers/gettext.rb +1 -1
  12. data/test/all.rb +4 -4
  13. data/test/api/basics.rb +8 -8
  14. data/test/api/defaults.rb +40 -0
  15. data/test/api/interpolation.rb +65 -67
  16. data/test/api/link.rb +31 -38
  17. data/test/api/localization/date.rb +69 -50
  18. data/test/api/localization/date_time.rb +66 -42
  19. data/test/api/localization/procs.rb +54 -0
  20. data/test/api/localization/time.rb +71 -52
  21. data/test/api/lookup.rb +38 -0
  22. data/test/api/pluralization.rb +22 -24
  23. data/test/api/procs.rb +40 -0
  24. data/test/cases/api/active_record_test.rb +28 -0
  25. data/test/cases/api/all_features_test.rb +37 -0
  26. data/test/cases/api/chain_test.rb +26 -0
  27. data/test/cases/api/fallbacks_test.rb +33 -0
  28. data/test/cases/api/pluralization_test.rb +33 -0
  29. data/test/cases/api/simple_test.rb +21 -0
  30. data/test/{backend/active_record_missing/active_record_missing_test.rb → cases/backend/active_record/missing_test.rb} +5 -8
  31. data/test/{backend/active_record → cases/backend}/active_record_test.rb +13 -3
  32. data/test/{backend/cache → cases/backend}/cache_test.rb +7 -7
  33. data/test/{backend/chain → cases/backend}/chain_test.rb +1 -1
  34. data/test/{backend/fallbacks → cases/backend}/fallbacks_test.rb +5 -5
  35. data/test/{backend/simple → cases/backend}/helpers_test.rb +1 -1
  36. data/test/{backend/metadata → cases/backend}/metadata_test.rb +12 -10
  37. data/test/{backend/pluralization → cases/backend}/pluralization_test.rb +10 -10
  38. data/test/cases/backend/simple_test.rb +77 -0
  39. data/test/{core_ext → cases/core_ext}/string/interpolate_test.rb +15 -15
  40. data/test/{gettext → cases/gettext}/api_test.rb +1 -4
  41. data/test/{gettext → cases/gettext}/backend_test.rb +9 -2
  42. data/test/{i18n_exceptions_test.rb → cases/i18n_exceptions_test.rb} +1 -1
  43. data/test/{i18n_load_path_test.rb → cases/i18n_load_path_test.rb} +2 -2
  44. data/test/{i18n_test.rb → cases/i18n_test.rb} +1 -1
  45. data/test/{locale → cases/locale}/fallbacks_test.rb +1 -3
  46. data/test/{locale → cases/locale}/tag/rfc4646_test.rb +1 -3
  47. data/test/{locale → cases/locale}/tag/simple_test.rb +1 -3
  48. data/test/fixtures/locales/de.po +5 -0
  49. data/test/test_helper.rb +45 -30
  50. data/vendor/po_parser.rb +329 -0
  51. metadata +60 -69
  52. data/lib/i18n/backend/active_record_missing.rb +0 -55
  53. data/test/api/lambda.rb +0 -52
  54. data/test/api/localization/lambda.rb +0 -26
  55. data/test/api/translation.rb +0 -51
  56. data/test/backend/active_record/all.rb +0 -3
  57. data/test/backend/active_record/api_test.rb +0 -54
  58. data/test/backend/active_record/setup.rb +0 -166
  59. data/test/backend/all/api_test.rb +0 -88
  60. data/test/backend/chain/api_test.rb +0 -80
  61. data/test/backend/fallbacks/api_test.rb +0 -84
  62. data/test/backend/pluralization/api_test.rb +0 -86
  63. data/test/backend/simple/all.rb +0 -5
  64. data/test/backend/simple/api_test.rb +0 -92
  65. data/test/backend/simple/lookup_test.rb +0 -24
  66. data/test/backend/simple/setup.rb +0 -147
  67. data/test/backend/simple/translations_test.rb +0 -83
  68. data/test/with_options.rb +0 -34
@@ -1,83 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
4
-
5
- class I18nSimpleBackendLoadTranslationsTest < Test::Unit::TestCase
6
- include Tests::Backend::Simple::Setup::Base
7
-
8
- def test_load_translations_with_unknown_file_type_raises_exception
9
- assert_raises(I18n::UnknownFileType) { I18n.backend.load_translations "#{locales_dir}/en.xml" }
10
- end
11
-
12
- def test_load_translations_with_ruby_file_type_does_not_raise_exception
13
- assert_nothing_raised { I18n.backend.load_translations "#{locales_dir}/en.rb" }
14
- end
15
-
16
- def test_load_rb_loads_data_from_ruby_file
17
- data = I18n.backend.send :load_rb, "#{locales_dir}/en.rb"
18
- assert_equal({ :en => { :fuh => { :bah => 'bas' } } }, data)
19
- end
20
-
21
- def test_load_rb_loads_data_from_yaml_file
22
- data = I18n.backend.send :load_yml, "#{locales_dir}/en.yml"
23
- assert_equal({ 'en' => { 'foo' => { 'bar' => 'baz' } } }, data)
24
- end
25
-
26
- def test_load_translations_loads_from_different_file_formats
27
- I18n.backend = I18n::Backend::Simple.new
28
- I18n.backend.load_translations "#{locales_dir}/en.rb", "#{locales_dir}/en.yml"
29
- expected = { :en => { :fuh => { :bah => "bas" }, :foo => { :bar => "baz" } } }
30
- assert_equal expected, backend_get_translations
31
- end
32
- end
33
-
34
- class I18nSimpleBackendStoreTranslationsTest < Test::Unit::TestCase
35
- include Tests::Backend::Simple::Setup::Base
36
-
37
- def test_store_translations_adds_translations # no, really :-)
38
- I18n.backend.store_translations :'en', :foo => 'bar'
39
- assert_equal Hash[:'en', {:foo => 'bar'}], backend_get_translations
40
- end
41
-
42
- def test_store_translations_deep_merges_translations
43
- I18n.backend.store_translations :'en', :foo => {:bar => 'bar'}
44
- I18n.backend.store_translations :'en', :foo => {:baz => 'baz'}
45
- assert_equal Hash[:'en', {:foo => {:bar => 'bar', :baz => 'baz'}}], backend_get_translations
46
- end
47
-
48
- def test_store_translations_forces_locale_to_sym
49
- I18n.backend.store_translations 'en', :foo => 'bar'
50
- assert_equal Hash[:'en', {:foo => 'bar'}], backend_get_translations
51
- end
52
-
53
- def test_store_translations_converts_keys_to_symbols
54
- # backend_reset_translations!
55
- I18n.backend.store_translations 'en', 'foo' => {'bar' => 'bar', 'baz' => 'baz'}
56
- assert_equal Hash[:'en', {:foo => {:bar => 'bar', :baz => 'baz'}}], backend_get_translations
57
- end
58
- end
59
-
60
- class I18nSimpleBackendReloadTranslationsTest < Test::Unit::TestCase
61
- include Tests::Backend::Simple::Setup::Base
62
-
63
- def setup
64
- I18n.backend = I18n::Backend::Simple.new
65
- I18n.load_path = [locales_dir + '/en.yml']
66
- assert_nil backend_get_translations
67
- I18n.backend.send :init_translations
68
- end
69
-
70
- def test_setup
71
- assert_not_nil backend_get_translations
72
- end
73
-
74
- def test_reload_translations_unloads_translations
75
- I18n.backend.reload!
76
- assert_nil backend_get_translations
77
- end
78
-
79
- def test_reload_translations_uninitializes_translations
80
- I18n.backend.reload!
81
- assert_equal I18n.backend.initialized?, false
82
- end
83
- end
@@ -1,34 +0,0 @@
1
- # encoding: utf-8
2
-
3
- # this is only here so we can test I18n works nicely with ActiveSupports
4
- # with_options. Maybe we can just remove it?
5
-
6
- class Object
7
- def with_options(options)
8
- yield ActiveSupport::OptionMerger.new(self, options)
9
- end
10
- end
11
-
12
- module ActiveSupport
13
- class OptionMerger #:nodoc:
14
- instance_methods.each do |method|
15
- undef_method(method) if method !~ /^(__|instance_eval|class|object_id)/
16
- end
17
-
18
- def initialize(context, options)
19
- @context, @options = context, options
20
- end
21
-
22
- private
23
- def method_missing(method, *arguments, &block)
24
- if arguments.last.is_a?(Proc)
25
- proc = arguments.pop
26
- arguments << lambda { |*args| @options.deep_merge(proc.call(*args)) }
27
- else
28
- arguments << (arguments.last.respond_to?(:to_hash) ? @options.deep_merge(arguments.pop) : @options.dup)
29
- end
30
-
31
- @context.__send__(method, *arguments, &block)
32
- end
33
- end
34
- end