r18n-core 0.2.3 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +157 -35
- data/base/cs.yml +34 -0
- data/base/de.yml +24 -0
- data/base/en.yml +24 -0
- data/base/fr.yml +24 -0
- data/base/pl.yml +24 -0
- data/base/ru.yml +30 -0
- data/lib/r18n-core/filters.rb +245 -0
- data/lib/r18n-core/i18n.rb +57 -40
- data/lib/r18n-core/locale.rb +116 -19
- data/lib/r18n-core/translated.rb +186 -0
- data/lib/r18n-core/translation.rb +33 -73
- data/lib/r18n-core/unsupported_locale.rb +27 -9
- data/lib/r18n-core/utils.rb +49 -0
- data/lib/r18n-core/version.rb +1 -1
- data/lib/r18n-core.rb +3 -15
- data/locales/cs.rb +23 -0
- data/locales/cs.yml +26 -0
- data/locales/de.yml +3 -8
- data/locales/en-us.rb +8 -0
- data/locales/en-us.yml +9 -0
- data/locales/en.rb +26 -0
- data/locales/en.yml +3 -8
- data/locales/eo.yml +3 -8
- data/locales/fr.rb +14 -0
- data/locales/fr.yml +3 -8
- data/locales/kk.yml +3 -8
- data/locales/pl.yml +4 -11
- data/locales/ru.yml +3 -8
- data/spec/filters_spec.rb +167 -0
- data/spec/i18n_spec.rb +61 -16
- data/spec/locale_spec.rb +46 -19
- data/spec/locales/cs_spec.rb +22 -0
- data/spec/locales/en-us_spec.rb +14 -0
- data/spec/locales/en_spec.rb +14 -0
- data/spec/locales/fr_spec.rb +10 -0
- data/spec/locales/pl_spec.rb +17 -17
- data/spec/locales/ru_spec.rb +2 -2
- data/spec/r18n_spec.rb +7 -3
- data/spec/spec_helper.rb +2 -0
- data/spec/translated_spec.rb +108 -0
- data/spec/translation_spec.rb +24 -56
- data/spec/translations/extension/{no_TR.yml → no-tr.yml} +0 -0
- data/spec/translations/general/en.yml +15 -2
- data/spec/translations/general/{no_LC.yml → no-lc.yml} +0 -0
- metadata +46 -31
- data/locales/en_US.yml +0 -14
data/spec/translation_spec.rb
CHANGED
@@ -2,46 +2,44 @@
|
|
2
2
|
require File.join(File.dirname(__FILE__), 'spec_helper')
|
3
3
|
|
4
4
|
describe R18n::Translation do
|
5
|
+
before :all do
|
6
|
+
@en = R18n::Locale.load('en')
|
7
|
+
@ru = R18n::Locale.load('ru')
|
8
|
+
end
|
5
9
|
|
6
10
|
it "should return all available translations" do
|
7
|
-
R18n::Translation.available(DIR).
|
8
|
-
R18n::Translation.available([TWO, DIR]).
|
9
|
-
'en', 'fr', '
|
11
|
+
R18n::Translation.available(DIR).should =~ ['en', 'no-lc', 'ru']
|
12
|
+
R18n::Translation.available([TWO, DIR]).should =~ [
|
13
|
+
'en', 'fr', 'no-lc', 'ru']
|
10
14
|
end
|
11
15
|
|
12
16
|
it "should load translations" do
|
13
|
-
translation = R18n::Translation.load(
|
17
|
+
translation = R18n::Translation.load([@en], DIR)
|
14
18
|
translation.one.should == 'One'
|
15
19
|
translation['one'].should == 'One'
|
16
20
|
end
|
17
21
|
|
18
22
|
it "should find in subtranslations" do
|
19
|
-
translation = R18n::Translation.load([
|
23
|
+
translation = R18n::Translation.load([@ru, @en], DIR)
|
20
24
|
translation.one.should == 'Один'
|
21
25
|
translation.two.should == 'Two'
|
22
26
|
end
|
23
27
|
|
24
28
|
it "should return nil if translation isn't found" do
|
25
|
-
translation = R18n::Translation.load(
|
29
|
+
translation = R18n::Translation.load([@en], DIR)
|
26
30
|
translation.not.exists.should be_nil
|
27
31
|
translation['not']['exists'].should be_nil
|
28
32
|
end
|
29
33
|
|
30
|
-
it "should can use params in translation" do
|
31
|
-
translation = R18n::Translation.load('en', DIR)
|
32
|
-
translation.params(1, 2).should == 'Is 1 between 1 and 2?'
|
33
|
-
translation['params', 1, 2].should == 'Is 1 between 1 and 2?'
|
34
|
-
end
|
35
|
-
|
36
34
|
it "should load use hierarchical translations" do
|
37
|
-
translation = R18n::Translation.load([
|
35
|
+
translation = R18n::Translation.load([@ru, @en], DIR)
|
38
36
|
translation.in.another.level.should == 'Иерархический'
|
39
37
|
translation['in']['another']['level'].should == 'Иерархический'
|
40
38
|
translation.only.english.should == 'Only in English'
|
41
39
|
end
|
42
40
|
|
43
41
|
it "should save path for translation" do
|
44
|
-
translation = R18n::Translation.load(
|
42
|
+
translation = R18n::Translation.load([@en], DIR)
|
45
43
|
|
46
44
|
translation.in.another.level.path.should == 'in.another.level'
|
47
45
|
|
@@ -54,21 +52,21 @@ describe R18n::Translation do
|
|
54
52
|
end
|
55
53
|
|
56
54
|
it "should return string with locale info" do
|
57
|
-
translation = R18n::Translation.load(['
|
58
|
-
translation.one.locale.should == R18n::UnsupportedLocale.new('
|
55
|
+
translation = R18n::Translation.load([R18n::Locale.load('no-LC'), @en], DIR)
|
56
|
+
translation.one.locale.should == R18n::UnsupportedLocale.new('no-LC')
|
59
57
|
translation.two.locale.should == R18n::Locale.load('en')
|
60
58
|
end
|
61
59
|
|
62
60
|
it "should load translations from several dirs" do
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
tr = R18n::Translation.load([R18n::Locale.load('no-LC'), @en], [TWO, DIR])
|
62
|
+
tr.in.two.should == 'Two'
|
63
|
+
tr.in.another.level.should == 'Hierarchical'
|
66
64
|
end
|
67
65
|
|
68
66
|
it "should use extension translations" do
|
69
67
|
R18n::Translation.extension_translations << EXT
|
70
68
|
|
71
|
-
translation = R18n::Translation.load(
|
69
|
+
translation = R18n::Translation.load([@en], DIR)
|
72
70
|
translation.ext.should == 'Extension'
|
73
71
|
translation.one.should == 'One'
|
74
72
|
end
|
@@ -76,46 +74,16 @@ describe R18n::Translation do
|
|
76
74
|
it "shouldn't use extension without app translations with same locale" do
|
77
75
|
R18n::Translation.extension_translations << EXT
|
78
76
|
|
79
|
-
translation = R18n::Translation.load(['
|
77
|
+
translation = R18n::Translation.load([R18n::Locale.load('no-TR'), @en], DIR)
|
80
78
|
translation.ext.should == 'Extension'
|
81
79
|
end
|
82
|
-
|
83
|
-
it "should call proc in translation" do
|
84
|
-
translation = R18n::Translation.load('en', DIR)
|
85
|
-
translation.sum(2, 3).should == 5
|
86
|
-
end
|
87
80
|
|
88
|
-
it "
|
89
|
-
translation = R18n::Translation.load('
|
90
|
-
|
91
|
-
R18n::Translation.call_proc.should be_false
|
92
|
-
translation.sum(2, 3).should == '|x, y| x + y'
|
93
|
-
R18n::Translation.call_proc = true
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should pluralize translation" do
|
97
|
-
translation = R18n::Translation.load('en', DIR)
|
98
|
-
translation.comments(0, 'article').should == 'no comments for article'
|
99
|
-
translation.comments(1, 'article').should == 'one comment for article'
|
100
|
-
translation.comments(5, 'article').should == '5 comments for article'
|
101
|
-
|
102
|
-
translation.files(0).should == '0 files'
|
103
|
-
translation.files(-5.5).should == '−5.5 files'
|
104
|
-
translation.files(5000).should == '5,000 files'
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should return unknown YAML type" do
|
108
|
-
translation = R18n::Translation.load('en', DIR)
|
81
|
+
it "should ignore case on loading" do
|
82
|
+
translation = R18n::Translation.load([R18n::Locale.load('no-lc')], [DIR])
|
83
|
+
translation.one.should == 'ONE'
|
109
84
|
|
110
|
-
translation.
|
111
|
-
translation.
|
112
|
-
translation.my_type.value.should == {'attr' => 'value'}
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should pluralize translation without locale" do
|
116
|
-
translation = R18n::Translation.load('no_LC', DIR)
|
117
|
-
translation.entries(1).should == 'ONE'
|
118
|
-
translation.entries(5).should == 'N'
|
85
|
+
translation = R18n::Translation.load([R18n::Locale.load('no-LC')], [DIR])
|
86
|
+
translation.one.should == 'ONE'
|
119
87
|
end
|
120
88
|
|
121
89
|
end
|
File without changes
|
@@ -21,5 +21,18 @@ files: !!pl
|
|
21
21
|
1: 1 file
|
22
22
|
n: %1 files
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
my_filter: !!my value
|
25
|
+
my_tree_filter: !!my
|
26
|
+
name: value
|
27
|
+
|
28
|
+
unknown_filter: !!unknown value
|
29
|
+
|
30
|
+
html: !!escape
|
31
|
+
<script>true && false</script>
|
32
|
+
greater: 1 < 2 is true
|
33
|
+
no_escape: !!html
|
34
|
+
<b>Warning</b>
|
35
|
+
|
36
|
+
markdown: !!markdown **Hi!**
|
37
|
+
|
38
|
+
textile: !!textile _Hi!_
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: r18n-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: "0.3"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey "A.I." Sitnik
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-26 00:00:00 +04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description: R18n is a i18n tool to translate your Ruby application. It can format numbers and time to the rules of the user locale, has translation for common words, storage translation in YAML format with pluralization and
|
16
|
+
description: R18n is a i18n tool to translate your Ruby application. It can format numbers and time to the rules of the user locale, has translation for common words, storage translation in YAML format with pluralization, procedures and user filters and has special support for countries with two official languages.
|
17
17
|
email: andrey@sitnik.ru
|
18
18
|
executables: []
|
19
19
|
|
@@ -23,32 +23,41 @@ extra_rdoc_files:
|
|
23
23
|
- README.rdoc
|
24
24
|
- LICENSE
|
25
25
|
files:
|
26
|
-
- base/
|
27
|
-
- base/
|
26
|
+
- base/ru.yml
|
27
|
+
- base/kk.yml
|
28
28
|
- base/fr.yml
|
29
|
+
- base/en.yml
|
29
30
|
- base/pl.yml
|
30
|
-
- base/
|
31
|
+
- base/de.yml
|
32
|
+
- base/cs.yml
|
31
33
|
- base/eo.yml
|
32
|
-
- base/kk.yml
|
33
|
-
- lib/r18n-core.rb
|
34
34
|
- lib/r18n-core
|
35
|
-
- lib/r18n-core/unsupported_locale.rb
|
36
|
-
- lib/r18n-core/translation.rb
|
37
35
|
- lib/r18n-core/untranslated.rb
|
36
|
+
- lib/r18n-core/translated.rb
|
38
37
|
- lib/r18n-core/i18n.rb
|
39
|
-
- lib/r18n-core/translated_string.rb
|
40
38
|
- lib/r18n-core/locale.rb
|
39
|
+
- lib/r18n-core/utils.rb
|
41
40
|
- lib/r18n-core/version.rb
|
42
|
-
-
|
43
|
-
-
|
41
|
+
- lib/r18n-core/translation.rb
|
42
|
+
- lib/r18n-core/translated_string.rb
|
43
|
+
- lib/r18n-core/filters.rb
|
44
|
+
- lib/r18n-core/unsupported_locale.rb
|
45
|
+
- lib/r18n-core.rb
|
44
46
|
- locales/ru.rb
|
45
|
-
- locales/
|
47
|
+
- locales/ru.yml
|
48
|
+
- locales/en.rb
|
49
|
+
- locales/kk.yml
|
46
50
|
- locales/fr.yml
|
51
|
+
- locales/en.yml
|
47
52
|
- locales/pl.yml
|
48
|
-
- locales/
|
49
|
-
- locales/
|
53
|
+
- locales/de.yml
|
54
|
+
- locales/cs.yml
|
55
|
+
- locales/fr.rb
|
56
|
+
- locales/cs.rb
|
50
57
|
- locales/eo.yml
|
51
|
-
- locales/
|
58
|
+
- locales/en-us.rb
|
59
|
+
- locales/en-us.yml
|
60
|
+
- locales/pl.rb
|
52
61
|
- LICENSE
|
53
62
|
- README.rdoc
|
54
63
|
has_rdoc: true
|
@@ -78,22 +87,28 @@ signing_key:
|
|
78
87
|
specification_version: 2
|
79
88
|
summary: I18n tool to translate your Ruby application.
|
80
89
|
test_files:
|
81
|
-
- spec/translations
|
82
|
-
- spec/translations/extension
|
83
|
-
- spec/translations/extension/no_TR.yml
|
84
|
-
- spec/translations/extension/en.yml
|
85
|
-
- spec/translations/general
|
86
|
-
- spec/translations/general/en.yml
|
87
|
-
- spec/translations/general/no_LC.yml
|
88
|
-
- spec/translations/general/ru.yml
|
89
|
-
- spec/translations/two
|
90
|
-
- spec/translations/two/en.yml
|
91
|
-
- spec/translations/two/fr.yml
|
92
90
|
- spec/locales
|
91
|
+
- spec/locales/en_spec.rb
|
93
92
|
- spec/locales/pl_spec.rb
|
93
|
+
- spec/locales/cs_spec.rb
|
94
|
+
- spec/locales/en-us_spec.rb
|
95
|
+
- spec/locales/fr_spec.rb
|
94
96
|
- spec/locales/ru_spec.rb
|
95
|
-
- spec/locale_spec.rb
|
96
|
-
- spec/i18n_spec.rb
|
97
|
-
- spec/r18n_spec.rb
|
98
97
|
- spec/spec_helper.rb
|
98
|
+
- spec/translations
|
99
|
+
- spec/translations/two
|
100
|
+
- spec/translations/two/fr.yml
|
101
|
+
- spec/translations/two/en.yml
|
102
|
+
- spec/translations/general
|
103
|
+
- spec/translations/general/ru.yml
|
104
|
+
- spec/translations/general/en.yml
|
105
|
+
- spec/translations/general/no-lc.yml
|
106
|
+
- spec/translations/extension
|
107
|
+
- spec/translations/extension/no-tr.yml
|
108
|
+
- spec/translations/extension/en.yml
|
99
109
|
- spec/translation_spec.rb
|
110
|
+
- spec/r18n_spec.rb
|
111
|
+
- spec/filters_spec.rb
|
112
|
+
- spec/locale_spec.rb
|
113
|
+
- spec/i18n_spec.rb
|
114
|
+
- spec/translated_spec.rb
|
data/locales/en_US.yml
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
include: en
|
2
|
-
|
3
|
-
code: en_US
|
4
|
-
title: English (US)
|
5
|
-
sublocales: [en]
|
6
|
-
|
7
|
-
formats:
|
8
|
-
time: "%H:%M"
|
9
|
-
date: "%m/%d/%Y"
|
10
|
-
short_date: "%b %d"
|
11
|
-
long_date: "%B %d, %Y"
|
12
|
-
datetime: "%a %b %d %H:%M:%S %Z %Y"
|
13
|
-
short_datetime: "%b %d %H:%M"
|
14
|
-
long_datetime: "%B %d, %Y %H:%M"
|