rgettext_poedit 0.0.1 → 0.0.2

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: 22519680349c5d1bf19928498618309c6d6a10bc
4
- data.tar.gz: 25331de0c8b9d70cf57752fdbfc64ca8b21bf7d1
3
+ metadata.gz: b83221d90230b0fdbbec2de473eb3ba4521c3767
4
+ data.tar.gz: 79e3eb1b9b0070652db1e86f039b7807046125a4
5
5
  SHA512:
6
- metadata.gz: a64883503c5a16f266a18e9731e187eeacd258ba21c559d0f890ad562d30f427582077ae2a70ed0a317b75fea9d111ae9af01cc0b1dc05df963e1b54e1f45e0c
7
- data.tar.gz: e39befe2df5d886dfa7dbbfdfbd965d0a94eac0917f7ab9095d9f11248f092380f715b3bf41c52cfd461869dc51633d3ef6ccd81442c480b8f8f385dc6a08f9c
6
+ metadata.gz: 59c8e97922de1b1704d54827bbe99a9f42d755c9963ac2d07bf5c33e466c619cfd8c5abd9c727033caeaafc930310ea38f4b8e9d9a04835fd41eec97a5b4e0a4
7
+ data.tar.gz: 7afff1e20d48d03da82c0b302f2a589fd9e99397d2551217441f68807147e748f3a009e26698b288c00cf8841332aca6c97dbdebb6c76762ec4978a382ec51d2
@@ -1,15 +1,18 @@
1
- = rgettext_poedit
1
+ # rgettext_poedit
2
2
 
3
3
  This Gem can help the application POEdit parse .erb and .haml files for easy translations.
4
4
 
5
- Configure POedit like this:
5
+ Configure POEdit like this:
6
6
 
7
7
  New parser with name "Ruby".
8
+
8
9
  List of extensions: *.rb; *.rhtml; *.erb; *.haml
10
+
9
11
  Command for parsing: rgettext_poedit %F -o %o
12
+
10
13
  Element in list for data files: %f
11
14
 
12
- == Contributing to rgettext_poedit
15
+ # Contributing to rgettext_poedit
13
16
 
14
17
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
15
18
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
@@ -19,7 +22,7 @@ Element in list for data files: %f
19
22
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
20
23
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
21
24
 
22
- == Copyright
25
+ # Copyright
23
26
 
24
27
  Copyright (c) 2014 Kasper Johansen. See LICENSE.txt for
25
28
  further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -7,6 +7,7 @@ class RgettextPoedit
7
7
  @translations = {}
8
8
  @method_names = ["_", "gettext"]
9
9
  @valid_beginning = '(^|\s+|\(|\{|<%=\s*)'
10
+ @comments = []
10
11
  end
11
12
 
12
13
  def parse_files
@@ -35,6 +36,11 @@ class RgettextPoedit
35
36
  @output << "#: #{file[:filepath]}:#{file[:line_no]}\n"
36
37
  end
37
38
 
39
+ data[:comments].each do |comment|
40
+ puts "Comment: #{comment}"
41
+ @output << "#. #{comment}\n"
42
+ end
43
+
38
44
  @output << "msgid \"#{translation}\"\n"
39
45
  @output << "msgstr \"\"\n"
40
46
  end
@@ -58,6 +64,10 @@ private
58
64
 
59
65
  # Scans content for translations and saves them.
60
66
  def parse_content(filepath, line_no, content)
67
+ content.scan(/^\s*#\. (.+)$/) do |match|
68
+ add_comment(match[0])
69
+ end
70
+
61
71
  @method_names.each do |method_name|
62
72
  # Scan for the various valid formats.
63
73
  content.scan(/#{@valid_beginning}#{Regexp.escape(method_name)}\s*\("(.+?)"/) do |match|
@@ -80,18 +90,22 @@ private
80
90
 
81
91
  def should_skip_line(filepath, line_no, line)
82
92
  # Skip the line if it is a comment in Haml.
83
- if File.extname(filepath) == ".haml" && line.match(/^(\s*)-(\s*)#/)
84
- return true
85
- end
86
-
93
+ return true if File.extname(filepath) == ".haml" && line.match(/^(\s*)-(\s*)#/)
87
94
  return false
88
95
  end
89
96
 
97
+ def add_comment(comment)
98
+ @comments << comment
99
+ end
100
+
90
101
  def add_translation(filepath, line_no, translation)
91
102
  if !@translations.key?(translation)
92
- @translations[translation] = {:files => []}
103
+ @translations[translation] = {:files => [], :comments => @comments}
104
+ else
105
+ @translations[translation][:comments] += @comments
93
106
  end
94
107
 
95
108
  @translations[translation][:files] << {:filepath => filepath, :line_no => line_no}
109
+ @comments = []
96
110
  end
97
111
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "rgettext_poedit"
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
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"]
@@ -14,6 +14,7 @@ describe "RgettextPoedit" do
14
14
  ' _"Test 7" ',
15
15
  " _'Test 8' \n",
16
16
  " str = \"Hejsa \#{_('Test 9')} ",
17
+ "#. Dette er en test",
17
18
  '<%=_"Test 10"%>'
18
19
  ]
19
20
 
@@ -33,5 +34,6 @@ describe "RgettextPoedit" do
33
34
  strs.keys.should include "Test 8"
34
35
  strs.keys.should include "Test 9"
35
36
  strs.keys.should include "Test 10"
37
+ strs["Test 10"][:comments].should include "Dette er en test"
36
38
  end
37
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgettext_poedit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-10 00:00:00.000000000 Z
11
+ date: 2014-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: knjrbfw
@@ -74,14 +74,14 @@ executables:
74
74
  extensions: []
75
75
  extra_rdoc_files:
76
76
  - LICENSE.txt
77
- - README.rdoc
77
+ - README.md
78
78
  files:
79
79
  - .document
80
80
  - .rspec
81
81
  - Gemfile
82
82
  - Gemfile.lock
83
83
  - LICENSE.txt
84
- - README.rdoc
84
+ - README.md
85
85
  - Rakefile
86
86
  - VERSION
87
87
  - bin/rgettext_poedit