gettext-setup 0.12 → 0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tasks/gettext.rake +27 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1ff3e5f7747f9bba978668895c4e001d989fff2
4
- data.tar.gz: 9abe9970c2aa1b735657b39a90060be0bc546c31
3
+ metadata.gz: c0f7e467d79154886b797367c614a87937e5b811
4
+ data.tar.gz: e9388332a6ccb61ab6b6df0e848283dff8a4cd1e
5
5
  SHA512:
6
- metadata.gz: 97bb39e683b537bb2b2e78f5edf6daf83bcad583950db1107802525dcc346950a93a8d86ffb85b2e124d1bb3cfe0caa7742c71ef7f1e118670edc5970d3ec8d5
7
- data.tar.gz: 07129328df93aaadbd749d06cc8355e68cb06cf489d86077813298c14abed6b03c56ba3e6474931b6eca6bf5cdbedeaa3c7efdf808c160baf623edf2a11d7bb7
6
+ metadata.gz: e114576c5e3610e93f06a17fb63701154ca7677590d24773970bf3e5f7ab50e892a500a2f5fd7d454334e82bde60d312c1aa925c5e4475a2de69e9a97e80481d
7
+ data.tar.gz: c86d5fff6ada432f699afa9ad8fbeaf87f7d5b57c602c7271abb50c05702d285bf808b442b61c878db75959b558de244900e83a5645d19bec045da6ad2f8e563
@@ -32,8 +32,7 @@ namespace :gettext do
32
32
  File.join(locale_path, GettextSetup.config['project_name'] + ".pot")
33
33
  end
34
34
 
35
- desc "Update pot files"
36
- task :pot do
35
+ def generate_new_pot
37
36
  config = GettextSetup.config
38
37
  package_name = config['package_name']
39
38
  project_name = config['project_name']
@@ -52,10 +51,34 @@ namespace :gettext do
52
51
  "--package-version '#{version}' " +
53
52
  "--copyright-holder='#{copyright_holder}' --copyright-year=#{Time.now.year} " +
54
53
  "#{files_to_translate.join(" ")}")
55
- puts "POT file locales/#{project_name}.pot has been updated"
56
54
  end
57
55
 
58
- desc "Update po file for a specific language"
56
+ desc "Generate a new POT file and replace old if strings changed"
57
+ task :update_pot do
58
+ if !File.exists? pot_file_path
59
+ puts "No existing POT file, generating new"
60
+ generate_new_pot
61
+ else
62
+ old_pot = pot_file_path + ".old"
63
+ File.rename(pot_file_path, old_pot)
64
+ generate_new_pot
65
+ if system("msgcmp --use-untranslated '#{old_pot}' '#{pot_file_path}'")
66
+ puts "No string changes detected, keeping old POT file"
67
+ File.rename(old_pot, pot_file_path)
68
+ else
69
+ File.delete(old_pot)
70
+ puts "String changes detected, replacing with updated POT file"
71
+ end
72
+ end
73
+ end
74
+
75
+ desc "Generate POT file"
76
+ task :pot do
77
+ generate_new_pot
78
+ puts "POT file #{pot_file_path} has been generated"
79
+ end
80
+
81
+ desc "Update PO file for a specific language"
59
82
  task :po, [:language] do |_, args|
60
83
  language = args.language || ENV["LANGUAGE"]
61
84
 
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.12'
4
+ version: '0.13'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-18 00:00:00.000000000 Z
11
+ date: 2017-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement