fast_gettext 0.6.9 → 0.6.10

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fast_gettext (0.6.9)
4
+ fast_gettext (0.6.10)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -8,8 +8,10 @@ class TranslationKey < ActiveRecord::Base
8
8
 
9
9
  attr_accessible :key, :translations, :translations_attributes
10
10
 
11
+ before_save :normalize_newlines
12
+
11
13
  def self.translation(key, locale)
12
- return unless translation_key = find_by_key(key)
14
+ return unless translation_key = find_by_key(newline_normalize(key))
13
15
  return unless translation_text = translation_key.translations.find_by_locale(locale)
14
16
  translation_text.text
15
17
  end
@@ -17,4 +19,14 @@ class TranslationKey < ActiveRecord::Base
17
19
  def self.available_locales
18
20
  @@available_locales ||= TranslationText.count(:group=>:locale).keys.sort
19
21
  end
22
+
23
+ protected
24
+
25
+ def self.newline_normalize(s)
26
+ s.to_s.gsub("\r\n", "\n")
27
+ end
28
+
29
+ def normalize_newlines
30
+ self.key = self.class.newline_normalize(key)
31
+ end
20
32
  end
@@ -1,3 +1,3 @@
1
1
  module FastGettext
2
- VERSION = Version = '0.6.9'
2
+ VERSION = Version = '0.6.10'
3
3
  end
@@ -14,7 +14,7 @@ describe FastGettext::PoFile do
14
14
  end
15
15
 
16
16
  it "stores untranslated values as nil" do
17
- de['Car|Model'].should == "Modell"
17
+ de['Untranslated'].should == nil
18
18
  end
19
19
 
20
20
  it "finds pluralized values" do
@@ -70,6 +70,11 @@ describe FastGettext::TranslationRepository::Db do
70
70
  @rep.plural('Axis','Axis').should == ['Achse','Achsen']
71
71
  end
72
72
 
73
+ it "can ignore newline format" do
74
+ create_translation "good\r\nmorning", "guten\r\nMorgen"
75
+ @rep["good\nmorning"].should == "guten\r\nMorgen"
76
+ end
77
+
73
78
  it "removes texts when key is removed" do
74
79
  t = create_translation("a", "b")
75
80
  expect{
@@ -27,6 +27,14 @@ describe FastGettext::Translation do
27
27
  _('car').should == 'Auto'
28
28
  end
29
29
 
30
+ it "returns the original string if its translation is blank" do
31
+ _('Untranslated').should == 'Untranslated'
32
+ end
33
+
34
+ it "does not return the blank translation if a string's translation is blank" do
35
+ _('Untranslated').should_not == ''
36
+ end
37
+
30
38
  it "returns key if not translation was found" do
31
39
  _('NOT|FOUND').should == 'NOT|FOUND'
32
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_gettext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.9
4
+ version: 0.6.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-31 00:00:00.000000000 Z
12
+ date: 2012-09-18 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: michael@grosser.it
@@ -111,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  segments:
113
113
  - 0
114
- hash: 4402652659877715881
114
+ hash: -1278908847002659361
115
115
  required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  segments:
122
122
  - 0
123
- hash: 4402652659877715881
123
+ hash: -1278908847002659361
124
124
  requirements: []
125
125
  rubyforge_project:
126
126
  rubygems_version: 1.8.24