yast-rake 0.2.37 → 0.2.38

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/tasks/pot.rake +38 -15
  4. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98b02611f30a453046b09d43d2a9475915d3f62ddaa25e86501a8dac1d7c34ac
4
- data.tar.gz: 72c1f696a456ea27607324326863ff0ab902e1c02d6852fe91aafa692e267e5a
3
+ metadata.gz: 18af28aa52d36fae2562ec34077203bf5caf3133e2478bbb148a62cb12fdfa9d
4
+ data.tar.gz: 6de5e620075e519ab220a18c80c0dc490401e25ed1554a778092505968ac67dd
5
5
  SHA512:
6
- metadata.gz: 8242f408e27684ee7a5888453f9efef2bb2922d4203dba46529391bb22926a65709ad522d52ce5c641fd74b3932a2d9f24b690e5d8b41193d952602593040833
7
- data.tar.gz: 6780d86f72ed7cd3950238d15428a5c0d83e22284ec50e1601151bd8d5ae97a29e0113e46ab45cb1eb58f33bf879c2733d1427f92289688d803b2f9e358c01e2
6
+ metadata.gz: 5620ca0179a75376946c702286ce5ddec59a5a112da7b0b05b686514f18621ece0c2a77f52cdb2928e1483a149310082ff97725efad3d654b37885da8f9855b3
7
+ data.tar.gz: d517ffc2098ccbf315132d51dcdc44adbe6dbfb8ba2718c13e7cc3989dc42f59a90c9e06676aec7cb2f359598c20ff883e20955974a2c5d463db1afbd094ff9d
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.37
1
+ 0.2.38
@@ -27,19 +27,36 @@ task :pot do
27
27
  end
28
28
 
29
29
  namespace :check do
30
+
31
+ def interpolation_message
32
+ <<~MSG
33
+ Note: \#{foo} substitution in translatable strings does
34
+ not work properly, use
35
+ _("foo %{bar} baz") % { :bar => bar }
36
+ or
37
+ _("foo %s baz") % bar
38
+ MSG
39
+ end
40
+
41
+ def angle_brackets_message
42
+ <<~MSG
43
+ Note: %<foo> placeholder should not be used in translatable strings
44
+ because GNU Gettext does not support any suitable language format for that,
45
+ use %{foo} instead.
46
+ MSG
47
+ end
48
+
30
49
  # print failed lines and a hint to STDERR
31
- def report_pot_errors(lines)
50
+ def report_pot_errors(lines, message)
51
+ return if lines.empty?
52
+
32
53
  warn "Failed lines:"
33
54
  warn "-" * 30
34
55
  warn lines
35
56
  warn "-" * 30
36
- $stderr.puts
37
- warn "Note: \#{foo} substitution in translatable strings does" \
38
- " not work properly, use"
39
- warn " _(\"foo %{bar} baz\") % { :bar => bar }"
40
- warn "or"
41
- warn " _(\"foo %s baz\") % bar"
42
- $stderr.puts
57
+ warn ""
58
+ warn message
59
+ warn ""
43
60
  end
44
61
 
45
62
  # remove gettext keywords and extra quotes
@@ -53,7 +70,9 @@ namespace :check do
53
70
  end
54
71
 
55
72
  desc "Check translatable strings for common mistakes"
56
- # depends on the global "pot" task defined above
73
+ # depends on the global "pot" task defined above,
74
+ # this scans for the #{} interpolations (do not work in translations)
75
+ # and %<> (no compatible language format in Gettext)
57
76
  task pot: :"rake:pot" do
58
77
  Dir["*.pot"].each do |pot|
59
78
  puts "Checking #{pot}..."
@@ -61,14 +80,18 @@ namespace :check do
61
80
  # remove comments
62
81
  lines.reject! { |line| line.match(/^#/) }
63
82
  # Ruby substitution present?
64
- lines.select! { |line| line.include?("\#{") }
83
+ interpolations = lines.select { |line| line.include?("\#{") }
84
+ angle_brackets = lines.select { |line| line.include?("%<") }
85
+
86
+ next if interpolations.empty? && angle_brackets.empty?
87
+
88
+ clean_pot_lines(interpolations)
89
+ clean_pot_lines(angle_brackets)
65
90
 
66
- clean_pot_lines(lines)
91
+ report_pot_errors(interpolations, interpolation_message)
92
+ report_pot_errors(angle_brackets, angle_brackets_message)
67
93
 
68
- if !lines.empty?
69
- report_pot_errors(lines)
70
- raise "ERROR: Ruby substitution found in a translatable string"
71
- end
94
+ raise "ERROR: Found invalid or unsupported translatable string"
72
95
  end
73
96
  end
74
97
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yast-rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.37
4
+ version: 0.2.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josef Reidinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-05 00:00:00.000000000 Z
11
+ date: 2020-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: packaging_rake_tasks
@@ -86,8 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  requirements: []
89
- rubyforge_project:
90
- rubygems_version: 2.7.6.2
89
+ rubygems_version: 3.1.2
91
90
  signing_key:
92
91
  specification_version: 4
93
92
  summary: Rake tasks providing basic work-flow for Yast development