grosser-fast_gettext 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/fast_gettext/translation.rb +10 -1
- data/spec/fast_gettext_spec.rb +16 -9
- metadata +1 -1
data/VERSION.yml
CHANGED
@@ -1,7 +1,16 @@
|
|
1
1
|
module FastGettext
|
2
2
|
module Translation
|
3
3
|
extend self
|
4
|
-
|
4
|
+
|
5
|
+
#make it usable in class definition, e.g.
|
6
|
+
# class Y
|
7
|
+
# include FastGettext::Translation
|
8
|
+
# @@x = _('y')
|
9
|
+
# end
|
10
|
+
def self.included(klas) #:nodoc:
|
11
|
+
klas.extend self
|
12
|
+
end
|
13
|
+
|
5
14
|
def _(translate)
|
6
15
|
FastGettext.current_translations[translate] || translate
|
7
16
|
end
|
data/spec/fast_gettext_spec.rb
CHANGED
@@ -5,6 +5,20 @@ FastGettext.text_domain = 'test'
|
|
5
5
|
FastGettext.available_locales = ['en','de']
|
6
6
|
FastGettext.locale = 'de'
|
7
7
|
|
8
|
+
class IncludeTest
|
9
|
+
include FastGettext::Translation
|
10
|
+
@@xx = _('car')
|
11
|
+
def self.ext
|
12
|
+
_('car')
|
13
|
+
end
|
14
|
+
def inc
|
15
|
+
_('car')
|
16
|
+
end
|
17
|
+
def self.xx
|
18
|
+
@@xx
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
8
22
|
include FastGettext
|
9
23
|
|
10
24
|
describe FastGettext do
|
@@ -17,16 +31,9 @@ describe FastGettext do
|
|
17
31
|
Nn_('X','Y').should == ['X','Y']
|
18
32
|
end
|
19
33
|
it "is extended to a class and included into a class" do
|
20
|
-
|
21
|
-
include FastGettext::Translation
|
22
|
-
def self.ext
|
23
|
-
_('car')
|
24
|
-
end
|
25
|
-
def inc
|
26
|
-
_('car')
|
27
|
-
end
|
28
|
-
end
|
34
|
+
IncludeTest.ext.should == 'Auto'
|
29
35
|
IncludeTest.ext.should == 'Auto'
|
30
36
|
IncludeTest.new.inc.should == 'Auto'
|
37
|
+
IncludeTest.xx.should == 'Auto'
|
31
38
|
end
|
32
39
|
end
|