translation 1.8.4 → 1.9

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: cc4d310a1304b751f3d62ee5163fd20afd5ae0bf
4
- data.tar.gz: 059d55d777d7e0672c3e826db523440c7665f7dc
3
+ metadata.gz: 4c393ed07bd2bf4db910f2b89540920d86da3244
4
+ data.tar.gz: f82f7acf41fb97eccdc42eca985b6ae2b2724d21
5
5
  SHA512:
6
- metadata.gz: 5476b81adeaaef13be180f18fc10aed9a006ca0f1b83aa453ea97f0c4ec7395779094a44debca5e06af75f1ad809c0ddbbab88a8806b55b15e397191910e5b2d
7
- data.tar.gz: 626d298948f5ff3df4d1a6fa2dd0e83d76b44702432881d787fd55ade97d0656ebaeb7b9260a84dec16c641d2bff60a2f01c3e8a54f563746b996a10f59e203b
6
+ metadata.gz: 32fd1caaa72d9de52a640323cd3337609fa09d92044f2cd4747203d272b50010afde2ee97547b606f86f94c0c8d6a2b192834efc8f18822cbdf19cb3d41b7479
7
+ data.tar.gz: d1bd9c545975c64e8095ed7b484c2776891f61a7fd48de357b6bcde257c5444e865372ce22ff6b616d999ef9b9f5a4d660616f38dac3cadb8fd210f96958f7bc
@@ -21,12 +21,29 @@ module TranslationIO
21
21
  file.puts " #{entry}"
22
22
  file.puts "end"
23
23
  end
24
+
25
+ # can happen sometimes if gettext parsing is wrong
26
+ if ruby_cmd_available?
27
+ remove_file_if_syntax_invalid(file_path, entry)
28
+ end
24
29
  end
25
30
  end
26
31
  end
27
32
 
28
33
  protected
29
34
 
35
+ def remove_file_if_syntax_invalid(file_path, entry)
36
+ if `ruby -c #{file_path} 2>/dev/null`.empty? # returns 'Syntax OK' if syntax valid
37
+ TranslationIO.info ""
38
+ TranslationIO.info "Warning - #{@markup_type.to_s.upcase} Gettext parsing failed: #{entry}"
39
+ TranslationIO.info " This entry will be ignored until you fix it. Please note that"
40
+ TranslationIO.info " this warning can sometimes be caused by complex interpolated strings."
41
+ TranslationIO.info ""
42
+
43
+ FileUtils.rm(file_path)
44
+ end
45
+ end
46
+
30
47
  def extracted_gettext_entries
31
48
  entries = []
32
49
 
@@ -41,6 +58,10 @@ module TranslationIO
41
58
 
42
59
  entries
43
60
  end
61
+
62
+ def ruby_cmd_available?
63
+ @ruby_cmd_available ||= `which ruby`.strip.length > 0
64
+ end
44
65
  end
45
66
  end
46
67
  end
@@ -46,6 +46,7 @@ module TranslationIO
46
46
  BaseOperation::CreateNewMoFilesStep.new(locales_path).run
47
47
 
48
48
  info_yaml_directory_structure
49
+ info_project_url(parsed_response)
49
50
  end
50
51
 
51
52
  cleanup
@@ -99,6 +100,14 @@ module TranslationIO
99
100
  puts "please check this article: https://translation.io/blog/dealing-with-yaml-files-and-their-directory-structure"
100
101
  puts "----------"
101
102
  end
103
+
104
+ def info_project_url(parsed_response)
105
+ puts
106
+ puts "----------"
107
+ puts "Use this URL to translate: #{parsed_response['project_url']}"
108
+ puts "Then use 'rake translation:sync' to send new keys to Translation.io and get new translations into your project."
109
+ puts "----------"
110
+ end
102
111
  end
103
112
  end
104
113
  end
@@ -39,10 +39,19 @@ module TranslationIO
39
39
  BaseOperation::CreateNewMoFilesStep.new(locales_path).run
40
40
  BaseOperation::SaveNewYamlFilesStep.new(target_locales, yaml_locales_path, parsed_response).run
41
41
  BaseOperation::SaveSpecialYamlFilesStep.new(source_locale, target_locales, yaml_locales_path, yaml_file_paths).run
42
+
43
+ info_project_url(parsed_response)
42
44
  end
43
45
 
44
46
  cleanup
45
47
  end
48
+
49
+ def info_project_url(parsed_response)
50
+ puts
51
+ puts "----------"
52
+ puts "Use this URL to translate: #{parsed_response['project_url']}"
53
+ puts "----------"
54
+ end
46
55
  end
47
56
  end
48
57
  end
@@ -10,9 +10,7 @@ module TranslationIO
10
10
  def run(params)
11
11
  TranslationIO.info "Downloading YAML source editions."
12
12
 
13
- timestamp = YAML::load(File.read(TranslationIO.config.metadata_path))['timestamp'] rescue 0
14
-
15
- params.merge!({ :timestamp => timestamp })
13
+ params.merge!({ :timestamp => metadata_timestamp })
16
14
  parsed_response = perform_source_edits_request(params)
17
15
 
18
16
  unless parsed_response.nil?
@@ -74,6 +72,21 @@ module TranslationIO
74
72
 
75
73
  private
76
74
 
75
+ def metadata_timestamp
76
+ if File.exist?(TranslationIO.config.metadata_path)
77
+ metadata_content = File.read(TranslationIO.config.metadata_path)
78
+
79
+ if metadata_content.include?('>>>>') || metadata_content.include?('<<<<')
80
+ TranslationIO.info "[Error] #{TranslationIO.config.metadata_path} file is corrupted and seems to have unresolved versioning conflicts. Please resolve them and try again."
81
+ exit
82
+ else
83
+ return YAML::load(metadata_content)['timestamp'] rescue 0
84
+ end
85
+ else
86
+ return 0
87
+ end
88
+ end
89
+
77
90
  def perform_source_edits_request(params)
78
91
  uri = URI("#{TranslationIO.client.endpoint}/projects/#{TranslationIO.client.api_key}/source_edits")
79
92
  parsed_response = BaseOperation.perform_request(uri, params)
@@ -65,7 +65,7 @@ module TranslationIO
65
65
  end
66
66
 
67
67
  def slim_source_files
68
- Dir['**/*.{slim}'].select do |p|
68
+ Dir['**/*.{slim,mjmlslim}'].select do |p|
69
69
  !p.start_with?('vendor/') && !p.start_with?('tmp/')
70
70
  end
71
71
  end
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.8.4
4
+ version: '1.9'
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: 2016-12-02 00:00:00.000000000 Z
12
+ date: 2017-02-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gettext
@@ -68,7 +68,7 @@ dependencies:
68
68
  - !ruby/object:Gem::Version
69
69
  version: '4.1'
70
70
  - !ruby/object:Gem::Dependency
71
- name: codeclimate-test-reporter
71
+ name: simplecov
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="
@@ -81,6 +81,20 @@ dependencies:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: codeclimate-test-reporter
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: 1.0.0
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: 1.0.0
84
98
  description: Rails translation made _("simple") with YAML and GetText. Localize your
85
99
  app using either t(".keys") or _("free text") and type "rake translation:sync" to
86
100
  synchronize with your translators.