gettext_simple 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c175117d02717c98b5d0e0ca0cc2209e55454bdb
4
- data.tar.gz: 779101b352b8f53452f39fbb3fa75f06b2e516d1
3
+ metadata.gz: 5ed6fbc7bca7c1258f201185281fe61dfa4f36cb
4
+ data.tar.gz: 0e5742f5b5d689cfcb1149fd1f409dbdb61f0dd6
5
5
  SHA512:
6
- metadata.gz: 717e09c91b277baa776384d4e1edbbb57f2167b93f58b7a300aa8f8515c736a8d695d907efc35ecf05b9d66b4afdc7a4bbd404d67a0e618b66da5cb256d1d98e
7
- data.tar.gz: 34d877e509a0f9d443a70f74f6b0d59fcfec2052038e1d75cec6ab5930b81c10a2ac099bea49f36fb8eba0148de305634cac7012122a57147113f421ea27bfe2
6
+ metadata.gz: 2487e6d91da120c6ce28a6555cbe04aa528f14610092fd5cc46ea4ab87be583169653bdcb6eff9826ac68dc278dac4ab7437979938a5879747dfa46bbbc8f08f
7
+ data.tar.gz: 5b1d8f24802fccdb8694b2cede56f905a4d0f65b030fc42a2430e706355328fcdeb2a36703a0ed555ffe3e925444f866f9d8c3d230b51fdbe859906cfbc45684
data/Gemfile.lock CHANGED
@@ -45,7 +45,7 @@ GEM
45
45
  multi_xml (~> 0.5)
46
46
  rack (~> 1.2)
47
47
  rack (1.5.2)
48
- rake (10.2.2)
48
+ rake (10.3.1)
49
49
  rdoc (3.12.2)
50
50
  json (~> 1.4)
51
51
  rspec (2.8.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gettext_simple"
8
- s.version = "0.0.7"
8
+ s.version = "0.0.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kasper Johansen"]
12
- s.date = "2014-04-11"
12
+ s.date = "2014-05-09"
13
13
  s.description = "A very simple version of Gettext reading .po files directly."
14
14
  s.email = "k@spernj.org"
15
15
  s.extra_rdoc_files = [
@@ -123,6 +123,8 @@ private
123
123
  reading_id = false
124
124
  reading_translation = false
125
125
 
126
+ fuzzy = false
127
+
126
128
  debug "Opening file for parsing: '#{filepath}' in locale '#{locale}'." if @debug
127
129
  File.open(filepath, "r", :encoding => @args[:encoding]) do |fp|
128
130
  fp.each_line do |line|
@@ -149,11 +151,14 @@ private
149
151
  if reading_id
150
152
  reading_id = false
151
153
  elsif reading_translation
152
- add_translation(locale, current_id, current_translation)
154
+ add_translation(locale, current_id, current_translation) unless fuzzy
153
155
  reading_translation = false
154
156
  current_id = nil
155
157
  current_translation = nil
158
+ fuzzy = false
156
159
  end
160
+ elsif line.match(/^#, fuzzy$/)
161
+ fuzzy = true
157
162
  elsif line.start_with?("#")
158
163
  # Line is a comment - ignore.
159
164
  else
@@ -161,7 +166,7 @@ private
161
166
  end
162
167
  end
163
168
 
164
- add_translation(locale, current_id, current_translation) if reading_translation
169
+ add_translation(locale, current_id, current_translation) if reading_translation && !fuzzy
165
170
  end
166
171
  end
167
172
 
@@ -23,6 +23,11 @@ describe "GettextSimple" do
23
23
  fp.puts "msgid \"empty translation\"\n"
24
24
  fp.puts "msgstr \"\"\n"
25
25
  fp.puts "\n"
26
+
27
+ fp.puts "#, fuzzy"
28
+ fp.puts "msgid \"fuzzy translation\"\n"
29
+ fp.puts "msgstr \"tralalala\"\n"
30
+ fp.puts "\n"
26
31
  end
27
32
 
28
33
  @gs = GettextSimple.new
@@ -73,4 +78,8 @@ describe "GettextSimple" do
73
78
  @gs.translate(1, :name => "kasper")
74
79
  @gs.translate("hejsa", :name => 5)
75
80
  end
81
+
82
+ it "should not read fuzzy translations" do
83
+ @gs.translate_with_locale("da", "fuzzy translation").should eq "fuzzy translation"
84
+ end
76
85
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gettext_simple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Johansen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-11 00:00:00.000000000 Z
11
+ date: 2014-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec