i18n_translation_spawner 0.0.15 → 0.0.16
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.
@@ -1,11 +1,21 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
=begin
|
2
|
+
class A
|
3
|
+
include LambdaAccessor
|
4
|
+
lambda_accessor :test
|
3
5
|
|
4
|
-
|
6
|
+
def default_test_handler(*args)
|
7
|
+
puts args.shift
|
5
8
|
end
|
9
|
+
end
|
6
10
|
|
7
|
-
|
11
|
+
b = A.new
|
12
|
+
b.test('goof')
|
13
|
+
b.test_handler = lambda {|*args| "---- #{args[1]} ----"}
|
14
|
+
=end
|
8
15
|
|
16
|
+
module LambdaAccessor
|
17
|
+
extend ActiveSupport::Concern
|
18
|
+
module ClassMethods
|
9
19
|
def lambda_accessor(*args)
|
10
20
|
args.map(&:to_s).each do |name|
|
11
21
|
attr_accessor "#{name}_handler"
|
@@ -20,20 +30,4 @@ module LambdaAccessor
|
|
20
30
|
end
|
21
31
|
end
|
22
32
|
end
|
23
|
-
end
|
24
|
-
|
25
|
-
=begin
|
26
|
-
class A
|
27
|
-
include LambdaAccessor
|
28
|
-
lambda_accessor :test
|
29
|
-
|
30
|
-
def default_test_handler(*args)
|
31
|
-
puts args.shift
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
b = A.new
|
36
|
-
b.test('goof')
|
37
|
-
|
38
|
-
b.test_handler = lambda {|*args| "---- #{args[1]} ----"}
|
39
|
-
=end
|
33
|
+
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
unless RUBY_VERSION >= '1.9'
|
2
|
+
require "yaml/encoding"
|
3
|
+
end
|
4
|
+
|
1
5
|
require "i18n_translation_spawner/string"
|
2
6
|
require "i18n_translation_spawner/hash"
|
3
7
|
require "i18n_translation_spawner/lambda_accessor"
|
@@ -39,7 +43,8 @@ module I18n
|
|
39
43
|
translations_hash = YAML::load_file(path)
|
40
44
|
hash_to_merge = "#{_locale.to_s}.#{key}".to_hash(translation(key, _locale.to_s)).deep_stringify_keys!
|
41
45
|
translations_hash = translations_hash.deep_merge(hash_to_merge).to_ordered_hash
|
42
|
-
|
46
|
+
translation_content = translations_hash.ya2yaml.sub(/---\s*/, '')
|
47
|
+
File.open(path, 'w') { |f| f.write(RUBY_VERSION >= '1.9' ? translation_content : YAML.unescape(translation_content)) }
|
43
48
|
end
|
44
49
|
end
|
45
50
|
rescue CannotDecodeTranslationFilePath
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_translation_spawner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 16
|
10
|
+
version: 0.0.16
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "B\xC5\x82a\xC5\xBCej --Stevo-- Kosmowski"
|
@@ -42,8 +42,8 @@ extra_rdoc_files: []
|
|
42
42
|
|
43
43
|
files:
|
44
44
|
- lib/i18n_translation_spawner/hash.rb
|
45
|
-
- lib/i18n_translation_spawner/lambda_accessor.rb
|
46
45
|
- lib/i18n_translation_spawner/string.rb
|
46
|
+
- lib/i18n_translation_spawner/lambda_accessor.rb
|
47
47
|
- lib/i18n_translation_spawner.rb
|
48
48
|
homepage: https://github.com/stevo/i18n_translation_spawner
|
49
49
|
licenses: []
|