i18n-cocoa 0.0.1 → 0.0.2

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
2
  SHA1:
3
- metadata.gz: f66d36a153926975436d4239f13ccf052ca05164
4
- data.tar.gz: 7550e2a670addbc6bb7b23588dd6b9ed2e36e045
3
+ metadata.gz: cf33f6d55b0323e9fc5c980f82f3e59515ac2a50
4
+ data.tar.gz: c00f49d7b1c616a240b2885827389361f238837c
5
5
  SHA512:
6
- metadata.gz: 98aaec479882ec958d9609d8a2bc5c898bfe94c3c68523d860ec75f43982045ac074de0036a3554396df0c3f6725cfe018acd1ad70c07b41cd31f3ae1b37b88e
7
- data.tar.gz: 1ef90d411f124ce5b0c72f615875ed3a847870b98f67e2acc561cb3d1768b130b3c7550763d68c04777314d00b95d0f671e3770c6f50f996c389ddbe1aa01d2e
6
+ metadata.gz: eb33bc5501a7feb7ba5c11d68cdb76fec4d95864bc5a67af5a0eb72d87c828bc524978a77874be78892f23e1f0d04122d01312788585c800ae32284ac6ab430d
7
+ data.tar.gz: 7c092cad942b9e6825af738ab9c745b3b991ead3e28ab53d6a8b93553035579733a2d7739d2ab33ae4159f6cbcfa7011ae89a296b656297ce9f1152bd5427a15
@@ -9,7 +9,7 @@ module I18n
9
9
  def initialize localized_macro_string='NSLocalizedString'
10
10
  @localized_macro_string = localized_macro_string
11
11
  @method_file_paths = []
12
- @lozalized_file_paths = []
12
+ @localized_file_paths = []
13
13
 
14
14
  _search_file_paths File.absolute_path(".")
15
15
  end
@@ -33,43 +33,43 @@ module I18n
33
33
  [failure_issues.count == 0, failure_issues]
34
34
  end
35
35
 
36
- private
37
- def _search_file_paths directory_path
38
- Dir::foreach(directory_path) do |f|
39
- current_file_path = "#{directory_path}/#{f}"
36
+ private
37
+ def _search_file_paths directory_path
38
+ Dir::foreach(directory_path) do |f|
39
+ current_file_path = "#{directory_path}/#{f}"
40
40
 
41
- assort_with_extension current_file_path unless File.directory?current_file_path
41
+ assort_with_extension current_file_path unless File.directory?current_file_path
42
42
 
43
- _search_file_paths current_file_path if _need_to_search_in_directory? current_file_path
43
+ _search_file_paths current_file_path if _need_to_search_in_directory? current_file_path
44
+ end
44
45
  end
45
- end
46
46
 
47
- def assort_with_extension file_path
48
- return if File.directory?file_path
47
+ def assort_with_extension file_path
48
+ return if File.directory?file_path
49
49
 
50
- extension = file_path.split('.').last
51
- case extension
52
- when 'm', 'mm', 'swift'
53
- @method_file_paths << file_path
54
- when 'strings'
55
- @localized_file_paths << file_path
50
+ extension = file_path.split('.').last
51
+ case extension
52
+ when 'm', 'mm', 'swift'
53
+ @method_file_paths << file_path
54
+ when 'strings'
55
+ @localized_file_paths << file_path
56
+ end
56
57
  end
57
- end
58
58
 
59
- def _need_to_search_in_directory? file_path
60
- return false unless File.directory? file_path
59
+ def _need_to_search_in_directory? file_path
60
+ return false unless File.directory? file_path
61
61
 
62
- file_name = file_path.split('/').last
63
- return false if file_name.start_with?"." # '.', '..', '.git'
62
+ file_name = file_path.split('/').last
63
+ return false if file_name.start_with?"." # '.', '..', '.git'
64
64
 
65
- extension = file_name.split('.').last
66
- xcode_extensions = ['xcodeproj', 'xcassets', 'xcworkspace']
67
- return false if xcode_extensions.include?extension # directory for xcode
65
+ extension = file_name.split('.').last
66
+ xcode_extensions = ['xcodeproj', 'xcassets', 'xcworkspace']
67
+ return false if xcode_extensions.include?extension # directory for xcode
68
68
 
69
- # TODO: support Pods, Carthage
69
+ # TODO: support Pods, Carthage
70
70
 
71
- true
72
- end
71
+ true
72
+ end
73
73
 
74
74
  def _find_lines_using_variable_key_in_method_files
75
75
  lines = []
@@ -118,15 +118,16 @@ private
118
118
  def _get_localized_keys_from_strings_files
119
119
  keys = []
120
120
 
121
- @lozalized_file_paths.each do |file_path|
122
- f = File.new(path, "r")
121
+ @localized_file_paths.each do |file_path|
122
+ f = File.new(file_path, "r")
123
123
  f.readlines.each do |l|
124
+ l = Utils.encode l
124
125
  next if l.start_with?("//")
125
126
 
126
- match = /^"([^"]+)"[ ]*=[ ]*"([^"]+)";[\r\n]*$/.match(l)
127
- next if match.nil?
127
+ m = /^"([^"]+)"[ ]*=[ ]*"([^"]+)";[\r\n]*$/.match(l)
128
+ next if m.nil?
128
129
 
129
- keys << match[1] if match.size == 3
130
+ keys << m[1] if m.size == 3
130
131
  end
131
132
  end
132
133
 
@@ -5,8 +5,13 @@ module I18n
5
5
 
6
6
  def self.encode string
7
7
  # invalid byte sequence in US-ASCII (ArgumentError)
8
- string.force_encoding('UTF-8')
9
- string.encode("UTF-8", "UTF-8")
8
+ replace_invalid_byte string
9
+ end
10
+
11
+ def self.replace_invalid_byte string
12
+ replace_options = { invalid: :replace, undef: :replace, replace: '?' }
13
+ temporal_encoding = (string.encoding == Encoding::UTF_8 ? Encoding::UTF_16BE : Encoding::UTF_8)
14
+ string.encode(temporal_encoding, string.encoding, replace_options).encode(string.encoding)
10
15
  end
11
16
 
12
17
  def self.create_issue title, description
@@ -2,6 +2,6 @@
2
2
 
3
3
  module I18n
4
4
  module Cocoa
5
- VERSION = "0.0.1"
5
+ VERSION = "0.0.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-cocoa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hirohisa Kawasaki