fast_gettext 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.6
1
+ 0.5.7
data/fast_gettext.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fast_gettext}
8
- s.version = "0.5.6"
8
+ s.version = "0.5.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2010-06-12}
12
+ s.date = %q{2010-06-24}
13
13
  s.email = %q{grosser.michael@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "README.markdown"
@@ -56,6 +56,8 @@ module FastGettext
56
56
  end
57
57
 
58
58
 
59
+ # if overwritten by user( FastGettext.pluralisation_rule = xxx) use it,
60
+ # otherwise fall back to repo or to default lambda
59
61
  def pluralisation_rule
60
62
  Thread.current[:fast_gettext_pluralisation_rule] || current_repository.pluralisation_rule || lambda{|i| i!=1}
61
63
  end
@@ -49,5 +49,9 @@ module FastGettext
49
49
  def Nn_(*keys)
50
50
  keys
51
51
  end
52
+
53
+ def ns_(*args)
54
+ n_(*args).split(NAMESPACE_SEPERATOR).last
55
+ end
52
56
  end
53
57
  end
@@ -2,6 +2,7 @@ require 'spec/spec_helper'
2
2
 
3
3
  describe 'FastGettext::TranslationRepository::Yaml' do
4
4
  before do
5
+ FastGettext.pluralisation_rule = nil
5
6
  @rep = FastGettext::TranslationRepository.build('test', :path => File.join('spec', 'locale', 'yaml'), :type => :yaml)
6
7
  @rep.is_a?(FastGettext::TranslationRepository::Yaml).should be_true
7
8
  FastGettext.locale = 'de'
@@ -43,11 +44,11 @@ describe 'FastGettext::TranslationRepository::Yaml' do
43
44
  FastGettext.n_('cars.axis',1).should == 'Achse'
44
45
  end
45
46
 
46
- it "can be used to do wanky pluralisation rules" do
47
- FastGettext.stub!(:current_repository).and_return @rep
48
- 4.times do |i|
47
+ 4.times do |i|
48
+ it "can be used to do wanky pluralisation rules #{i}" do
49
+ FastGettext.stub!(:current_repository).and_return @rep
49
50
  @rep.stub!(:pluralisation_rule).and_return lambda{i}
50
- FastGettext.n_('cars.silly',1).should == i.to_s
51
+ FastGettext.n_('cars.silly',1).should == i.to_s # cars.silly translations are 0,1,2,3
51
52
  end
52
53
  end
53
54
 
@@ -101,6 +101,13 @@ describe FastGettext::Translation do
101
101
  end
102
102
  end
103
103
 
104
+ describe :ns_ do
105
+ it "translates whith namespace" do
106
+ ns_('Fruit|Apple','Fruit|Apples',2).should == 'Apples'
107
+ end
108
+ end
109
+
110
+
104
111
  describe :caching do
105
112
  describe :cache_hit do
106
113
  before do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 6
9
- version: 0.5.6
8
+ - 7
9
+ version: 0.5.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Grosser
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-12 00:00:00 +02:00
17
+ date: 2010-06-24 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies: []
20
20