babelyoda 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,6 +10,10 @@ module Babelyoda
10
10
  @values = {}
11
11
  end
12
12
 
13
+ def to_s
14
+ "\"#{@id}\" [#{@values.keys.map{|k| ":#{k.to_s}"}.join(', ')}] // #{@context}"
15
+ end
16
+
13
17
  def <<(localization_value)
14
18
  @values[localization_value.language.to_sym] = localization_value.dup
15
19
  self
@@ -7,8 +7,8 @@ module Babelyoda
7
7
  def exe(cmd) ; putcmd cmd ; system cmd ; end
8
8
  def putcmd(cmd) ; print magenta, "CMD: #{cmd}", reset, "\n" ; end
9
9
  def status(msg) ; print blue, "--- #{msg} ---", reset, "\n" ; end
10
- def success(msg) ; print green, bold, 'SUCCESS: ', msg, reset, "\n" ; end
11
- def error(msg) ; print red, bold, 'ERROR: ', msg, reset, "\n" ; exit 1 ; end
10
+ def success(msg, heading = true) ; print green, bold, (heading ? 'SUCCESS: ' : ''), msg, reset, "\n" ; end
11
+ def error(msg, heading = true, do_exit = true) ; print red, bold, (heading ? 'ERROR: ' : ''), msg, reset, "\n" ; exit 1 if do_exit; end
12
12
  def escape_cmd_args(args) ; args.collect{ |arg| "'#{arg}'"}.join(' ') ; end
13
13
  end
14
14
  end
@@ -1,5 +1,6 @@
1
1
  require 'rchardet19'
2
2
 
3
+ require_relative 'file'
3
4
  require_relative 'keyset'
4
5
  require_relative 'strings_lexer'
5
6
  require_relative 'strings_parser'
@@ -20,8 +21,9 @@ module Babelyoda
20
21
  end
21
22
 
22
23
  def read
23
- if File.exist?(@filename)
24
- File.open(@filename, read_mode) do |f|
24
+ localized_filename = File.localized(@filename, @language)
25
+ if File.exist?(localized_filename)
26
+ File.open(localized_filename, read_mode) do |f|
25
27
  lexer = StringsLexer.new
26
28
  parser = StringsParser.new(lexer, @language)
27
29
  parser.parse(f.read) do |localization_key|
@@ -56,6 +58,7 @@ module Babelyoda
56
58
  cd = CharDet.detect(File.read(@filename))
57
59
  encoding_str = Encoding.aliases[cd.encoding] || cd.encoding
58
60
  encoding_str = 'UTF-8' if encoding_str == 'utf-8'
61
+ encoding_str = 'UTF-8' if encoding_str == 'ascii'
59
62
  if (encoding_str != "UTF-8")
60
63
  "rb:#{encoding_str}:UTF-8"
61
64
  else
@@ -36,7 +36,8 @@ module Babelyoda
36
36
  context &&= context.text
37
37
  result = self.new(node[:id], context)
38
38
  node.css('value').each do |value_node|
39
- result << Babelyoda::LocalizationValue.parse_xml(value_node)
39
+ value = Babelyoda::LocalizationValue.parse_xml(value_node)
40
+ result << value if value
40
41
  end
41
42
  result
42
43
  end
@@ -44,7 +45,9 @@ module Babelyoda
44
45
 
45
46
  class LocalizationValue
46
47
  def self.parse_xml(node)
47
- self.new(node[:language], node.text, node[:status])
48
+ if node.text.length > 0
49
+ self.new(node[:language], node.text, node[:status])
50
+ end
48
51
  end
49
52
  end
50
53
 
@@ -1,3 +1,3 @@
1
1
  module Babelyoda
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
data/lib/babelyoda.rb CHANGED
@@ -121,7 +121,7 @@ namespace :babelyoda do
121
121
  spec.scm.transaction("[Babelyoda] Merge in remote translations") do
122
122
  spec.strings_files.each do |filename|
123
123
  keyset_name = Babelyoda::Keyset.keyset_name(filename)
124
- remote_keyset = spec.engine.load_keyset(keyset_name, nil, :unapproved, true)
124
+ remote_keyset = spec.engine.load_keyset(keyset_name, nil, :unapproved)
125
125
  remote_keyset.drop_empty!
126
126
  spec.all_languages.each do |language|
127
127
  keyset_filename = strings_filename(keyset_name, language)
@@ -158,27 +158,36 @@ namespace :babelyoda do
158
158
  task :pull => [:fetch_strings, :localize_xibs] do
159
159
  end
160
160
 
161
- # desc "Verifies all local translations are present"
162
- # task :verify do
163
- # combined_keyset = Babelyoda::Keyset.new('babelyoda.verify')
164
- # spec.strings_files.each do |filename|
165
- # dev_lang_strings = Babelyoda::Strings.new(filename, spec.development_language).read
166
- # combined_keyset.merge!(dev_lang_strings)
167
- # spec.localization_languages.each do |language|
168
- # lang_strings = Babelyoda::Strings.new(filename, language).read
169
- # combined_keyset.merge!(lang_strings)
170
- # end
171
- # end
172
- # puts "TOTAL KEYS: #{combined_keyset}"
173
- # missing = {}
174
- # spec.localization_languages.each do |language|
175
- # missing[language] = Babelyoda::Keyset.new('babelyoda.verify.' + language)
176
- # end
177
- # puts "MISSING KEYS:"
178
- # spec.localization_languages.each do |language|
179
- # puts " #{language}: #{missing}"
180
- # end
181
- # end
161
+ desc "Verifies all local translations are present"
162
+ task :verify do
163
+ combined_keyset = Babelyoda::Keyset.new('babelyoda.verify')
164
+ spec.strings_files.each do |filename|
165
+ dev_lang_strings = Babelyoda::Strings.new(filename, spec.development_language).read
166
+ combined_keyset.merge!(dev_lang_strings)
167
+ spec.localization_languages.each do |language|
168
+ lang_strings = Babelyoda::Strings.new(filename, language).read
169
+ combined_keyset.merge!(lang_strings)
170
+ end
171
+ end
172
+ $logger.success("#{spec.development_language}: #{combined_keyset.keys.size} keys", false)
173
+ missing = {}
174
+ spec.localization_languages.each do |language|
175
+ missing[language] = Babelyoda::Keyset.new("babelyoda.verify.#{language}")
176
+ end
177
+ combined_keyset.drop_empty!
178
+ combined_keyset.keys.each_value do |key|
179
+ spec.localization_languages.each do |lang|
180
+ missing[lang.to_sym].merge_key!(key) unless key.values.has_key?(lang.to_sym)
181
+ end
182
+ end
183
+ total_missing_count = 0
184
+ spec.localization_languages.each do |language|
185
+ count = missing[language].keys.size
186
+ total_missing_count += count
187
+ $logger.error("#{language}: #{combined_keyset.keys.size - count} keys (#{count} translations missing)", false, false) if count > 0
188
+ end
189
+ exit 1 if total_missing_count > 0
190
+ end
182
191
 
183
192
  namespace :remote do
184
193
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: babelyoda
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-01-19 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70248372389060 !ruby/object:Gem::Requirement
16
+ requirement: &70131405357940 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: 2.8.0
25
25
  type: :development
26
26
  prerelease: false
27
- version_requirements: *70248372389060
27
+ version_requirements: *70131405357940
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: awesome_print
30
- requirement: &70248372387200 !ruby/object:Gem::Requirement
30
+ requirement: &70131405354760 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ~>
@@ -38,10 +38,10 @@ dependencies:
38
38
  version: 1.0.2
39
39
  type: :runtime
40
40
  prerelease: false
41
- version_requirements: *70248372387200
41
+ version_requirements: *70131405354760
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rake
44
- requirement: &70248372385200 !ruby/object:Gem::Requirement
44
+ requirement: &70131405344240 !ruby/object:Gem::Requirement
45
45
  none: false
46
46
  requirements:
47
47
  - - ~>
@@ -52,10 +52,10 @@ dependencies:
52
52
  version: 0.9.2.2
53
53
  type: :runtime
54
54
  prerelease: false
55
- version_requirements: *70248372385200
55
+ version_requirements: *70131405344240
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: active_support
58
- requirement: &70248372381080 !ruby/object:Gem::Requirement
58
+ requirement: &70131405341480 !ruby/object:Gem::Requirement
59
59
  none: false
60
60
  requirements:
61
61
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 3.0.0
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *70248372381080
69
+ version_requirements: *70131405341480
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rchardet19
72
- requirement: &70248372378460 !ruby/object:Gem::Requirement
72
+ requirement: &70131405339840 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
@@ -80,10 +80,10 @@ dependencies:
80
80
  version: 1.3.5
81
81
  type: :runtime
82
82
  prerelease: false
83
- version_requirements: *70248372378460
83
+ version_requirements: *70131405339840
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: builder
86
- requirement: &70248372376260 !ruby/object:Gem::Requirement
86
+ requirement: &70131405328400 !ruby/object:Gem::Requirement
87
87
  none: false
88
88
  requirements:
89
89
  - - ~>
@@ -94,10 +94,10 @@ dependencies:
94
94
  version: 3.0.0
95
95
  type: :runtime
96
96
  prerelease: false
97
- version_requirements: *70248372376260
97
+ version_requirements: *70131405328400
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: nokogiri
100
- requirement: &70248372375060 !ruby/object:Gem::Requirement
100
+ requirement: &70131405327320 !ruby/object:Gem::Requirement
101
101
  none: false
102
102
  requirements:
103
103
  - - ~>
@@ -108,10 +108,10 @@ dependencies:
108
108
  version: 1.5.0
109
109
  type: :runtime
110
110
  prerelease: false
111
- version_requirements: *70248372375060
111
+ version_requirements: *70131405327320
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: term-ansicolor
114
- requirement: &70248372373400 !ruby/object:Gem::Requirement
114
+ requirement: &70131405326220 !ruby/object:Gem::Requirement
115
115
  none: false
116
116
  requirements:
117
117
  - - ~>
@@ -122,7 +122,7 @@ dependencies:
122
122
  version: 1.0.7
123
123
  type: :runtime
124
124
  prerelease: false
125
- version_requirements: *70248372373400
125
+ version_requirements: *70131405326220
126
126
  description: A simple utility to push/pull l10n resources of an Xcode project to/from
127
127
  the translators
128
128
  email:
@@ -172,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
172
  version: '0'
173
173
  segments:
174
174
  - 0
175
- hash: -4332337468175115437
175
+ hash: -1710872162034708641
176
176
  required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  none: false
178
178
  requirements:
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  segments:
183
183
  - 0
184
- hash: -4332337468175115437
184
+ hash: -1710872162034708641
185
185
  requirements: []
186
186
  rubyforge_project: babelyoda
187
187
  rubygems_version: 1.8.10