i18n-tasks 0.2.4 → 0.2.5

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: e0c21ea7a7fb96f56cb630dda06c0fe3e1ad8429
4
- data.tar.gz: 837023040b812540446e4ecf8f3f192a6a896339
3
+ metadata.gz: 4b6ca864b87be5f8d5c8a1c6be42ebe3c4c4ec3c
4
+ data.tar.gz: 41133bde7863a0b57c9d14889ea4d56846c0c543
5
5
  SHA512:
6
- metadata.gz: b88f3ea402af1fcb94388afbd31da4ba9e19077ed464fb023cbc9a825db5d24358bcd418d3b0e3c76c293541debe7bc2b8e7eef9006efd48e9c4653a3ac41481
7
- data.tar.gz: 0acb8e5a56d3386a108ab518c31430d76c81c38496296d304d1b213a33fa351ad337efed14a215405d69047178cd3dd4ecdaa713c2e9d4128b4c4d171905b088
6
+ metadata.gz: 583ff94e1c15d0946de46f2dcf4a20ab9ea348a2f4ce9b60feabfbbd6e5123ae0e0fb9860c4fda7481ff5b60ab7011103cd67b646673395c16cf37dac8bf3827
7
+ data.tar.gz: 0d40adb4b4d03cd123aa9e099a65784fbf936da6eaaa780fa6dd1e936c769aeb5932cdc124b699f801200f11d283bba8d69b10814ffd8589cc39bc8372a8fef4
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # i18n-tasks [![Build Status](https://travis-ci.org/glebm/i18n-tasks.png?branch=master)](https://travis-ci.org/glebm/i18n-tasks) [![Coverage Status](https://coveralls.io/repos/glebm/i18n-tasks/badge.png?branch=master)](https://coveralls.io/r/glebm/i18n-tasks?branch=master) [![Code Climate](https://codeclimate.com/github/glebm/i18n-tasks.png)](https://codeclimate.com/github/glebm/i18n-tasks)
2
2
 
3
3
 
4
- Tasks to manage translations in Rails.
4
+ Tasks to manage translations in ruby applications using I18n.
5
5
 
6
6
  ![i18n-screenshot](https://raw.github.com/glebm/i18n-tasks/master/doc/img/i18n-tasks.gif "i18n-tasks output screenshot")
7
7
 
@@ -10,6 +10,7 @@ Tasks to manage translations in Rails.
10
10
  Use `rake -T i18n` to get the list of tasks with descriptions. These are [the tasks](/lib/tasks/i18n-tasks.rake) available:
11
11
 
12
12
  There are reports for missing and unused translations:
13
+
13
14
  ```bash
14
15
  rake i18n:missing
15
16
  rake i18n:unused
@@ -20,6 +21,7 @@ rake i18n:spreadsheet_report
20
21
  i18n-tasks can add missing keys to the locale data, and it can also fill untranslated values.
21
22
 
22
23
  To add the keys that are not in the base locale but detected in the source do:
24
+
23
25
  ```bash
24
26
  # add missing keys to the base locale data (I18n.default_locale)
25
27
  # values set to key.humanize
@@ -29,11 +31,13 @@ rake i18n:add_missing[OhNoesMissing]
29
31
  ```
30
32
 
31
33
  Add blank yaml keys - `key: ''` for all missing and untranslated keys:
34
+
32
35
  ```bash
33
36
  rake i18n:fill:blanks
34
37
  ```
35
38
 
36
39
  Prefill empty translations using Google Translate:
40
+
37
41
  ```bash
38
42
  rake i18n:fill:google_translate
39
43
  # this task and the ones below can also accept specific locales:
@@ -45,6 +49,7 @@ rake i18n:fill:base_value
45
49
  ```
46
50
 
47
51
  i18n-tasks sorts the keys and writes them to their respective files:
52
+
48
53
  ```bash
49
54
  # this happens automatically on any i18n:fill:* task
50
55
  rake i18n:normalize
@@ -68,7 +73,14 @@ For more examples see [the tests](/spec/i18n_tasks_spec.rb).
68
73
  Simply add to Gemfile:
69
74
 
70
75
  ```ruby
71
- gem 'i18n-tasks', '~> 0.2.3'
76
+ gem 'i18n-tasks', '~> 0.2.5'
77
+ ```
78
+
79
+ If you do not use Rails, you will also need to require the tasks in your Rakefile:
80
+
81
+ ```ruby
82
+ # Rakefile
83
+ load 'tasks/i18n-tasks.rake'
72
84
  ```
73
85
 
74
86
  ## Configuration
@@ -172,6 +184,31 @@ ignore:
172
184
  - kaminari.*
173
185
  ```
174
186
 
187
+ ## RSpec integration
188
+
189
+ You might want to test for missing and unused translations as part of your test suite.
190
+ This is how you can do it with rspec:
191
+
192
+ ```ruby
193
+ # spec_helper.rb
194
+ require 'i18n/tasks'
195
+ require 'i18n/tasks/base_task'
196
+
197
+ # spec/locales_spec.rb
198
+ require 'spec_helper'
199
+ describe 'translations' do
200
+ let(:i18n) { I18n::Tasks::BaseTask.new }
201
+
202
+ it 'are all used' do
203
+ i18n.unused_keys.should have(0).keys
204
+ end
205
+
206
+ it 'are all present' do
207
+ i18n.untranslated_keys.should have(0).keys
208
+ end
209
+ end
210
+ ```
211
+
175
212
  ## HTML report
176
213
 
177
214
  While i18n-tasks does not provide an HTML version of the report, it's easy to roll your own, see [the example](https://gist.github.com/glebm/6887030).
@@ -3,32 +3,33 @@ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'i18n/tasks/version'
5
5
 
6
- Gem::Specification.new do |spec|
7
- spec.name = 'i18n-tasks'
8
- spec.version = I18n::Tasks::VERSION
9
- spec.authors = ['glebm']
10
- spec.email = ['glex.spb@gmail.com']
11
- spec.summary = %q{Tasks to manage missing and unused translations in Rails.}
12
- spec.description = %q{
6
+ Gem::Specification.new do |s|
7
+ s.name = 'i18n-tasks'
8
+ s.version = I18n::Tasks::VERSION
9
+ s.authors = ['glebm']
10
+ s.email = ['glex.spb@gmail.com']
11
+ s.summary = %q{Tasks to manage missing and unused translations in ruby applications using I18n.}
12
+ s.description = %q{
13
13
  rake tasks to find unused and missing translations, normalize locale files,
14
14
  and prefill missing keys. Supports relative and plural keys and Google Translate.
15
15
  }
16
- spec.homepage = 'https://github.com/glebm/i18n-tasks'
17
- spec.license = 'MIT'
16
+ s.homepage = 'https://github.com/glebm/i18n-tasks'
17
+ s.metadata = { 'issue_tracker' => 'https://github.com/glebm/i18n-tasks' }
18
+ s.license = 'MIT'
18
19
 
19
- spec.files = `git ls-files`.split($/) - %w(doc/img/i18n-tasks.gif)
20
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
- spec.require_paths = ['lib']
20
+ s.files = `git ls-files`.split($/) - %w(doc/img/i18n-tasks.gif)
21
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
23
+ s.require_paths = ['lib']
23
24
 
24
- spec.add_dependency 'rake'
25
- spec.add_dependency 'activesupport'
26
- spec.add_dependency 'easy_translate'
27
- spec.add_dependency 'term-ansicolor'
28
- spec.add_dependency 'terminal-table'
29
- spec.add_development_dependency 'axlsx', '~> 2.0'
30
- spec.add_development_dependency 'bundler', '~> 1.3'
31
- spec.add_development_dependency 'rake'
32
- spec.add_development_dependency 'rspec-rails'
33
- spec.add_development_dependency 'yard'
25
+ s.add_dependency 'rake'
26
+ s.add_dependency 'activesupport'
27
+ s.add_dependency 'easy_translate'
28
+ s.add_dependency 'term-ansicolor'
29
+ s.add_dependency 'terminal-table'
30
+ s.add_development_dependency 'axlsx', '~> 2.0'
31
+ s.add_development_dependency 'bundler', '~> 1.3'
32
+ s.add_development_dependency 'rake'
33
+ s.add_development_dependency 'rspec-rails'
34
+ s.add_development_dependency 'yard'
34
35
  end
@@ -1,10 +1,10 @@
1
1
  require 'i18n/tasks/version'
2
- require 'i18n/tasks/railtie'
3
2
  require 'active_support/core_ext/hash'
4
3
  require 'active_support/core_ext/string'
5
4
  require 'active_support/core_ext/module/delegation'
6
5
  require 'active_support/core_ext/object/try'
7
6
  require 'term/ansicolor'
7
+ require 'i18n/tasks/railtie' if defined?(Rails)
8
8
 
9
9
  module I18n
10
10
  module Tasks
@@ -1,5 +1,5 @@
1
1
  module I18n::Tasks::Configuration
2
- extend ActiveSupport::Concern
2
+ extend ::ActiveSupport::Concern
3
3
 
4
4
  # i18n-tasks config (defaults + config/i18n-tasks.yml)
5
5
  # @return [Hash{String => String,Hash,Array}]
@@ -1,5 +1,7 @@
1
1
  require 'i18n/tasks/data_traversal'
2
2
  require 'i18n/tasks/key_pattern_matching'
3
+ require 'yaml'
4
+
3
5
  module I18n::Tasks
4
6
  module Data
5
7
  class Yaml
@@ -29,7 +31,6 @@ module I18n::Tasks
29
31
  }
30
32
  @locale_data = {}
31
33
  end
32
- attr_reader :config
33
34
 
34
35
  # get locale tree
35
36
  def get(locale)
@@ -68,4 +69,4 @@ module I18n::Tasks
68
69
  alias []= set
69
70
  end
70
71
  end
71
- end
72
+ end
@@ -1,10 +1,12 @@
1
- require 'rails'
2
1
  module I18n
3
2
  module Tasks
4
3
  class Railtie < ::Rails::Railtie
5
- rake_tasks {
4
+ rake_tasks do
6
5
  load 'tasks/i18n-tasks.rake'
7
- }
6
+ namespace :i18n do
7
+ task :setup => 'environment'
8
+ end
9
+ end
8
10
  end
9
11
  end
10
12
  end
@@ -1,5 +1,5 @@
1
1
  module I18n
2
2
  module Tasks
3
- VERSION = '0.2.4'
3
+ VERSION = '0.2.5'
4
4
  end
5
5
  end
@@ -1,10 +1,14 @@
1
1
  require 'set'
2
+ require 'i18n/tasks'
2
3
  require 'i18n/tasks/base_task'
3
4
  require 'i18n/tasks/reports/terminal'
4
5
  require 'active_support/core_ext/module/delegation'
5
6
  require 'i18n/tasks/reports/spreadsheet'
6
7
 
7
8
  namespace :i18n do
9
+ task :setup do
10
+ end
11
+
8
12
  desc 'show missing translations'
9
13
  task :missing => 'i18n:setup' do
10
14
  i18n_report.missing_translations
@@ -57,13 +61,6 @@ namespace :i18n do
57
61
  end
58
62
  end
59
63
 
60
- task 'i18n:setup' => :environment do
61
- if File.exists?('.i18nignore')
62
- I18n::Tasks.warn_deprecated "Looks like you are using .i18ignore. It is no longer used in favour of config/i18n-tasks.yml.\n
63
- See README.md https://github.com/glebm/i18n-tasks"
64
- end
65
- end
66
-
67
64
  module ::I18n::Tasks::RakeHelpers
68
65
  include Term::ANSIColor
69
66
 
@@ -2,3 +2,7 @@ task :environment do
2
2
  I18n.default_locale = 'en'
3
3
  I18n.available_locales = %w(en es)
4
4
  end
5
+
6
+ namespace :i18n do
7
+ task :setup => 'environment'
8
+ end
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.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-28 00:00:00.000000000 Z
11
+ date: 2013-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -210,7 +210,8 @@ files:
210
210
  homepage: https://github.com/glebm/i18n-tasks
211
211
  licenses:
212
212
  - MIT
213
- metadata: {}
213
+ metadata:
214
+ issue_tracker: https://github.com/glebm/i18n-tasks
214
215
  post_install_message:
215
216
  rdoc_options: []
216
217
  require_paths:
@@ -230,7 +231,8 @@ rubyforge_project:
230
231
  rubygems_version: 2.1.11
231
232
  signing_key:
232
233
  specification_version: 4
233
- summary: Tasks to manage missing and unused translations in Rails.
234
+ summary: Tasks to manage missing and unused translations in ruby applications using
235
+ I18n.
234
236
  test_files:
235
237
  - spec/fixtures/app/assets/javascripts/application.js
236
238
  - spec/fixtures/app/controllers/events_controller.rb