get_pomo 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/get_pomo/po_file.rb +1 -1
- data/lib/get_pomo/version.rb +1 -1
- data/vendor/iconv.rb +2 -1
- data/vendor/mofile.rb +58 -29
- 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: 10ce7fafc6ac3513491f6cc7966a018a6418b890
|
4
|
+
data.tar.gz: 718ce80076413a166985cd2cb2bfa41420425c32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 811c853026cbf5a06edc89cc204f275b7380afc7a7946a70dc69afe94c31c1fb2b3ec8eb46ef2e8999f49433675012cd44391f19821166595dcfc8ccfb6f681e
|
7
|
+
data.tar.gz: 681fc7e7d3407e1127a5043a2488aa55c070f4d12a7ca60c382996f214a25d531cb4f4c655a02f2b3f017a6420e55abd9f5d2ee585045cef987857e7f179d97e
|
data/lib/get_pomo/po_file.rb
CHANGED
@@ -33,7 +33,7 @@ module GetPomo
|
|
33
33
|
default_options = {:parse_obsoletes => false}
|
34
34
|
@options.merge!(default_options.merge(options))
|
35
35
|
start_new_translation
|
36
|
-
text.
|
36
|
+
text.sub!(/^#{"\357\273\277"}/, "") #remove bom (utf8 byte order mark)
|
37
37
|
text.split(/$/).each_with_index do |line,index|
|
38
38
|
@line_number = index + 1
|
39
39
|
next if line.empty?
|
data/lib/get_pomo/version.rb
CHANGED
data/vendor/iconv.rb
CHANGED
@@ -20,6 +20,7 @@
|
|
20
20
|
|
21
21
|
begin
|
22
22
|
require 'iconv'
|
23
|
+
GetPomo::Iconv = Iconv
|
23
24
|
rescue LoadError
|
24
25
|
# Provides Iconv.iconv which normally is provided through Ruby/GLib(1) functions.
|
25
26
|
# This library is required for 'gettext'.
|
@@ -34,7 +35,7 @@ rescue LoadError
|
|
34
35
|
# You can get binaries for Win32(One-Click Ruby Installer).
|
35
36
|
# <URL: http://ruby-gnome2.sourceforge.jp/>
|
36
37
|
module GetPomo
|
37
|
-
class
|
38
|
+
class Iconv
|
38
39
|
module Failure; end
|
39
40
|
class InvalidEncoding < ArgumentError; include Failure; end
|
40
41
|
class IllegalSequence < ArgumentError; include Failure; end
|
data/vendor/mofile.rb
CHANGED
@@ -15,12 +15,8 @@
|
|
15
15
|
$Id: mo.rb,v 1.10 2008/06/17 16:40:52 mutoh Exp $
|
16
16
|
=end
|
17
17
|
|
18
|
-
require File.join(File.dirname(__FILE__),'iconv')
|
19
18
|
require 'stringio'
|
20
19
|
|
21
|
-
#Modifications:
|
22
|
-
# use Iconv or FastGettext::Icvon
|
23
|
-
|
24
20
|
module GetPomo
|
25
21
|
module GetText
|
26
22
|
class MOFile < Hash
|
@@ -46,8 +42,12 @@ module GetPomo
|
|
46
42
|
:trans_sysdep_tab_offset
|
47
43
|
end
|
48
44
|
|
49
|
-
MAGIC_BIG_ENDIAN
|
45
|
+
MAGIC_BIG_ENDIAN = "\x95\x04\x12\xde"
|
50
46
|
MAGIC_LITTLE_ENDIAN = "\xde\x12\x04\x95"
|
47
|
+
if "".respond_to?(:force_encoding)
|
48
|
+
MAGIC_BIG_ENDIAN.force_encoding("ASCII-8BIT")
|
49
|
+
MAGIC_LITTLE_ENDIAN.force_encoding("ASCII-8BIT")
|
50
|
+
end
|
51
51
|
|
52
52
|
def self.open(arg = nil, output_charset = nil)
|
53
53
|
result = self.new(output_charset)
|
@@ -149,18 +149,9 @@ module GetPomo
|
|
149
149
|
@plural = "0" unless @plural
|
150
150
|
end
|
151
151
|
else
|
152
|
-
if @output_charset
|
153
|
-
|
154
|
-
|
155
|
-
str = iconv.conv(@output_charset, @charset, str) if @charset
|
156
|
-
rescue iconv::Failure
|
157
|
-
if $DEBUG
|
158
|
-
warn "@charset = ", @charset
|
159
|
-
warn"@output_charset = ", @output_charset
|
160
|
-
warn "msgid = ", original_strings[i]
|
161
|
-
warn "msgstr = ", str
|
162
|
-
end
|
163
|
-
end
|
152
|
+
if @charset and @output_charset
|
153
|
+
str = convert_encoding(str, original_strings[i])
|
154
|
+
original_strings[i] = convert_encoding(original_strings[i], original_strings[i])
|
164
155
|
end
|
165
156
|
end
|
166
157
|
self[original_strings[i]] = str.freeze
|
@@ -168,21 +159,26 @@ module GetPomo
|
|
168
159
|
self
|
169
160
|
end
|
170
161
|
|
162
|
+
|
163
|
+
|
171
164
|
# Is this number a prime number ?
|
172
165
|
# http://apidock.com/ruby/Prime
|
173
166
|
def prime?(number)
|
174
167
|
('1' * number) !~ /^1?$|^(11+?)\1+$/
|
175
168
|
end
|
176
169
|
|
177
|
-
|
178
|
-
require '
|
179
|
-
|
180
|
-
Prime
|
181
|
-
else
|
182
|
-
Prime.new
|
170
|
+
begin
|
171
|
+
require 'prime'
|
172
|
+
def next_prime(seed)
|
173
|
+
Prime.instance.find{|x| x > seed }
|
183
174
|
end
|
184
|
-
|
185
|
-
|
175
|
+
rescue LoadError
|
176
|
+
def next_prime(seed)
|
177
|
+
require 'mathn'
|
178
|
+
prime = Prime.new
|
179
|
+
while current = prime.succ
|
180
|
+
return current if current > seed
|
181
|
+
end
|
186
182
|
end
|
187
183
|
end
|
188
184
|
|
@@ -232,17 +228,17 @@ module GetPomo
|
|
232
228
|
|
233
229
|
orig_table_data = Array.new()
|
234
230
|
ary.each{|item, _|
|
235
|
-
orig_table_data.push(item.
|
231
|
+
orig_table_data.push(item.bytesize)
|
236
232
|
orig_table_data.push(pos)
|
237
|
-
pos += item.
|
233
|
+
pos += item.bytesize + 1 # +1 is <NUL>
|
238
234
|
}
|
239
235
|
io.write(orig_table_data.pack('V*'))
|
240
236
|
|
241
237
|
trans_table_data = Array.new()
|
242
238
|
ary.each{|_, item|
|
243
|
-
trans_table_data.push(item.
|
239
|
+
trans_table_data.push(item.bytesize)
|
244
240
|
trans_table_data.push(pos)
|
245
|
-
pos += item.
|
241
|
+
pos += item.bytesize + 1 # +1 is <NUL>
|
246
242
|
}
|
247
243
|
io.write(trans_table_data.pack('V*'))
|
248
244
|
|
@@ -295,6 +291,39 @@ module GetPomo
|
|
295
291
|
|
296
292
|
attr_accessor :little_endian, :path, :last_modified
|
297
293
|
attr_reader :charset, :nplurals, :plural
|
294
|
+
|
295
|
+
private
|
296
|
+
if "".respond_to?(:encode)
|
297
|
+
def convert_encoding(string, original_string)
|
298
|
+
begin
|
299
|
+
string.encode(@output_charset, @charset)
|
300
|
+
rescue EncodingError
|
301
|
+
if $DEBUG
|
302
|
+
warn "@charset = ", @charset
|
303
|
+
warn "@output_charset = ", @output_charset
|
304
|
+
warn "msgid = ", original_string
|
305
|
+
warn "msgstr = ", string
|
306
|
+
end
|
307
|
+
string
|
308
|
+
end
|
309
|
+
end
|
310
|
+
else
|
311
|
+
|
312
|
+
require File.expand_path('iconv.rb', File.dirname(__FILE__))
|
313
|
+
def convert_encoding(string, original_string)
|
314
|
+
begin
|
315
|
+
|
316
|
+
str = GetPomo::Iconv.conv(@output_charset, @charset, string)
|
317
|
+
rescue GetPomo::Iconv::Failure
|
318
|
+
if $DEBUG
|
319
|
+
warn "@charset = ", @charset
|
320
|
+
warn "@output_charset = ", @output_charset
|
321
|
+
warn "msgid = ", original_string
|
322
|
+
warn "msgstr = ", str
|
323
|
+
end
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end
|
298
327
|
end
|
299
328
|
end
|
300
329
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: get_pomo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: michael@grosser.it
|