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.
- checksums.yaml +4 -4
- data/ChangeLog.md +4 -0
- data/README.md +2 -2
- data/lib/r18n-core/filter_list.rb +2 -3
- data/lib/r18n-core/filters.rb +9 -10
- data/lib/r18n-core/helpers.rb +0 -1
- data/lib/r18n-core/i18n.rb +1 -2
- data/lib/r18n-core/locale.rb +10 -12
- data/lib/r18n-core/translated.rb +3 -4
- data/lib/r18n-core/translated_string.rb +0 -1
- data/lib/r18n-core/translation.rb +2 -3
- data/lib/r18n-core/unsupported_locale.rb +0 -1
- data/lib/r18n-core/untranslated.rb +0 -1
- data/lib/r18n-core/utils.rb +0 -11
- data/lib/r18n-core/version.rb +1 -2
- data/lib/r18n-core/yaml_loader.rb +0 -1
- data/lib/r18n-core/yaml_methods.rb +2 -8
- data/lib/r18n-core.rb +0 -3
- data/locales/bg.rb +11 -13
- data/locales/ca.rb +13 -14
- data/locales/cs.rb +15 -16
- data/locales/da.rb +13 -15
- data/locales/de.rb +14 -15
- data/locales/en-au.rb +2 -2
- data/locales/en-gb.rb +2 -2
- data/locales/en-us.rb +5 -7
- data/locales/en.rb +14 -14
- data/locales/eo.rb +11 -12
- data/locales/es-us.rb +6 -8
- data/locales/es.rb +11 -12
- data/locales/fi.rb +16 -17
- data/locales/fr.rb +10 -11
- data/locales/gl.rb +12 -13
- data/locales/hr.rb +12 -13
- data/locales/hu.rb +12 -13
- data/locales/id.rb +9 -9
- data/locales/it.rb +9 -10
- data/locales/ja.rb +11 -12
- data/locales/kk.rb +16 -18
- data/locales/lv.rb +16 -17
- data/locales/mn.rb +12 -14
- data/locales/nb.rb +12 -13
- data/locales/nl.rb +13 -14
- data/locales/no.rb +12 -13
- data/locales/pl.rb +13 -14
- data/locales/pt-br.rb +2 -3
- data/locales/pt.rb +13 -14
- data/locales/ru.rb +14 -15
- data/locales/sk.rb +15 -16
- data/locales/sr-latn.rb +12 -14
- data/locales/sv-se.rb +11 -13
- data/locales/th.rb +13 -14
- data/locales/tr.rb +12 -15
- data/locales/uk.rb +11 -15
- data/locales/zh-cn.rb +2 -3
- data/locales/zh-tw.rb +5 -6
- data/locales/zh.rb +10 -11
- data/r18n-core.gemspec +5 -4
- data/spec/filters_spec.rb +94 -91
- data/spec/i18n_spec.rb +66 -68
- data/spec/locale_spec.rb +74 -74
- data/spec/locales/cs_spec.rb +14 -14
- data/spec/locales/en-us_spec.rb +6 -6
- data/spec/locales/en_spec.rb +6 -6
- data/spec/locales/fr_spec.rb +2 -2
- data/spec/locales/hu_spec.rb +6 -7
- data/spec/locales/it_spec.rb +3 -4
- data/spec/locales/pl_spec.rb +14 -14
- data/spec/locales/ru_spec.rb +13 -13
- data/spec/locales/sk_spec.rb +14 -14
- data/spec/locales/th_spec.rb +2 -2
- data/spec/r18n_spec.rb +47 -49
- data/spec/spec_helper.rb +0 -7
- data/spec/translated_spec.rb +26 -28
- data/spec/translation_spec.rb +38 -40
- data/spec/yaml_loader_spec.rb +14 -16
- metadata +2 -2
data/spec/translation_spec.rb
CHANGED
@@ -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.
|
9
|
-
i18n.not.exists.
|
10
|
-
(i18n.not.exists | 'default').
|
11
|
-
i18n.not.exists.locale.
|
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.
|
14
|
-
i18n.not.exists.
|
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').
|
15
|
+
expect(i18n.in | 'default').to eq('default')
|
17
16
|
|
18
|
-
i18n.one.
|
19
|
-
(i18n.one | 'default').
|
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.
|
31
|
-
str.html_safe.
|
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.
|
37
|
-
i18n[:in][:another][:level].
|
38
|
-
i18n['in']['another']['level'].
|
39
|
-
i18n.only.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.
|
44
|
+
expect(i18n.in.another.level.path).to eq('in.another.level')
|
46
45
|
|
47
|
-
i18n.in.another.not.exists.path.
|
48
|
-
i18n.in.another.not.exists.untranslated_path.
|
49
|
-
i18n.in.another.not.exists.translated_path.
|
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.
|
52
|
-
i18n.not.translated_path.
|
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.
|
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.
|
63
|
-
i18n.two.locale.
|
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, '', :
|
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).
|
72
|
-
translation.count(5).
|
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.
|
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
|
-
:
|
84
|
+
locale: en, translations: { 'a' => 'A' })
|
86
85
|
|
87
|
-
translation.a.no_tr.
|
88
|
-
translation.a.no_tr.translated_path.
|
89
|
-
translation.a.no_tr.untranslated_path.
|
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
|
-
:
|
97
|
-
translation.inspect.
|
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
|
-
:
|
101
|
-
translation.inspect.
|
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.
|
103
|
+
expect(translation.inspect).to eq('Translation root for en {}')
|
105
104
|
end
|
106
|
-
|
107
105
|
end
|
data/spec/yaml_loader_spec.rb
CHANGED
@@ -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.
|
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.
|
23
|
-
@loader.
|
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.
|
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')).
|
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.
|
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.
|
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'].
|
54
|
-
translation['in']['two'].
|
55
|
-
translation['ext'].
|
56
|
-
translation['deep'].
|
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:
|
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
|
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.
|