simple_po_parser 1.0.1 → 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 +15 -0
- data/README.md +15 -14
- data/Rakefile +0 -3
- data/lib/simple_po_parser/parser.rb +6 -2
- data/lib/simple_po_parser/version.rb +1 -1
- data/spec/simple_po_parser/parser_spec.rb +16 -16
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10a107f2a74fa7cf6902d58c15f466705a52ef0c
|
4
|
+
data.tar.gz: 63369a5ede32deb4846c07a9206cc1a09cc4989c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f905113fc6890089e63110702d752b90cf3d2d678399d42f3ddd3d088fdcab787caf453d6a07fa07b0cc9b947a5b90aebc025ee33c20025a9174f6a829183424
|
7
|
+
data.tar.gz: 26591d6acbf9c279ddbd7986ba4d320bc6c525858740dd6d7fc86f87971fe795d16d95524c297703c24190140f372ebf994b2df81602180d8dbfadc177ff100c
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Version 1.1.0
|
2
|
+
=============
|
3
|
+
|
4
|
+
* for line types only parsed once the parser returns a string instead of an array with one string
|
5
|
+
|
6
|
+
Version 1.0.1
|
7
|
+
=============
|
8
|
+
|
9
|
+
* added specs
|
10
|
+
* fixed minor parser errors
|
11
|
+
|
12
|
+
Version 1.0.0
|
13
|
+
=============
|
14
|
+
|
15
|
+
* initial release
|
data/README.md
CHANGED
@@ -9,23 +9,24 @@ This is a simple PO file to ruby hash parser, which complies with [GNU PO file s
|
|
9
9
|
## Hash format
|
10
10
|
|
11
11
|
A PO message is parsed into a hash with meaningful keys for each type of line.
|
12
|
-
The values are
|
13
|
-
|
12
|
+
The values are strings, if only one line of such content was parsed,
|
13
|
+
otherthise it's an array of strings. Each string is
|
14
|
+
representing one line of content in the PO file.
|
14
15
|
|
15
16
|
```ruby
|
16
17
|
{
|
17
|
-
:translator_comment => [""],
|
18
|
-
:extracted_comment => [""],
|
19
|
-
:reference => [""],
|
20
|
-
:flag => [""],
|
21
|
-
:previous_msgctxt => [""
|
22
|
-
:previous_msgid => [""], # msgid of the messaged used for the fuzzy translation
|
23
|
-
:previous_msgid_plural => [""],
|
24
|
-
:msgctxt => [""],
|
25
|
-
:msgid => [""],
|
26
|
-
:msgid_plural => [""],
|
27
|
-
:msgstr => [""], # for singular messages
|
28
|
-
"msgstr[N]" => [""] # for plural messages, there N is the plural number starting from 0
|
18
|
+
:translator_comment => "" || ["", ""...],
|
19
|
+
:extracted_comment => "" || ["", ""...],
|
20
|
+
:reference => "" || ["", ""...],
|
21
|
+
:flag => "" || ["", ""...],
|
22
|
+
:previous_msgctxt => "" || ["", ""...],# msgctxt of the message used for the fuzzy translation
|
23
|
+
:previous_msgid => "" || ["", ""...], # msgid of the messaged used for the fuzzy translation
|
24
|
+
:previous_msgid_plural => "" || ["", ""...],
|
25
|
+
:msgctxt => "" || ["", ""...],
|
26
|
+
:msgid => "" || ["", ""...],
|
27
|
+
:msgid_plural => "" || ["", ""...],
|
28
|
+
:msgstr => "" || ["", ""...], # for singular messages
|
29
|
+
"msgstr[N]" => "" || ["", ""...] # for plural messages, there N is the plural number starting from 0
|
29
30
|
}
|
30
31
|
```
|
31
32
|
|
data/Rakefile
CHANGED
@@ -342,9 +342,13 @@ module SimplePoParser
|
|
342
342
|
# creates an array if the given key already has a result
|
343
343
|
def add_result(key, text)
|
344
344
|
if @result[key]
|
345
|
-
@result[key].
|
345
|
+
if @result[key].is_a? Array
|
346
|
+
@result[key].push(text)
|
347
|
+
else
|
348
|
+
@result[key] = [@result[key], text]
|
349
|
+
end
|
346
350
|
else
|
347
|
-
@result[key] =
|
351
|
+
@result[key] = text
|
348
352
|
end
|
349
353
|
end
|
350
354
|
|
@@ -8,8 +8,8 @@ describe SimplePoParser::Parser do
|
|
8
8
|
it "parses the PO header" do
|
9
9
|
expected_result = {
|
10
10
|
:translator_comment => ["PO Header entry", ""],
|
11
|
-
:flag =>
|
12
|
-
:msgid =>
|
11
|
+
:flag => "fuzzy",
|
12
|
+
:msgid => "",
|
13
13
|
:msgstr => ["", "Project-Id-Version: simple_po_parser 1\\n", "Report-Msgid-Bugs-To: me\\n"]
|
14
14
|
}
|
15
15
|
expect(SimplePoParser::Parser.parse(po_header)).to eq(expected_result)
|
@@ -17,12 +17,12 @@ describe SimplePoParser::Parser do
|
|
17
17
|
|
18
18
|
it "parses the simple entry as expected" do
|
19
19
|
expected_result = {
|
20
|
-
:translator_comment =>
|
21
|
-
:extracted_comment =>
|
22
|
-
:reference =>
|
23
|
-
:msgctxt =>
|
24
|
-
:msgid =>
|
25
|
-
:msgstr =>
|
20
|
+
:translator_comment => "translator-comment",
|
21
|
+
:extracted_comment => "extract",
|
22
|
+
:reference => "reference1",
|
23
|
+
:msgctxt => "Context",
|
24
|
+
:msgid => "msgid",
|
25
|
+
:msgstr => "translated"
|
26
26
|
}
|
27
27
|
expect(SimplePoParser::Parser.parse(po_simple_message)).to eq(expected_result)
|
28
28
|
end
|
@@ -30,18 +30,18 @@ describe SimplePoParser::Parser do
|
|
30
30
|
it "parses the complex entry as expected" do
|
31
31
|
expected_result = {
|
32
32
|
:translator_comment => ["translator-comment", ""],
|
33
|
-
:extracted_comment =>
|
33
|
+
:extracted_comment => "extract",
|
34
34
|
:reference => ["reference1", "reference2"],
|
35
|
-
:flag =>
|
36
|
-
:previous_msgctxt =>
|
35
|
+
:flag => "flag",
|
36
|
+
:previous_msgctxt => "previous context",
|
37
37
|
:previous_msgid => ["", "multiline\\n", "previous messageid"],
|
38
|
-
:previous_msgid_plural =>
|
39
|
-
:msgctxt =>
|
40
|
-
:msgid =>
|
38
|
+
:previous_msgid_plural => "previous msgid_plural",
|
39
|
+
:msgctxt => "Context",
|
40
|
+
:msgid => "msgid",
|
41
41
|
:msgid_plural => ["", "multiline msgid_plural\\n", ""],
|
42
|
-
"msgstr[0]" =>
|
42
|
+
"msgstr[0]" => "msgstr 0",
|
43
43
|
"msgstr[1]" => ["", "msgstr 1 multiline 1\\n", "msgstr 1 line 2\\n"],
|
44
|
-
"msgstr[2]" =>
|
44
|
+
"msgstr[2]" => "msgstr 2"
|
45
45
|
}
|
46
46
|
expect(SimplePoParser::Parser.parse(po_complex_message)).to eq(expected_result)
|
47
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_po_parser
|
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
|
- Dennis-Florian Herr
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- ".gitignore"
|
64
64
|
- ".rspec"
|
65
65
|
- ".travis.yml"
|
66
|
+
- CHANGELOG.md
|
66
67
|
- Gemfile
|
67
68
|
- Gemfile.lock
|
68
69
|
- LICENSE.txt
|