i18n-tasks 0.6.1 → 0.6.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: 334c00605d3e55a82e36c72359bdf31a17bd54f2
4
- data.tar.gz: f0240ff3e7452b1509c18cc0b5c33f6eecd8b7ec
3
+ metadata.gz: f361cd15dc7c4dbe60aedba3245481fb4180b91e
4
+ data.tar.gz: 5c1fa95a09f2cf826c12eb913145f91e2906758a
5
5
  SHA512:
6
- metadata.gz: 53a6c2668b4a31bc8049b2c0b08ea4c76aa0e30e6740c83a70878820965a77efa8d47f2639407b21e8b306ea6a9e581c344933b484f737a650dd4f3df0991392
7
- data.tar.gz: 9a50045d591c8aa773e31e2223739eb814ab9010e8a7d6f9b603c76fe0bbd791c643ebbbd8acc1954eec3b241febefaf652a4f67a7514b59552dacaf68d2f9fb
6
+ metadata.gz: db244b5be78460bac7f310996b389fd71296a788509700d07ae86b2f4ac68e920b70dc1293febebba07e5b7871a4c4b42c3856ec042fdbd9e64d2a13a1e71624
7
+ data.tar.gz: 24a7dff3fb48aa9d4b8371143669a491d079bbffc1630a97964607627293b7ae70a9576d4dda4241dbf9b11f8eea44a6f1c7b697cb3c9910f28a77a9dbd54301
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.6.2
2
+
3
+ * New task to show locale data: `i18n-tasks data`
4
+ * New output format: `keys`, e.g. `i18n-tasks data -fkeys`
5
+ * Fix an issue with a top-level dynamic key breaking unused detection [#75](https://github.com/glebm/i18n-tasks/issues/75)
6
+ * Document [magic comment hints](https://github.com/glebm/i18n-tasks#fine-tuning)
7
+
1
8
  ## 0.6.1
2
9
 
3
10
  * Fix Google Translate issue with plural keys and missing billing info error
data/README.md CHANGED
@@ -11,14 +11,14 @@ It can also pre-fill missing keys, including from Google Translate, and it can r
11
11
 
12
12
  i18n-tasks can be used with any project using [i18n][i18n-gem] (default in Rails), or similar, even if it isn't ruby.
13
13
 
14
- <img width="534" height="288" src="https://raw.github.com/glebm/i18n-tasks/master/doc/img/i18n-tasks.png">
14
+ <img width="539" height="331" src="https://raw.github.com/glebm/i18n-tasks/master/doc/img/i18n-tasks.png">
15
15
 
16
16
  ## Installation
17
17
 
18
18
  Add to Gemfile:
19
19
 
20
20
  ```ruby
21
- gem 'i18n-tasks', '~> 0.6.0'
21
+ gem 'i18n-tasks', '~> 0.6.2'
22
22
  ```
23
23
 
24
24
 
@@ -267,8 +267,14 @@ See this basic [pattern scanner](/lib/i18n/tasks/scanners/pattern_scanner.rb) fo
267
267
 
268
268
  ### Fine-tuning
269
269
 
270
- Tasks may incorrectly report framework i18n keys as missing, also some patterns may not be detected.
271
- When all else fails, use the options below.
270
+ Add hints to static analysis with magic comment hints (lines starting with `(#|/) i18n-tasks-use` by default):
271
+
272
+ ```ruby
273
+ # i18n-tasks-use t('activerecord.models.user') # let i18n-tasks know the key is used
274
+ User.model_name.human
275
+ ```
276
+
277
+ You can also explicitly ignore keys appearing in locale files:
272
278
 
273
279
  ```yaml
274
280
  # config/i18n-tasks.yml
data/i18n-tasks.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.version = I18n::Tasks::VERSION
9
9
  s.authors = ['glebm']
10
10
  s.email = ['glex.spb@gmail.com']
11
- s.summary = %q{Manage translations in ruby applications with the awesome power of static analysis — Edit}
11
+ s.summary = %q{Manage localization and translation with the awesome power of static analysis}
12
12
  s.description = %q{
13
13
  i18n-tasks helps you find and manage missing and unused translations.
14
14
 
@@ -17,7 +17,7 @@ module I18n::Tasks
17
17
  },
18
18
  format: proc {
19
19
  on '-f', :format=,
20
- 'Format: terminal-table, terminal-tree, json, yaml. Default: terminal-table.',
20
+ "Output format: #{VALID_TREE_FORMATS * ', '}. Default: terminal-table.",
21
21
  {default: 'terminal-table', argument: true, optional: false}
22
22
  }
23
23
  }
@@ -61,6 +61,15 @@ module I18n::Tasks
61
61
  print_locale_tree i18n.used_tree(key_filter: opt[:filter].presence, source_locations: true), opt, :used_keys
62
62
  end
63
63
 
64
+ desc 'show locale data'
65
+ opts do
66
+ instance_exec &OPT[:locale]
67
+ instance_exec &OPT[:format]
68
+ end
69
+ cmd :data do |opt = {}|
70
+ parse_locales! opt
71
+ print_locale_tree i18n.data_forest(opt[:locales]), opt
72
+ end
64
73
 
65
74
  desc 'translate missing keys with Google Translate'
66
75
  opts do
@@ -27,7 +27,7 @@ module I18n::Tasks
27
27
  end
28
28
 
29
29
 
30
- VALID_TREE_FORMATS = %w(terminal-table yaml json inspect)
30
+ VALID_TREE_FORMATS = %w(terminal-table yaml json keys inspect)
31
31
 
32
32
  def print_locale_tree(tree, opt, version = :show_tree)
33
33
  format = opt[:format] || VALID_TREE_FORMATS.first
@@ -37,7 +37,9 @@ module I18n::Tasks
37
37
  terminal_report.send(version, tree)
38
38
  when 'inspect'
39
39
  puts tree.inspect
40
- else
40
+ when 'keys'
41
+ puts tree.key_names(root: true)
42
+ when *i18n.data.adapter_names.map(&:to_s)
41
43
  puts i18n.data.adapter_dump tree, i18n.data.adapter_by_name(format)
42
44
  end
43
45
  end
@@ -17,6 +17,12 @@ module I18n::Tasks
17
17
  end
18
18
  end
19
19
 
20
+ def data_forest(locales = self.locales)
21
+ locales.inject(Tree::Siblings.new) do |tree, locale|
22
+ tree.merge! data[locale]
23
+ end
24
+ end
25
+
20
26
  def t(key, locale = base_locale)
21
27
  data.t(key, locale)
22
28
  end
@@ -17,6 +17,10 @@ module I18n
17
17
  self.class.adapter_by_name(path)
18
18
  end
19
19
 
20
+ def adapter_names
21
+ self.class.adapter_names
22
+ end
23
+
20
24
  def adapter_dump(tree, adapter_info)
21
25
  adapter_name, adapter_pattern, adapter = adapter_info
22
26
  adapter_options = (config[adapter_name] || {})[:write]
@@ -51,6 +55,10 @@ module I18n
51
55
  } or raise CommandError.new("Adapter not found for #{path}. Registered adapters: #{@fn_patterns.inspect}")
52
56
  end
53
57
 
58
+ def adapter_names
59
+ @fn_patterns.map(&:first)
60
+ end
61
+
54
62
  def adapter_by_name(name)
55
63
  name = name.to_s
56
64
  @fn_patterns.detect { |(adapter_name, _pattern, _adapter)|
@@ -33,7 +33,7 @@ module I18n::Tasks::KeyPatternMatching
33
33
  def key_match_pattern(k)
34
34
  @key_match_pattern ||= {}
35
35
  @key_match_pattern[k] ||= begin
36
- "#{k.gsub(KEY_INTERPOLATION_RE, '*')}#{'*' if k.end_with?('.')}"
36
+ "#{k.gsub(KEY_INTERPOLATION_RE, ':')}#{':' if k.end_with?('.')}"
37
37
  end
38
38
  end
39
39
 
@@ -44,7 +44,12 @@ module I18n::Tasks
44
44
  # keys in the source that end with a ., e.g. t("category.#{cat.i18n_key}") or t("category." + category.key)
45
45
  def expr_key_re
46
46
  @expr_key_re ||= begin
47
- patterns = used_key_names.select { |k| key_expression?(k) }.map { |k| key_match_pattern(k) }
47
+ patterns = used_key_names.select { |k| key_expression?(k) }.map { |k|
48
+ pattern = key_match_pattern(k)
49
+ # disallow patterns with no keys
50
+ next if pattern =~ /\A(:\.)*:\z/
51
+ pattern
52
+ }.compact
48
53
  compile_key_pattern "{#{patterns * ','}}"
49
54
  end
50
55
  end
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
  module I18n
3
3
  module Tasks
4
- VERSION = '0.6.1'
4
+ VERSION = '0.6.2'
5
5
  end
6
6
  end
@@ -1,4 +1,4 @@
1
- # i18n-tasks find and manage missing and unused translations ⚙ https://github.com/glebm/i18n-tasks
1
+ # i18n-tasks finds and manages missing and unused translations ⚙ https://github.com/glebm/i18n-tasks
2
2
 
3
3
  base_locale: en
4
4
  ## i18n-tasks detects locales automatically from the existing locale files
@@ -60,6 +60,11 @@ search:
60
60
  # ignore_lines:
61
61
  # - "^\\s*[#/](?!\\si18n-tasks-use)"
62
62
 
63
+ ## Google Translate
64
+ # translation:
65
+ # # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate
66
+ # api_key: "AbC-dEf5"
67
+
63
68
  ## Consider these keys not missing
64
69
  # ignore_missing:
65
70
  # - pagination.views.*
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-17 00:00:00.000000000 Z
11
+ date: 2014-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubis
@@ -292,8 +292,7 @@ rubyforge_project:
292
292
  rubygems_version: 2.2.2
293
293
  signing_key:
294
294
  specification_version: 4
295
- summary: Manage translations in ruby applications with the awesome power of static
296
- analysis — Edit
295
+ summary: Manage localization and translation with the awesome power of static analysis
297
296
  test_files:
298
297
  - spec/conservative_router_spec.rb
299
298
  - spec/file_system_data_spec.rb