r18n-core 1.1.11 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +4 -0
  3. data/README.md +2 -2
  4. data/lib/r18n-core/filter_list.rb +2 -3
  5. data/lib/r18n-core/filters.rb +9 -10
  6. data/lib/r18n-core/helpers.rb +0 -1
  7. data/lib/r18n-core/i18n.rb +1 -2
  8. data/lib/r18n-core/locale.rb +10 -12
  9. data/lib/r18n-core/translated.rb +3 -4
  10. data/lib/r18n-core/translated_string.rb +0 -1
  11. data/lib/r18n-core/translation.rb +2 -3
  12. data/lib/r18n-core/unsupported_locale.rb +0 -1
  13. data/lib/r18n-core/untranslated.rb +0 -1
  14. data/lib/r18n-core/utils.rb +0 -11
  15. data/lib/r18n-core/version.rb +1 -2
  16. data/lib/r18n-core/yaml_loader.rb +0 -1
  17. data/lib/r18n-core/yaml_methods.rb +2 -8
  18. data/lib/r18n-core.rb +0 -3
  19. data/locales/bg.rb +11 -13
  20. data/locales/ca.rb +13 -14
  21. data/locales/cs.rb +15 -16
  22. data/locales/da.rb +13 -15
  23. data/locales/de.rb +14 -15
  24. data/locales/en-au.rb +2 -2
  25. data/locales/en-gb.rb +2 -2
  26. data/locales/en-us.rb +5 -7
  27. data/locales/en.rb +14 -14
  28. data/locales/eo.rb +11 -12
  29. data/locales/es-us.rb +6 -8
  30. data/locales/es.rb +11 -12
  31. data/locales/fi.rb +16 -17
  32. data/locales/fr.rb +10 -11
  33. data/locales/gl.rb +12 -13
  34. data/locales/hr.rb +12 -13
  35. data/locales/hu.rb +12 -13
  36. data/locales/id.rb +9 -9
  37. data/locales/it.rb +9 -10
  38. data/locales/ja.rb +11 -12
  39. data/locales/kk.rb +16 -18
  40. data/locales/lv.rb +16 -17
  41. data/locales/mn.rb +12 -14
  42. data/locales/nb.rb +12 -13
  43. data/locales/nl.rb +13 -14
  44. data/locales/no.rb +12 -13
  45. data/locales/pl.rb +13 -14
  46. data/locales/pt-br.rb +2 -3
  47. data/locales/pt.rb +13 -14
  48. data/locales/ru.rb +14 -15
  49. data/locales/sk.rb +15 -16
  50. data/locales/sr-latn.rb +12 -14
  51. data/locales/sv-se.rb +11 -13
  52. data/locales/th.rb +13 -14
  53. data/locales/tr.rb +12 -15
  54. data/locales/uk.rb +11 -15
  55. data/locales/zh-cn.rb +2 -3
  56. data/locales/zh-tw.rb +5 -6
  57. data/locales/zh.rb +10 -11
  58. data/r18n-core.gemspec +5 -4
  59. data/spec/filters_spec.rb +94 -91
  60. data/spec/i18n_spec.rb +66 -68
  61. data/spec/locale_spec.rb +74 -74
  62. data/spec/locales/cs_spec.rb +14 -14
  63. data/spec/locales/en-us_spec.rb +6 -6
  64. data/spec/locales/en_spec.rb +6 -6
  65. data/spec/locales/fr_spec.rb +2 -2
  66. data/spec/locales/hu_spec.rb +6 -7
  67. data/spec/locales/it_spec.rb +3 -4
  68. data/spec/locales/pl_spec.rb +14 -14
  69. data/spec/locales/ru_spec.rb +13 -13
  70. data/spec/locales/sk_spec.rb +14 -14
  71. data/spec/locales/th_spec.rb +2 -2
  72. data/spec/r18n_spec.rb +47 -49
  73. data/spec/spec_helper.rb +0 -7
  74. data/spec/translated_spec.rb +26 -28
  75. data/spec/translation_spec.rb +38 -40
  76. data/spec/yaml_loader_spec.rb +14 -16
  77. metadata +2 -2
@@ -1,22 +1,21 @@
1
- # encoding: utf-8
2
1
  require File.expand_path('../spec_helper', __FILE__)
3
2
 
4
3
  describe R18n::Translation do
5
4
 
6
5
  it "returns unstranslated string if translation isn't found" do
7
6
  i18n = R18n::I18n.new('en', DIR)
8
- i18n.not.exists.should be_a(R18n::Untranslated)
9
- i18n.not.exists.should_not be_translated
10
- (i18n.not.exists | 'default').should == 'default'
11
- i18n.not.exists.locale.should == R18n.locale('en')
7
+ expect(i18n.not.exists).to be_kind_of(R18n::Untranslated)
8
+ expect(i18n.not.exists).not_to be_translated
9
+ expect(i18n.not.exists | 'default').to eq('default')
10
+ expect(i18n.not.exists.locale).to eq(R18n.locale('en'))
12
11
 
13
- i18n.not.exists.should == i18n.not.exists
14
- i18n.not.exists.should_not == i18n.not.exists2
12
+ expect(i18n.not.exists).to eq(i18n.not.exists)
13
+ expect(i18n.not.exists).not_to eq(i18n.not.exists2)
15
14
 
16
- (i18n.in | 'default').should == 'default'
15
+ expect(i18n.in | 'default').to eq('default')
17
16
 
18
- i18n.one.should be_translated
19
- (i18n.one | 'default').should == 'One'
17
+ expect(i18n.one).to be_translated
18
+ expect(i18n.one | 'default').to eq('One')
20
19
  end
21
20
 
22
21
  it "returns html escaped string" do
@@ -27,81 +26,80 @@ describe R18n::Translation do
27
26
  end
28
27
  str = klass.new('1', nil, nil)
29
28
 
30
- str.should be_html_safe
31
- str.html_safe.should == '2'
29
+ expect(str).to be_html_safe
30
+ expect(str.html_safe).to eq('2')
32
31
  end
33
32
 
34
33
  it "loads use hierarchical translations" do
35
34
  i18n = R18n::I18n.new(['ru', 'en'], DIR)
36
- i18n.in.another.level.should == 'Иерархический'
37
- i18n[:in][:another][:level].should == 'Иерархический'
38
- i18n['in']['another']['level'].should == 'Иерархический'
39
- i18n.only.english.should == 'Only in English'
35
+ expect(i18n.in.another.level).to eq('Иерархический')
36
+ expect(i18n[:in][:another][:level]).to eq('Иерархический')
37
+ expect(i18n['in']['another']['level']).to eq('Иерархический')
38
+ expect(i18n.only.english).to eq('Only in English')
40
39
  end
41
40
 
42
41
  it "saves path for translation" do
43
42
  i18n = R18n::I18n.new('en', DIR)
44
43
 
45
- i18n.in.another.level.path.should == 'in.another.level'
44
+ expect(i18n.in.another.level.path).to eq('in.another.level')
46
45
 
47
- i18n.in.another.not.exists.path.should == 'in.another.not.exists'
48
- i18n.in.another.not.exists.untranslated_path.should == 'not.exists'
49
- i18n.in.another.not.exists.translated_path.should == 'in.another.'
46
+ expect(i18n.in.another.not.exists.path).to eq('in.another.not.exists')
47
+ expect(i18n.in.another.not.exists.untranslated_path).to eq('not.exists')
48
+ expect(i18n.in.another.not.exists.translated_path).to eq('in.another.')
50
49
 
51
- i18n.not.untranslated_path.should == 'not'
52
- i18n.not.translated_path.should == ''
50
+ expect(i18n.not.untranslated_path).to eq('not')
51
+ expect(i18n.not.translated_path).to eq('')
53
52
  end
54
53
 
55
54
  it "returns translation keys" do
56
55
  i18n = R18n::I18n.new('en', [DIR, TWO])
57
- i18n.in.translation_keys.should =~ ['another', 'two']
56
+ expect(i18n.in.translation_keys).to match_array(['another', 'two'])
58
57
  end
59
58
 
60
59
  it "returns string with locale info" do
61
60
  i18n = R18n::I18n.new(['nolocale', 'en'], DIR)
62
- i18n.one.locale.should == R18n::UnsupportedLocale.new('nolocale')
63
- i18n.two.locale.should == R18n.locale('en')
61
+ expect(i18n.one.locale).to eq(R18n::UnsupportedLocale.new('nolocale'))
62
+ expect(i18n.two.locale).to eq(R18n.locale('en'))
64
63
  end
65
64
 
66
65
  it "filters typed data" do
67
66
  en = R18n.locale('en')
68
- translation = R18n::Translation.new(en, '', :locale => en, :translations =>
67
+ translation = R18n::Translation.new(en, '', locale: en, translations:
69
68
  { 'count' => R18n::Typed.new('pl', { 1 => 'one', 'n' => 'many' }) })
70
69
 
71
- translation.count(1).should == 'one'
72
- translation.count(5).should == 'many'
70
+ expect(translation.count(1)).to eq('one')
71
+ expect(translation.count(5)).to eq('many')
73
72
  end
74
73
 
75
74
  it "returns hash of translations" do
76
75
  i18n = R18n::I18n.new('en', DIR)
77
- i18n.in.to_hash.should == {
76
+ expect(i18n.in.to_hash).to eq({
78
77
  'another' => { 'level' => 'Hierarchical' }
79
- }
78
+ })
80
79
  end
81
80
 
82
81
  it "returns untranslated, when we go deeper string" do
83
82
  en = R18n.locale('en')
84
83
  translation = R18n::Translation.new(en, '',
85
- :locale => en, :translations => { 'a' => 'A' })
84
+ locale: en, translations: { 'a' => 'A' })
86
85
 
87
- translation.a.no_tr.should be_a(R18n::Untranslated)
88
- translation.a.no_tr.translated_path.should == 'a.'
89
- translation.a.no_tr.untranslated_path.should == 'no_tr'
86
+ expect(translation.a.no_tr).to be_kind_of(R18n::Untranslated)
87
+ expect(translation.a.no_tr.translated_path).to eq('a.')
88
+ expect(translation.a.no_tr.untranslated_path).to eq('no_tr')
90
89
  end
91
90
 
92
91
  it "inspects translation" do
93
92
  en = R18n.locale('en')
94
93
 
95
94
  translation = R18n::Translation.new(en, 'a',
96
- :locale => en, :translations => { 'a' => 'A' })
97
- translation.inspect.should == 'Translation `a` for en {"a"=>"A"}'
95
+ locale: en, translations: { 'a' => 'A' })
96
+ expect(translation.inspect).to eq('Translation `a` for en {"a"=>"A"}')
98
97
 
99
98
  translation = R18n::Translation.new(en, '',
100
- :locale => en, :translations => { 'a' => 'A' })
101
- translation.inspect.should == 'Translation root for en {"a"=>"A"}'
99
+ locale: en, translations: { 'a' => 'A' })
100
+ expect(translation.inspect).to eq('Translation root for en {"a"=>"A"}')
102
101
 
103
102
  translation = R18n::Translation.new(en, '')
104
- translation.inspect.should == 'Translation root for en {}'
103
+ expect(translation.inspect).to eq('Translation root for en {}')
105
104
  end
106
-
107
105
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  require File.expand_path('../spec_helper', __FILE__)
3
2
 
4
3
  describe R18n::Loader::YAML do
@@ -15,45 +14,44 @@ describe R18n::Loader::YAML do
15
14
  end
16
15
 
17
16
  it "returns dir with translations" do
18
- @loader.dir.should == DIR.expand_path.to_s
17
+ expect(@loader.dir).to eq(DIR.expand_path.to_s)
19
18
  end
20
19
 
21
20
  it "equals to another YAML loader with same dir" do
22
- @loader.should == R18n::Loader::YAML.new(DIR)
23
- @loader.should_not == Class.new(R18n::Loader::YAML).new(DIR)
21
+ expect(@loader).to eq(R18n::Loader::YAML.new(DIR))
22
+ expect(@loader).not_to eq(Class.new(R18n::Loader::YAML).new(DIR))
24
23
  end
25
24
 
26
25
  it "returns all available translations" do
27
- @loader.available.should =~ [R18n.locale('ru'),
26
+ expect(@loader.available).to match_array([R18n.locale('ru'),
28
27
  R18n.locale('en'),
29
- R18n.locale('nolocale')]
28
+ R18n.locale('nolocale')])
30
29
  end
31
30
 
32
31
  it "loads translation" do
33
- @loader.load(R18n.locale('ru')).should == {
32
+ expect(@loader.load(R18n.locale('ru'))).to eq({
34
33
  'one' => 'Один',
35
34
  'in' => { 'another' => { 'level' => 'Иерархический' } },
36
35
  'typed' => R18n::Typed.new('my', 'value')
37
- }
36
+ })
38
37
  end
39
38
 
40
39
  it "returns hash by dir" do
41
- @loader.hash.should == R18n::Loader::YAML.new(DIR).hash
40
+ expect(@loader.hash).to eq(R18n::Loader::YAML.new(DIR).hash)
42
41
  end
43
42
 
44
43
  it "loads in dir recursively" do
45
44
  loader = R18n::Loader::YAML.new(TRANSLATIONS)
46
- loader.available.should =~ [R18n.locale('ru'),
45
+ expect(loader.available).to match_array([R18n.locale('ru'),
47
46
  R18n.locale('en'),
48
47
  R18n.locale('fr'),
49
48
  R18n.locale('notransl'),
50
- R18n.locale('nolocale')]
49
+ R18n.locale('nolocale')])
51
50
 
52
51
  translation = loader.load(R18n.locale('en'))
53
- translation['two'].should == 'Two'
54
- translation['in']['two'].should == 'Two'
55
- translation['ext'].should == 'Extension'
56
- translation['deep'].should == 'Deep one'
52
+ expect(translation['two']).to eq('Two')
53
+ expect(translation['in']['two']).to eq('Two')
54
+ expect(translation['ext']).to eq('Extension')
55
+ expect(translation['deep']).to eq('Deep one')
57
56
  end
58
-
59
57
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r18n-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.11
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Sitnik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-20 00:00:00.000000000 Z
11
+ date: 2014-12-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  R18n is a i18n tool to translate your Ruby application.