gettext_simple 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/gettext_simple.gemspec +2 -2
- data/lib/gettext_simple.rb +7 -2
- data/spec/gettext_simple_spec.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ed6fbc7bca7c1258f201185281fe61dfa4f36cb
|
4
|
+
data.tar.gz: 0e5742f5b5d689cfcb1149fd1f409dbdb61f0dd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2487e6d91da120c6ce28a6555cbe04aa528f14610092fd5cc46ea4ab87be583169653bdcb6eff9826ac68dc278dac4ab7437979938a5879747dfa46bbbc8f08f
|
7
|
+
data.tar.gz: 5b1d8f24802fccdb8694b2cede56f905a4d0f65b030fc42a2430e706355328fcdeb2a36703a0ed555ffe3e925444f866f9d8c3d230b51fdbe859906cfbc45684
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/gettext_simple.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "gettext_simple"
|
8
|
-
s.version = "0.0.
|
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-
|
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 = [
|
data/lib/gettext_simple.rb
CHANGED
@@ -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
|
|
data/spec/gettext_simple_spec.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2014-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|