i18n-tasks 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b6ca864b87be5f8d5c8a1c6be42ebe3c4c4ec3c
4
- data.tar.gz: 41133bde7863a0b57c9d14889ea4d56846c0c543
3
+ metadata.gz: e1bc1cb806707bc4c7658d1c26a943c92dbd654c
4
+ data.tar.gz: b63519bafa3e4f0f149a553c10af48f6e16e5b0d
5
5
  SHA512:
6
- metadata.gz: 583ff94e1c15d0946de46f2dcf4a20ab9ea348a2f4ce9b60feabfbbd6e5123ae0e0fb9860c4fda7481ff5b60ab7011103cd67b646673395c16cf37dac8bf3827
7
- data.tar.gz: 0d40adb4b4d03cd123aa9e099a65784fbf936da6eaaa780fa6dd1e936c769aeb5932cdc124b699f801200f11d283bba8d69b10814ffd8589cc39bc8372a8fef4
6
+ metadata.gz: 5b8b9bd686f9bfce0e95e335f28a14afa966acc6b2c7f3a916c8f5fe5ca6a9b7b33cac512684d768f1646f2e220f3bb4e46e1e5eaab3f178f07f3c0858e7c068
7
+ data.tar.gz: a5384b5edd7c0fcf17d0bd4264e81e2db0f071ddf525933403370fd1fcf6bbc5c89788b4b8bb924f1e7645561ed253618556c1083a49de69ac6240b3dd7b751a
data/CHANGES.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## v0.2.6
2
+
3
+ * config/i18n-tasks.yml now processed with ERB (@glebm)
4
+
5
+ ## v0.2.5
6
+
7
+ * can now be used with any ruby apps, not just Rails (@glebm)
8
+
1
9
  ## v0.2.4
2
10
 
3
11
  * more powerful key pattern matching with sets and backtracking (@glebm)
data/README.md CHANGED
@@ -73,7 +73,7 @@ For more examples see [the tests](/spec/i18n_tasks_spec.rb).
73
73
  Simply add to Gemfile:
74
74
 
75
75
  ```ruby
76
- gem 'i18n-tasks', '~> 0.2.5'
76
+ gem 'i18n-tasks', '~> 0.2.6'
77
77
  ```
78
78
 
79
79
  If you do not use Rails, you will also need to require the tasks in your Rakefile:
@@ -85,7 +85,15 @@ load 'tasks/i18n-tasks.rake'
85
85
 
86
86
  ## Configuration
87
87
 
88
- Configuration is read from `config/i18n-tasks.yml`.
88
+ Configuration is read from `config/i18n-tasks.yml` (processed with ERB then Yaml).
89
+
90
+ By default, `i18n-tasks` will work with `I18n.default_locale` and `I18n.available_locales`, but you can override this:
91
+
92
+ ```yaml
93
+ # config/i18n-tasks.yml
94
+ base_locale: en
95
+ locales: [es, fr]
96
+ ```
89
97
 
90
98
  ### Storage
91
99
 
data/i18n-tasks.gemspec CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.require_paths = ['lib']
24
24
 
25
25
  s.add_dependency 'rake'
26
+ s.add_dependency 'erubis'
26
27
  s.add_dependency 'activesupport'
27
28
  s.add_dependency 'easy_translate'
28
29
  s.add_dependency 'term-ansicolor'
data/lib/i18n/tasks.rb CHANGED
@@ -4,16 +4,20 @@ require 'active_support/core_ext/string'
4
4
  require 'active_support/core_ext/module/delegation'
5
5
  require 'active_support/core_ext/object/try'
6
6
  require 'term/ansicolor'
7
+ require 'erubis'
7
8
  require 'i18n/tasks/railtie' if defined?(Rails)
8
9
 
9
10
  module I18n
10
11
  module Tasks
11
- CONFIG_FILE = 'config/i18n-tasks.yml'
12
+ CONFIG_FILES = %w(
13
+ config/i18n-tasks.yml config/i18n-tasks.yml.erb
14
+ i18n-tasks.yml i18n-tasks.yml.erb
15
+ )
12
16
  class << self
13
17
  def config
14
18
  @config ||= begin
15
- file = File.read(CONFIG_FILE) if File.exists?(CONFIG_FILE)
16
- file = YAML.load(file) if file.present?
19
+ file = File.read(CONFIG_FILES.detect { |f| File.exists?(f) })
20
+ file = YAML.load(Erubis::Eruby.new(file).result) if file.present?
17
21
  HashWithIndifferentAccess.new.merge(file.presence || {})
18
22
  end
19
23
  end
@@ -4,7 +4,7 @@ module I18n::Tasks::DataTraversal
4
4
  def t(hash = data[base_locale], key)
5
5
  if hash.is_a?(String)
6
6
  # has is a locale
7
- raise ArgumentError.new("invalid locale: #{hash}") if hash =~ /\W/
7
+ raise ArgumentError.new("invalid locale: #{hash}") if hash =~ /[^A-z-]/
8
8
  hash = data[hash]
9
9
  end
10
10
  key.split('.').inject(hash) { |r, seg| r[seg] if r }
@@ -1,5 +1,5 @@
1
1
  module I18n
2
2
  module Tasks
3
- VERSION = '0.2.5'
3
+ VERSION = '0.2.6'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebm
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: erubis
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: activesupport
29
43
  requirement: !ruby/object:Gem::Requirement