i18n-cocoa 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/i18n/cocoa/finder.rb +6 -9
- data/lib/i18n/cocoa/utils.rb +11 -2
- data/lib/i18n/cocoa/version.rb +1 -1
- data/lib/i18n/cocoa.rb +9 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fb89f4fc53709c2d624e976a3284b20e6946387
|
4
|
+
data.tar.gz: 4dc100da833def9078cc5f3ff16bd166dfcf1ec1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d5a4582799d1018027ca73f2c0807cebf7c80c76803109d2ecd9f3efbfe6172e4a51651650e5a0e008c2ba49fb46399934595e2188e0b2537d7bc462f362230
|
7
|
+
data.tar.gz: 3520e52f7973b64a405ae2780de1eff0737d728828bd803aa8294d7e980f863dfb6a8dea1fcf5fa55aace35cf69f9df0f444e95f27f6f0e5b2ef5d6393b94b45
|
data/lib/i18n/cocoa/finder.rb
CHANGED
@@ -1,34 +1,31 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require 'pp'
|
3
2
|
|
4
3
|
module I18n
|
5
4
|
module Cocoa
|
6
5
|
|
7
6
|
class Finder
|
8
7
|
|
9
|
-
def initialize
|
10
|
-
@localized_macro_string = localized_macro_string
|
8
|
+
def initialize attributes
|
9
|
+
@localized_macro_string = attributes[:localized_macro_string]
|
11
10
|
@method_file_paths = []
|
12
11
|
@localized_file_paths = []
|
13
12
|
|
14
|
-
_search_file_paths File.absolute_path(
|
13
|
+
_search_file_paths File.absolute_path(attributes[:search_path])
|
15
14
|
end
|
16
15
|
|
17
16
|
def ensure_localization
|
18
17
|
failure_issues = []
|
19
18
|
|
20
19
|
# use variable key for localization
|
21
|
-
|
22
|
-
|
23
|
-
failure_issues << Utils.create_issue("found to set varible keys with logic", l)
|
24
|
-
end
|
20
|
+
lines = _find_lines_using_variable_key_in_method_files
|
21
|
+
failure_issues << Utils.create_issue("found to set varible keys with logic", lines) if lines.count > 0
|
25
22
|
|
26
23
|
# use localized key but key doesnt exist in strings file
|
27
24
|
used_keys = _get_used_localized_keys_from_method_files
|
28
25
|
localized_keys = _get_localized_keys_from_strings_files
|
29
26
|
|
30
27
|
forgot_keys = _contain_keys_in_localized_keys used_keys, localized_keys
|
31
|
-
failure_issues << Utils.create_issue("found to forget keys", forgot_keys
|
28
|
+
failure_issues << Utils.create_issue("found to forget keys", forgot_keys) if forgot_keys.count > 0
|
32
29
|
|
33
30
|
[failure_issues.count == 0, failure_issues]
|
34
31
|
end
|
data/lib/i18n/cocoa/utils.rb
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
module I18n
|
2
2
|
module Cocoa
|
3
3
|
|
4
|
+
class Issue
|
5
|
+
attr_reader :description, :values
|
6
|
+
|
7
|
+
def initialize description, values
|
8
|
+
@description = description
|
9
|
+
@values = values
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
4
13
|
module Utils
|
5
14
|
|
6
15
|
def self.encode string
|
@@ -14,8 +23,8 @@ module I18n
|
|
14
23
|
string.encode(temporal_encoding, string.encoding, replace_options).encode(string.encoding)
|
15
24
|
end
|
16
25
|
|
17
|
-
def self.create_issue
|
18
|
-
|
26
|
+
def self.create_issue description, values
|
27
|
+
Issue.new description, values
|
19
28
|
end
|
20
29
|
end
|
21
30
|
end
|
data/lib/i18n/cocoa/version.rb
CHANGED
data/lib/i18n/cocoa.rb
CHANGED
@@ -7,10 +7,17 @@ require "i18n/cocoa/finder"
|
|
7
7
|
module I18n
|
8
8
|
module Cocoa
|
9
9
|
|
10
|
-
def self.health
|
11
|
-
finder = Finder.new
|
10
|
+
def self.health attributes = {}
|
11
|
+
finder = Finder.new(config.update attributes)
|
12
12
|
finder.ensure_localization
|
13
13
|
end
|
14
14
|
|
15
|
+
def self.config
|
16
|
+
{
|
17
|
+
:localized_macro_string => 'NSLocalizedString',
|
18
|
+
:search_path => '.'
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
15
22
|
end
|
16
23
|
end
|