i18n-cocoa 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -3
- data/lib/i18n/cocoa.rb +10 -6
- data/lib/i18n/cocoa/finder.rb +10 -2
- data/lib/i18n/cocoa/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1eb0526aedea5961090b2d46dd620bf93c8ecab
|
4
|
+
data.tar.gz: 4b7051aece56792387f818b966d5db3a67979438
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd10d236fa6d9fe5f6a66ce8887fa5052bfa0a40dda202e923466b92b783d346580f6734eef308663b69d7b689141018d3ad18f440a1631e3cac1a4f28e8ae7e
|
7
|
+
data.tar.gz: 8f995eb12b31fb268ab60d7d27cda0816de7778f0e7ab45af513e18046b78e139140177c89b291271a751da7617c5398c46f56f5c942e34b70f6f17709f3f9dc
|
data/README.md
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
-
|
1
|
+
i18n::Cocoa
|
2
2
|
===========
|
3
3
|
|
4
|
-
|
4
|
+
i18n-cocoa manages translation and localization with analysis, for iOS, OSX.
|
5
|
+
It helps you find to missing and unused localized strings in file.
|
6
|
+
|
7
|
+
Support languages
|
8
|
+
----------
|
9
|
+
|
10
|
+
Objective-C, Objective-C++, Swift
|
5
11
|
|
6
12
|
Installation
|
7
13
|
----------
|
@@ -23,19 +29,39 @@ Or install it yourself as:
|
|
23
29
|
Usage
|
24
30
|
----------
|
25
31
|
|
26
|
-
|
32
|
+
### Check health
|
33
|
+
|
34
|
+
`I18n::Cocoa.health` checks if any keys are missing or not used:
|
27
35
|
```ruby
|
36
|
+
require 'i18n/cocoa'
|
37
|
+
|
38
|
+
success, failure_issues = I18n::Cocoa.health
|
39
|
+
```
|
40
|
+
|
41
|
+
**Custom macro and specify directory**
|
42
|
+
```ruby
|
43
|
+
require 'i18n/cocoa'
|
28
44
|
|
29
45
|
attributes = {:localized_macro_string => 'LocalizedString', :search_path => 'iOSProject'}
|
30
46
|
success, failure_issues = I18n::Cocoa.health attributes
|
47
|
+
```
|
48
|
+
|
49
|
+
### Remove unused keys
|
31
50
|
|
51
|
+
`I18n::Cocoa.remove_unused` remove unused keys from `.strings` file if any keys are not used:
|
52
|
+
```ruby
|
53
|
+
require 'i18n/cocoa'
|
54
|
+
|
55
|
+
success, failure_issues = I18n::Cocoa.remove_unused
|
32
56
|
```
|
33
57
|
|
58
|
+
|
34
59
|
Features
|
35
60
|
----------
|
36
61
|
|
37
62
|
- [x] Ensure to not forget to add localized string literal with key in `.strings` files
|
38
63
|
- [x] Find to unused localizaed key in files and strip them from these files
|
64
|
+
- [ ] Output documentation
|
39
65
|
- [ ] Comprehensive Unit Test Coverage
|
40
66
|
|
41
67
|
Contributing
|
data/lib/i18n/cocoa.rb
CHANGED
@@ -8,18 +8,22 @@ module I18n
|
|
8
8
|
module Cocoa
|
9
9
|
|
10
10
|
def self.health attributes = {}
|
11
|
-
finder = Finder.new(
|
11
|
+
finder = Finder.new(attributes)
|
12
12
|
finder.ensure_localization
|
13
13
|
|
14
14
|
unused_keys = finder.find_unused_localization
|
15
15
|
finder.delete_localization_keys unless unused_keys.empty?
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
def self.unused attributes = {}
|
19
|
+
finder = Finder.new(attributes)
|
20
|
+
finder.find_unused_localization
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.remove_unused attributes = {}
|
24
|
+
finder = Finder.new(attributes)
|
25
|
+
unused_keys = finder.find_unused_localization
|
26
|
+
finder.delete_localization_keys unless unused_keys.empty?
|
23
27
|
end
|
24
28
|
|
25
29
|
end
|
data/lib/i18n/cocoa/finder.rb
CHANGED
@@ -6,11 +6,19 @@ module I18n
|
|
6
6
|
class Finder
|
7
7
|
|
8
8
|
def initialize attributes
|
9
|
-
|
9
|
+
config = default_config.update attributes
|
10
|
+
@localized_macro_string = config[:localized_macro_string]
|
10
11
|
@method_file_paths = []
|
11
12
|
@localized_file_paths = []
|
12
13
|
|
13
|
-
_search_file_paths File.absolute_path(
|
14
|
+
_search_file_paths File.absolute_path(config[:search_path])
|
15
|
+
end
|
16
|
+
|
17
|
+
def default_config
|
18
|
+
{
|
19
|
+
:localized_macro_string => 'NSLocalizedString',
|
20
|
+
:search_path => '.'
|
21
|
+
}
|
14
22
|
end
|
15
23
|
|
16
24
|
def ensure_localization
|
data/lib/i18n/cocoa/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hirohisa Kawasaki
|
@@ -69,7 +69,7 @@ files:
|
|
69
69
|
- spec/spec_helper.rb
|
70
70
|
- README.md
|
71
71
|
- LICENSE
|
72
|
-
homepage:
|
72
|
+
homepage: https://github.com/hirohisa/i18n-cocoa
|
73
73
|
licenses:
|
74
74
|
- MIT
|
75
75
|
metadata: {}
|