translation 1.3 → 1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 438a297a6cc07e0af97053bf03b98e5c5c0613dd
4
- data.tar.gz: 433b5ab03bdd59005cf81dfc4c042e0aefb7ab0d
3
+ metadata.gz: dd5685e820858ee9272a66b6cefb5d85d82f01d8
4
+ data.tar.gz: 547c098280bc7db216d336c6bf676c0ec738a1c3
5
5
  SHA512:
6
- metadata.gz: 0fac9fb66470320c386ea22792953ccf164f1a05d2d759b2ec994fae468e6c6d9b96b12109ec0f379f2c2ec48ae391215d5d92c69569270b85fc63d62ca5718e
7
- data.tar.gz: 2f88d12ab1f5cb1c724086b0cfc40bfe7c3bff4cca05d4078c90d5fef8e1c2ceb913d513eb677d7f317290bd7bdfe79a7a861370979af3ab08c37f6cd130ee56
6
+ metadata.gz: 2f404426ef37f123acbf9957c9d96acc522c6e0f32e749b957ca0c9eca3204a0dba3c8791b109d42e2fcd20687a9902a249bed9f6a9d2bc8ddf230717febd080
7
+ data.tar.gz: 90d29c39095fb4234d850f8e34b1d4cf22b1fd06629f057481fe673e8cf78028bd0fd69ff9363c846fa022cfbc7b2e9e4715962048b07e07332bf5f7e3cd6b8f
@@ -1,3 +1,4 @@
1
+ require 'translation_io/client/base_operation/update_pot_file_step'
1
2
  require 'translation_io/client/base_operation/save_new_po_files_step'
2
3
  require 'translation_io/client/base_operation/create_new_mo_files_step'
3
4
  require 'translation_io/client/base_operation/save_new_yaml_files_step'
@@ -41,7 +42,7 @@ module TranslationIO
41
42
  $stderr.puts "[Error] #{parsed_response['error']}"
42
43
  exit
43
44
  else
44
- $stderr.puts "[Error] Unknown error."
45
+ $stderr.puts "[Error] Unknown error from the server: #{response.code}."
45
46
  exit
46
47
  end
47
48
  rescue Errno::ECONNREFUSED
@@ -52,6 +53,10 @@ module TranslationIO
52
53
 
53
54
  def cleanup
54
55
  FileUtils.rm_rf(File.join('tmp', 'translation'))
56
+
57
+ if TranslationIO.config.disable_gettext
58
+ FileUtils.rm_rf(TranslationIO.config.locales_path)
59
+ end
55
60
  end
56
61
  end
57
62
  end
@@ -16,7 +16,9 @@ module TranslationIO
16
16
  file_path = File.join('tmp', 'translation', "haml-gettext-#{index.to_s.rjust(8,'0')}.rb")
17
17
 
18
18
  File.open(file_path, 'w') do |file|
19
- file.puts "#{entry}"
19
+ file.puts "def fake"
20
+ file.puts " #{entry}"
21
+ file.puts "end"
20
22
  end
21
23
  end
22
24
  end
@@ -16,7 +16,9 @@ module TranslationIO
16
16
  file_path = File.join('tmp', 'translation', "slim-gettext-#{index.to_s.rjust(8,'0')}.rb")
17
17
 
18
18
  File.open(file_path, 'w') do |file|
19
- file.puts "#{entry}"
19
+ file.puts "def fake"
20
+ file.puts " #{entry}"
21
+ file.puts "end"
20
22
  end
21
23
  end
22
24
  end
@@ -1,14 +1,20 @@
1
1
  module TranslationIO
2
2
  class Client
3
- class InitOperation < BaseOperation
3
+ class BaseOperation
4
4
  class UpdatePotFileStep
5
5
  def initialize(pot_path, source_files)
6
- @pot_path = pot_path
7
- @source_files = source_files + Dir['tmp/translation/*.rb']
6
+ @pot_path = pot_path
7
+
8
+ if TranslationIO.config.disable_gettext
9
+ @source_files = empty_source_files
10
+ else
11
+ @source_files = source_files + Dir['tmp/translation/*.rb']
12
+ end
8
13
  end
9
14
 
10
15
  def run(params)
11
16
  TranslationIO.info "Updating POT file."
17
+
12
18
  FileUtils.mkdir_p(File.dirname(@pot_path))
13
19
  GetText::Tools::XGetText.run(*@source_files, '-o', @pot_path,
14
20
  '--msgid-bugs-address', TranslationIO.config.pot_msgid_bugs_address,
@@ -17,7 +23,19 @@ module TranslationIO
17
23
  '--copyright-holder', TranslationIO.config.pot_copyright_holder,
18
24
  '--copyright-year', TranslationIO.config.pot_copyright_year.to_s)
19
25
 
20
- params["pot_data"] = File.read(@pot_path)
26
+ FileUtils.rm_f(@tmp_empty_file) if @tmp_empty_file.present?
27
+
28
+ params['pot_data'] = File.read(@pot_path)
29
+ end
30
+
31
+ private
32
+
33
+ def empty_source_files
34
+ @tmp_empty_file = 'tmp/empty-gettext-file.rb'
35
+ FileUtils.mkdir_p('tmp')
36
+ FileUtils.touch(@tmp_empty_file)
37
+
38
+ [@tmp_empty_file]
21
39
  end
22
40
  end
23
41
  end
@@ -1,4 +1,3 @@
1
- require 'translation_io/client/init_operation/update_pot_file_step'
2
1
  require 'translation_io/client/init_operation/update_and_collect_po_files_step'
3
2
  require 'translation_io/client/init_operation/create_yaml_po_files_step'
4
3
  require 'translation_io/client/init_operation/cleanup_yaml_files_step'
@@ -19,8 +18,10 @@ module TranslationIO
19
18
  yaml_locales_path = config.yaml_locales_path
20
19
  yaml_file_paths = config.yaml_file_paths
21
20
 
22
- BaseOperation::DumpHamlGettextKeysStep.new(haml_source_files).run
23
- BaseOperation::DumpSlimGettextKeysStep.new(slim_source_files).run
21
+ unless config.disable_gettext
22
+ BaseOperation::DumpHamlGettextKeysStep.new(haml_source_files).run
23
+ BaseOperation::DumpSlimGettextKeysStep.new(slim_source_files).run
24
+ end
24
25
 
25
26
  UpdatePotFileStep.new(pot_path, source_files).run(params)
26
27
  UpdateAndCollectPoFilesStep.new(target_locales, pot_path, locales_path).run(params)
@@ -32,8 +33,13 @@ module TranslationIO
32
33
  yaml_locales_difference = (all_used_yaml_locales) - target_locales.sort.map(&:to_s)
33
34
 
34
35
  if yaml_locales_difference.any?
35
- TranslationIO.info("[error] Your `config.target_locales` are [#{target_locales.join(', ')}] and we have found some YAML keys for [#{all_used_yaml_locales.join(', ')}] and they does not match.")
36
- TranslationIO.info("[error] Do you really want to continue? (y/N)")
36
+ puts
37
+ puts "----------"
38
+ puts "Your `config.target_locales` are [#{target_locales.join(', ')}]."
39
+ puts "We have found some YAML keys for [#{all_used_yaml_locales.join(', ')}] and they don't match."
40
+ puts "Some of these locales may be coming from your gems."
41
+ puts "----------"
42
+ puts "Do you want to continue? (y/N)"
37
43
 
38
44
  print "> "
39
45
  input = STDIN.gets.strip
@@ -5,9 +5,9 @@ module TranslationIO
5
5
  attr_accessor :all_used_yaml_locales
6
6
 
7
7
  def initialize(source_locale, target_locales, yaml_file_paths)
8
- @source_locale = source_locale
9
- @target_locales = target_locales
10
- @yaml_file_paths = yaml_file_paths
8
+ @source_locale = source_locale
9
+ @target_locales = target_locales
10
+ @yaml_file_paths = yaml_file_paths
11
11
  @all_used_yaml_locales = Set.new
12
12
  end
13
13
 
@@ -1,4 +1,3 @@
1
- require 'translation_io/client/sync_operation/update_and_collect_pot_file_step'
2
1
  require 'translation_io/client/sync_operation/create_yaml_pot_file_step'
3
2
  require 'translation_io/client/sync_operation/apply_yaml_source_edits_step'
4
3
 
@@ -20,10 +19,12 @@ module TranslationIO
20
19
 
21
20
  ApplyYamlSourceEditsStep.new(yaml_file_paths, source_locale).run(params)
22
21
 
23
- BaseOperation::DumpHamlGettextKeysStep.new(haml_source_files).run
24
- BaseOperation::DumpSlimGettextKeysStep.new(slim_source_files).run
22
+ unless config.disable_gettext
23
+ BaseOperation::DumpHamlGettextKeysStep.new(haml_source_files).run
24
+ BaseOperation::DumpSlimGettextKeysStep.new(slim_source_files).run
25
+ end
25
26
 
26
- UpdateAndCollectPotFileStep.new(pot_path, source_files).run(params)
27
+ UpdatePotFileStep.new(pot_path, source_files).run(params)
27
28
  CreateYamlPotFileStep.new(source_locale, yaml_file_paths).run(params)
28
29
 
29
30
  if purge
@@ -8,6 +8,7 @@ module TranslationIO
8
8
  attr_accessor :ignored_key_prefixes
9
9
  attr_accessor :ignored_source_files
10
10
  attr_accessor :localization_key_prefixes
11
+ attr_accessor :disable_gettext
11
12
  attr_accessor :charset
12
13
  attr_accessor :metadata_path
13
14
 
@@ -28,6 +29,7 @@ module TranslationIO
28
29
  self.ignored_key_prefixes = []
29
30
  self.ignored_source_files = [] # Files not parsed for GetText entries
30
31
  self.localization_key_prefixes = []
32
+ self.disable_gettext = false
31
33
  self.charset = 'UTF-8'
32
34
  self.metadata_path = File.join('config', 'locales', '.translation_io')
33
35
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translation
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.3'
4
+ version: '1.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aurelien Malisart
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-13 00:00:00.000000000 Z
12
+ date: 2015-12-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gettext
@@ -85,15 +85,14 @@ files:
85
85
  - lib/translation_io/client/base_operation/save_new_po_files_step.rb
86
86
  - lib/translation_io/client/base_operation/save_new_yaml_files_step.rb
87
87
  - lib/translation_io/client/base_operation/save_special_yaml_files_step.rb
88
+ - lib/translation_io/client/base_operation/update_pot_file_step.rb
88
89
  - lib/translation_io/client/init_operation.rb
89
90
  - lib/translation_io/client/init_operation/cleanup_yaml_files_step.rb
90
91
  - lib/translation_io/client/init_operation/create_yaml_po_files_step.rb
91
92
  - lib/translation_io/client/init_operation/update_and_collect_po_files_step.rb
92
- - lib/translation_io/client/init_operation/update_pot_file_step.rb
93
93
  - lib/translation_io/client/sync_operation.rb
94
94
  - lib/translation_io/client/sync_operation/apply_yaml_source_edits_step.rb
95
95
  - lib/translation_io/client/sync_operation/create_yaml_pot_file_step.rb
96
- - lib/translation_io/client/sync_operation/update_and_collect_pot_file_step.rb
97
96
  - lib/translation_io/config.rb
98
97
  - lib/translation_io/controller.rb
99
98
  - lib/translation_io/extractor.rb
@@ -1,25 +0,0 @@
1
- module TranslationIO
2
- class Client
3
- class SyncOperation < BaseOperation
4
- class UpdateAndCollectPotFileStep
5
- def initialize(pot_path, source_files)
6
- @pot_path = pot_path
7
- @source_files = source_files + Dir['tmp/translation/*.rb']
8
- end
9
-
10
- def run(params)
11
- TranslationIO.info "Updating POT file."
12
-
13
- GetText::Tools::XGetText.run(*@source_files, '-o', @pot_path,
14
- '--msgid-bugs-address', TranslationIO.config.pot_msgid_bugs_address,
15
- '--package-name', TranslationIO.config.pot_package_name,
16
- '--package-version', TranslationIO.config.pot_package_version,
17
- '--copyright-holder', TranslationIO.config.pot_copyright_holder,
18
- '--copyright-year', TranslationIO.config.pot_copyright_year.to_s)
19
-
20
- params['pot_data'] = File.read(@pot_path)
21
- end
22
- end
23
- end
24
- end
25
- end