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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 211d87eb1540d27dba3ed74c5f3ab0489f84893b
4
- data.tar.gz: 611f40a2e50f1d4dac3e3a49f6c32a3054cef3b2
3
+ metadata.gz: a1eb0526aedea5961090b2d46dd620bf93c8ecab
4
+ data.tar.gz: 4b7051aece56792387f818b966d5db3a67979438
5
5
  SHA512:
6
- metadata.gz: ed78a710294ff7db0633e4fa9dcb7ab1c059568f668e489ecaac88a34909492683837078d0c7d0e1f233d4347b08ee30019efda481c55c5e607ba20b62a086c2
7
- data.tar.gz: 520c45d09e3e65ed2c3baef4e9efcb1f49c5745a855381a7ea515166dabeca34639277d4a1a192ca7becac33327d045512a81e0dd59b96c6d5cd323ffcd59cfe
6
+ metadata.gz: cd10d236fa6d9fe5f6a66ce8887fa5052bfa0a40dda202e923466b92b783d346580f6734eef308663b69d7b689141018d3ad18f440a1631e3cac1a4f28e8ae7e
7
+ data.tar.gz: 8f995eb12b31fb268ab60d7d27cda0816de7778f0e7ab45af513e18046b78e139140177c89b291271a751da7617c5398c46f56f5c942e34b70f6f17709f3f9dc
data/README.md CHANGED
@@ -1,7 +1,13 @@
1
- I18n::Cocoa
1
+ i18n::Cocoa
2
2
  ===========
3
3
 
4
- Manage translation and localization with static analysis, for iOS, OSX
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
- **Check health**
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(config.update attributes)
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.config
19
- {
20
- :localized_macro_string => 'NSLocalizedString',
21
- :search_path => '.'
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
@@ -6,11 +6,19 @@ module I18n
6
6
  class Finder
7
7
 
8
8
  def initialize attributes
9
- @localized_macro_string = attributes[:localized_macro_string]
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(attributes[:search_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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module I18n
4
4
  module Cocoa
5
- VERSION = "0.0.5"
5
+ VERSION = "0.0.6"
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.5
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: {}