PoParser 1.0.3 → 1.1.0
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/CHANGELOG.md +39 -23
- data/Gemfile +1 -1
- data/README.md +4 -4
- data/lib/poparser/constants.rb +1 -1
- data/lib/poparser/entry.rb +5 -0
- data/lib/poparser/header.rb +5 -0
- data/lib/poparser/parser.rb +4 -5
- data/lib/poparser/po.rb +1 -1
- data/lib/poparser/version.rb +1 -1
- data/spec/poparser/entry_spec.rb +1 -1
- data/spec/poparser/parser_spec.rb +11 -8
- data/spec/poparser/po_spec.rb +1 -1
- data/spec/poparser/tokenizer_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -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: 954ba00cb0682d03951ff75fc7de053d515a621b
|
4
|
+
data.tar.gz: 40d00d176527e9c4ff109cd44dd3c46c16674a42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b1635f9d67863a2ffe25c0051b3d772d3ae595f8600fe190d152524441a4f44354b1b95929ca2b47ea46526bb80a52646919796c67610d822bdc85261bf6ffe
|
7
|
+
data.tar.gz: 1bfa4f0d0d4df93cba148577e3b803113c627758c26e1cee69de0f823d8fbf0b82dfdd912ce7c98c7b9866dbc08a1cc6a2768f2fc4e685e7415b7aafd2d6362f
|
data/CHANGELOG.md
CHANGED
@@ -1,38 +1,54 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
1.1.0 / 2016-12-07
|
2
|
+
==================
|
3
3
|
|
4
|
-
|
5
|
-
*
|
6
|
-
*
|
7
|
-
*
|
4
|
+
* fixed typo refrence, but kept it backwards compatible for entries
|
5
|
+
* [Header] skip empty header fields from to_s output with a warning
|
6
|
+
* [Parser] Allow multiple space after msgs and text
|
7
|
+
* added alias methods for entry accessors
|
8
8
|
|
9
|
-
|
9
|
+
Version 1.0.3
|
10
|
+
=============
|
10
11
|
|
11
|
-
*
|
12
|
+
* Add `obsolete` alias for `cached` entries. Now you can use `Po#obsolete` or `Entry#obsolete?`
|
12
13
|
|
13
|
-
|
14
|
+
Version 1.0.2
|
15
|
+
=============
|
14
16
|
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
* `po.add` now raises error if you try to add an unknown label
|
17
|
+
* Update dependencies
|
18
|
+
* Handle empty lines in .po file (thanks to @roland9)
|
19
|
+
* Fix translated strings stats
|
19
20
|
|
20
|
-
|
21
|
+
Version 1.0.1
|
22
|
+
=============
|
21
23
|
|
22
|
-
*
|
24
|
+
* Update dependencies and tests
|
23
25
|
|
24
|
-
|
26
|
+
Version 1.0.0
|
27
|
+
=============
|
25
28
|
|
26
|
-
*
|
29
|
+
* add support for header entry
|
30
|
+
* `add_entry` renamed to `add` and returns `self`
|
31
|
+
* besides percentages, inspect of `po` now returns each entry count too
|
32
|
+
* `po.add` now raises error if you try to add an unknown label
|
27
33
|
|
28
|
-
|
34
|
+
Version 0.2.1
|
35
|
+
=============
|
29
36
|
|
30
|
-
|
37
|
+
* Add search_in method.
|
31
38
|
|
32
|
-
|
33
|
-
|
39
|
+
Version 0.2.0
|
40
|
+
=============
|
34
41
|
|
35
|
-
|
42
|
+
* Some entries in PO files are started with "#~", these entries are just kept by program for later use and are not counted as active entries. `PoParser` now supports them. We won't count them in stats or show them in Tanslated or Untranslated entries. They're just there.
|
43
|
+
* Added size/length methods to `PO` class. It won't count cached entries(described above).
|
36
44
|
|
37
|
-
|
45
|
+
Version 0.1.1
|
46
|
+
=============
|
38
47
|
|
48
|
+
* Fix bug of "str" and "to_str" on Messages
|
49
|
+
* Small refactoring
|
50
|
+
|
51
|
+
Version 0.1.0
|
52
|
+
=============
|
53
|
+
|
54
|
+
* initial release
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -66,7 +66,7 @@ You can add a new entry to the PO file:
|
|
66
66
|
```ruby
|
67
67
|
new_entry = {
|
68
68
|
translator_comment: 'comment',
|
69
|
-
|
69
|
+
reference: 'reference comment',
|
70
70
|
msgid: 'untranslated',
|
71
71
|
msgstr: 'translated string'
|
72
72
|
}
|
@@ -84,7 +84,7 @@ Adding plural string is the same:
|
|
84
84
|
```ruby
|
85
85
|
new_entry = {
|
86
86
|
translator_comment: 'comment',
|
87
|
-
|
87
|
+
reference: 'reference comment',
|
88
88
|
msgid_plural: 'untranslated',
|
89
89
|
'msgstr[0]': 'translated string',
|
90
90
|
'msgstr[1]': 'translated string'
|
@@ -100,11 +100,11 @@ Each entry can have following properties (for more information see [GNU PO file
|
|
100
100
|
|
101
101
|
```
|
102
102
|
translator_comment
|
103
|
-
|
103
|
+
reference
|
104
104
|
extracted_comment
|
105
105
|
flag
|
106
106
|
previous_untraslated_string
|
107
|
-
cached
|
107
|
+
cached # obsolete entries
|
108
108
|
msgid
|
109
109
|
msgid_plural
|
110
110
|
msgstr
|
data/lib/poparser/constants.rb
CHANGED
data/lib/poparser/entry.rb
CHANGED
@@ -18,6 +18,11 @@ module PoParser
|
|
18
18
|
define_reader_methods
|
19
19
|
|
20
20
|
self.class.send(:alias_method, :translate, :msgstr=)
|
21
|
+
self.class.send(:alias_method, :obsolete, :cached)
|
22
|
+
self.class.send(:alias_method, :obsolete=, :cached=)
|
23
|
+
# alias for backward compatibility of this typo
|
24
|
+
self.class.send(:alias_method, :refrence, :reference)
|
25
|
+
self.class.send(:alias_method, :refrence=, :reference)
|
21
26
|
end
|
22
27
|
|
23
28
|
# If entry doesn't have any msgid, it's probably a cached entry that is
|
data/lib/poparser/header.rb
CHANGED
@@ -34,6 +34,11 @@ module PoParser
|
|
34
34
|
end
|
35
35
|
string << "msgid \"\"\nmsgstr \"\""
|
36
36
|
configs.each do |k, v|
|
37
|
+
if v.nil? || v.empty?
|
38
|
+
puts "WARNING: \"#{k}\" header field is empty and skipped"
|
39
|
+
next
|
40
|
+
end
|
41
|
+
|
37
42
|
string << "#{k}: #{v}\n".dump
|
38
43
|
end
|
39
44
|
string.join("\n")
|
data/lib/poparser/parser.rb
CHANGED
@@ -7,7 +7,7 @@ module PoParser
|
|
7
7
|
|
8
8
|
# Comments
|
9
9
|
rule(:comments) do
|
10
|
-
|
10
|
+
reference |
|
11
11
|
extracted_comment | flag |
|
12
12
|
previous_untraslated_string |
|
13
13
|
cached |
|
@@ -16,14 +16,14 @@ module PoParser
|
|
16
16
|
|
17
17
|
rule(:translator_comment) { spaced('#') >> comment_text_line.as(:translator_comment) }
|
18
18
|
rule(:extracted_comment) { spaced('#.') >> comment_text_line.as(:extracted_comment) }
|
19
|
-
rule(:
|
19
|
+
rule(:reference) { spaced('#:') >> comment_text_line.as(:reference) }
|
20
20
|
rule(:flag) { spaced('#,') >> comment_text_line.as(:flag) }
|
21
21
|
rule(:previous_untraslated_string){ spaced('#|') >> comment_text_line.as(:previous_untraslated_string) }
|
22
22
|
rule(:cached) { spaced('#~') >> comment_text_line.as(:cached) }
|
23
23
|
|
24
24
|
# Entries
|
25
25
|
rule(:entries) do
|
26
|
-
msgid.as(:msgid) |
|
26
|
+
msgid.as(:msgid) |
|
27
27
|
msgid_plural.as(:msgid_plural) |
|
28
28
|
msgstr.as(:msgstr) |
|
29
29
|
msgstr_plural.as(:msgstr_plural) |
|
@@ -39,7 +39,7 @@ module PoParser
|
|
39
39
|
rule(:msgctxt) { spaced('msgctxt') >> msg_text_line >> multiline.repeat }
|
40
40
|
|
41
41
|
# Helpers
|
42
|
-
rule(:space) { match['
|
42
|
+
rule(:space) { match['\p{Blank}'].repeat } #match only whitespace and not newline
|
43
43
|
rule(:space?) { space.maybe }
|
44
44
|
rule(:newline) { match["\n"] }
|
45
45
|
rule(:eol) { newline | any.absent? }
|
@@ -65,4 +65,3 @@ module PoParser
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
68
|
-
|
data/lib/poparser/po.rb
CHANGED
data/lib/poparser/version.rb
CHANGED
data/spec/poparser/entry_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe PoParser::Entry do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
let(:labels) do
|
11
|
-
[:refrence, :extracted_comment, :flag, :previous_untraslated_string,
|
11
|
+
[:reference, :refrence, :extracted_comment, :flag, :previous_untraslated_string,
|
12
12
|
:translator_comment, :msgid, :msgid_plural, :msgstr, :msgctxt]
|
13
13
|
end
|
14
14
|
|
@@ -1,13 +1,12 @@
|
|
1
|
-
#encoding: utf-8
|
2
|
-
require
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
3
|
|
4
4
|
describe PoParser::Parser do
|
5
5
|
let(:po) { PoParser::Parser.new }
|
6
6
|
|
7
7
|
context(:comments) do
|
8
|
-
|
9
8
|
let(:tc) { po.translator_comment }
|
10
|
-
let(:rc) { po.
|
9
|
+
let(:rc) { po.reference }
|
11
10
|
let(:ec) { po.extracted_comment }
|
12
11
|
let(:fc) { po.flag }
|
13
12
|
let(:pusc){ po.previous_untraslated_string }
|
@@ -35,7 +34,6 @@ describe PoParser::Parser do
|
|
35
34
|
expect(pusc).to parse("#| \"Hello,\\n\"\n")
|
36
35
|
expect(pusc).to parse("#| \"The new state of %(module)s - %(branch)s - %(domain)s (%(language)s) is \"\n")
|
37
36
|
end
|
38
|
-
|
39
37
|
end
|
40
38
|
|
41
39
|
context 'Entries' do
|
@@ -46,11 +44,13 @@ describe PoParser::Parser do
|
|
46
44
|
it 'parses msgid' do
|
47
45
|
expect(msgid).to parse "msgid \"The new state of %(module)s - %(branch)s - %(domain)s (%(language)s) is now \"\n"
|
48
46
|
expect(msgid).to parse "msgid \"The new \"state\" of %(module)s - %(branch)s - %(domain)s (%(language)s) is now \"\n"
|
47
|
+
expect(msgid).to parse "msgid \"The new \"state\" of %(module)s - %(branch)s - %(domain)s (%(language)s) is now \"\n"
|
49
48
|
end
|
50
49
|
|
51
50
|
it 'parses msgstr' do
|
52
51
|
expect(msgstr).to parse "msgstr \"The new state of %(module)s - %(branch)s - %(domain)s (%(language)s) is now \"\n"
|
53
52
|
expect(msgstr).to parse "msgstr \"فعالیت نامعتبر. شاید یک نفر دیگر دقیقا قبل از شما یک فعالیت دیگر ارسال کرده ۱۲۳۱۲۳۱safda \"\n"
|
53
|
+
expect(msgstr).to parse "msgstr \"The new state of %(module)s - %(branch)s - %(domain)s (%(language)s) is now \"\n"
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'parses multiline entries' do
|
@@ -60,10 +60,13 @@ describe PoParser::Parser do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'parses plural msgstr entries' do
|
63
|
-
|
63
|
+
str1 = "msgstr[0] \"\""
|
64
|
+
str2 = "msgstr[0] \"\""
|
65
|
+
str3 = "msgstr[0]\"\""
|
64
66
|
result = [{:msgstr_plural=>{:plural_id=>"0", :text=>""}}]
|
65
|
-
expect(po.parse(
|
67
|
+
expect(po.parse(str1)).to eq(result)
|
68
|
+
expect(po.parse(str2)).to eq(result)
|
69
|
+
expect(po.parse(str3)).to eq(result)
|
66
70
|
end
|
67
71
|
end
|
68
|
-
|
69
72
|
end
|
data/spec/poparser/po_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe PoParser::Tokenizer do
|
|
5
5
|
let(:token) { PoParser::Tokenizer.new }
|
6
6
|
let(:po_file){ Pathname.new('spec/poparser/fixtures/tokenizer.po').realpath }
|
7
7
|
let(:po_file_empty_line){ Pathname.new('spec/poparser/fixtures/tokenizer_empty_line.po').realpath }
|
8
|
-
let(:result) { [{:
|
8
|
+
let(:result) { [{:reference=>"templates:105", :msgid=>"Afrikaans", :msgstr=>"آفریقایی"}, {:flag=>"fuzzy", :msgid=>"Afrikaans", :msgstr=>"آفریقایی" }] }
|
9
9
|
|
10
10
|
it 'should be able to extracts entries' do
|
11
11
|
expect(
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: PoParser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arash Mousavi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parslet
|