gettext-setup 0.30 → 0.31

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
- SHA1:
3
- metadata.gz: 55e7c36131dbc622484fd2d752352dc235c82cf7
4
- data.tar.gz: ef5a82547c41f8336cbcaa251ba4e1c0a0278d89
2
+ SHA256:
3
+ metadata.gz: 12e71aa5e0dfcabd81f9815b7288de5edea56295600b5b82fce740614374b948
4
+ data.tar.gz: c42ce6ef320c3999fcfa6895d9c2d7ceaab93980459cfd8985a19a389eb6a08a
5
5
  SHA512:
6
- metadata.gz: 634692fe3c69bc1ab9dca17f1460dc3013ac32054757c7553531e316dd7de6fbe937396d898db50cfb155d3315bb6119c000642f07e15fd5862dd803f5f4e335
7
- data.tar.gz: 9e9b644e6baa63327de33e7ce2ca46cebeda5533f28acea6cc9afc47289065db878c9d2a28672b0e7762b50fad2bc8218f09a27b1702268d2dc09df7c667602b
6
+ metadata.gz: 1ee5e91fd99697e94de0f11bf162c5353e32cb86d273da51e6188e821a95065674d68aaad626c0c21a3f6e2c1ef10999c74228b62e2eb18c87b84ef97e55148a
7
+ data.tar.gz: 5b384a1a0ef825e3d591fba2ce46a6356a0fb2cdfe6b03b0de89b1863db66ccc3666bb1aa79643f64974ba2f911fd81c1ba83fb26152ed390eef710c392c0302
@@ -58,6 +58,7 @@ module GettextSetup
58
58
 
59
59
  def self.config?
60
60
  raise NoConfigFoundError, File.join(locales_path, 'config.yaml') unless @config
61
+
61
62
  @config
62
63
  end
63
64
 
@@ -113,9 +114,11 @@ module GettextSetup
113
114
  # return the default locale
114
115
  def self.negotiate_locale(accept_header)
115
116
  unless @config
116
- raise ArgumentError, 'No config.yaml found! Use `GettextSetup.initialize(locales_path)` to locate your config.yaml'
117
+ raise ArgumentError, 'No config.yaml found! Use ' \
118
+ '`GettextSetup.initialize(locales_path)` to locate your config.yaml'
117
119
  end
118
120
  return FastGettext.default_locale if accept_header.nil?
121
+
119
122
  available_locales = accept_header.split(',').map do |locale|
120
123
  pair = locale.strip.split(';q=')
121
124
  pair << '1.0' unless pair.size == 2
@@ -1,5 +1,6 @@
1
1
  require 'erb'
2
2
  require 'json'
3
+ require 'date'
3
4
 
4
5
  module GettextSetup
5
6
  module MetadataPot
@@ -13,7 +14,7 @@ module GettextSetup
13
14
 
14
15
  def self.metadata(metadata_file = 'metadata.json')
15
16
  if File.exist?(metadata_file)
16
- file = open(metadata_file)
17
+ file = File.open(metadata_file)
17
18
  json = file.read
18
19
  JSON.parse(json)
19
20
  else
@@ -28,7 +29,7 @@ module GettextSetup
28
29
  end
29
30
 
30
31
  def self.generate_metadata_pot(pot_metadata = metadata, path = metadata_path)
31
- open(path, 'w') do |f|
32
+ File.open(path, 'w') do |f|
32
33
  f << pot_string(pot_metadata)
33
34
  end
34
35
  end
@@ -25,28 +25,39 @@ module GettextSetup
25
25
 
26
26
  def self.pot_file_path
27
27
  return if GettextSetup.locales_path.nil?
28
+
28
29
  return if GettextSetup.config['project_name'].nil?
30
+
29
31
  File.join(GettextSetup.locales_path, GettextSetup.config['project_name'] + '.pot')
30
32
  end
31
33
 
32
34
  def self.po_file_path(language)
33
35
  return if GettextSetup.locales_path.nil?
36
+
34
37
  return if GettextSetup.config['project_name'].nil?
38
+
35
39
  return if language.nil?
40
+
36
41
  File.join(GettextSetup.locales_path, language, GettextSetup.config['project_name'] + '.po')
37
42
  end
38
43
 
39
44
  def self.string_changes?(old_pot, new_pot)
40
45
  # Warnings will be in another language if locale is not set to en_US
41
46
  _, stderr, status = Open3.capture3("LANG=en_US msgcmp --use-untranslated '#{old_pot}' '#{new_pot}'")
42
- if status.exitstatus == 1 || /this message is not used/.match(stderr) || /this message is used but not defined/.match(stderr)
47
+ return true if status.exitstatus == 1 || \
48
+ /this message is not used/.match(stderr) || \
49
+ /this message is used but not defined/.match(stderr)
50
+
51
+ if stderr =~ /msgcmp: command not found/
52
+ puts 'Warning - msgcmp is not present on the system'
43
53
  return true
44
54
  end
45
- return false
55
+
56
+ false
46
57
  rescue IOError
47
58
  # probably means msgcmp is not present on the system
48
59
  # so return true to be on the safe side
49
- return true
60
+ true
50
61
  end
51
62
 
52
63
  # @param [:locales_path] opts
@@ -176,6 +187,7 @@ module GettextSetup
176
187
  _, _, _, wait = Open3.popen3(cmd)
177
188
  exitstatus = wait.value
178
189
  raise 'PO files failed to merge' unless exitstatus.success?
190
+
179
191
  puts "PO files have been successfully merged, #{target_filename} has been created."
180
192
  exitstatus
181
193
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'rspec/expectations'
2
4
  require_relative '../../spec_helper'
3
5
 
@@ -164,7 +164,7 @@ describe GettextSetup::Pot do
164
164
  before :all do
165
165
  { 'ruby' => 'ruby.pot', 'puppet' => 'puppet.pot', 'metadata' => 'metadata.pot' }.each do |pot_type, pot_name|
166
166
  File.open(File.join(merge_locales_path, pot_name), 'w') do |file|
167
- file.write <<-POT
167
+ file.write <<POT
168
168
  # Copyright (C) 2017 Puppet, Inc.
169
169
  # This file is distributed under the same license as the puppetlabs-mysql package.
170
170
  # FIRST AUTHOR <EMAIL@ADDRESS>, 2017.
@@ -186,7 +186,7 @@ describe GettextSetup::Pot do
186
186
  #: ../lib/puppet/parser/functions/mysql_strip_hash.rb:11
187
187
  msgid "this is a #{pot_type} string"
188
188
  msgstr ""
189
- POT
189
+ POT
190
190
  end
191
191
  end
192
192
  end
@@ -10,9 +10,9 @@ end
10
10
  def cmd_present?(cmd)
11
11
  # Try to call out to msgcmp, if it doesn't error, we have the tool
12
12
  `#{cmd} --version`
13
- return true
13
+ true
14
14
  rescue IOError
15
- return false
15
+ false
16
16
  end
17
17
 
18
18
  def msgcmp_present?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gettext-setup
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.30'
4
+ version: '0.31'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-12 00:00:00.000000000 Z
11
+ date: 2019-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fast_gettext
@@ -223,32 +223,31 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  - !ruby/object:Gem::Version
224
224
  version: '0'
225
225
  requirements: []
226
- rubyforge_project:
227
- rubygems_version: 2.5.1
226
+ rubygems_version: 3.0.3
228
227
  signing_key:
229
228
  specification_version: 4
230
229
  summary: A gem to ease internationalization with fast_gettext
231
230
  test_files:
231
+ - spec/spec_helper.rb
232
+ - spec/lib/tasks/gettext_rake_spec.rb
233
+ - spec/lib/gettext-setup/pot_spec.rb
234
+ - spec/lib/gettext-setup/metadata_pot_spec.rb
235
+ - spec/lib/gettext-setup/gettext_setup_spec.rb
236
+ - spec/fixtures/fixture_locales/test_strings.rb
232
237
  - spec/fixtures/fixture_locales/config.yaml
233
238
  - spec/fixtures/fixture_locales/fixture_locales.pot
234
239
  - spec/fixtures/fixture_locales/jp/fixture_locales.po
235
- - spec/fixtures/fixture_locales/test_strings.rb
240
+ - spec/fixtures/locales/sinatra-i18n.pot
236
241
  - spec/fixtures/locales/config.yaml
237
242
  - spec/fixtures/locales/de/sinatra-i18n.po
238
- - spec/fixtures/locales/sinatra-i18n.pot
239
243
  - spec/fixtures/merge_locales/config.yaml
240
- - spec/fixtures/spec_locales/config.yaml
241
- - spec/fixtures/spec_locales/sinatra-i18n.pot
242
- - spec/fixtures/string_changes/add.pot
243
- - spec/fixtures/string_changes/change.pot
244
244
  - spec/fixtures/string_changes/non_string_changes.pot
245
- - spec/fixtures/string_changes/old.pot
246
245
  - spec/fixtures/string_changes/remove.pot
246
+ - spec/fixtures/string_changes/old.pot
247
+ - spec/fixtures/string_changes/change.pot
248
+ - spec/fixtures/string_changes/add.pot
249
+ - spec/fixtures/spec_locales/sinatra-i18n.pot
250
+ - spec/fixtures/spec_locales/config.yaml
251
+ - spec/fixtures/tmp_locales/sinatra-i18n.pot
247
252
  - spec/fixtures/tmp_locales/config.yaml
248
253
  - spec/fixtures/tmp_locales/de/sinatra-i18n.po
249
- - spec/fixtures/tmp_locales/sinatra-i18n.pot
250
- - spec/lib/gettext-setup/gettext_setup_spec.rb
251
- - spec/lib/gettext-setup/metadata_pot_spec.rb
252
- - spec/lib/gettext-setup/pot_spec.rb
253
- - spec/lib/tasks/gettext_rake_spec.rb
254
- - spec/spec_helper.rb