translate-rails3-plus 0.0.14 → 0.0.15
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 +4 -4
- data/VERSION +1 -1
- data/app/controllers/translate_controller.rb +9 -1
- data/app/views/translate/index.html.erb +3 -0
- data/config/routes.rb +1 -0
- data/lib/translate/file.rb +15 -8
- data/lib/translate/storage.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18b7016a4e2a75186ed46cb97f048463f1274b5e
|
4
|
+
data.tar.gz: fbaa2d21042297f854a2ec952f1d2f262e2a2e00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 614704fb2b4f129c5626c6b7c08e01c7d571d44c4bd4203d948998e64a42d234175e3925c96a75b2479c4eb73ce9283661a9ccb0f2adf68b2d712377a96f59d7
|
7
|
+
data.tar.gz: ede6faa8f7275998fe472ef164e424af763d7e67b1c6d979d889e17a4cc8abb32990c9bd87deadcb8db80f4f0fe1a39ce0bce855c4cba6f9d03f6c569f98d604
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.15
|
@@ -29,7 +29,7 @@ class TranslateController < ActionController::Base
|
|
29
29
|
Translate::Storage.new(@to_locale).write_to_file
|
30
30
|
Translate::Log.new(@from_locale, @to_locale, params[:key].keys).write_to_file
|
31
31
|
force_init_translations # Force reload from YAML file
|
32
|
-
flash[:notice] = "Translations
|
32
|
+
flash[:notice] = "Translations saved"
|
33
33
|
old_params = params.slice(:filter, :sort_by, :key_type, :key_pattern, :text_type, :text_pattern, :translated_text_type, :translated_text_pattern)
|
34
34
|
redirect_to( {:action => :index}.merge(old_params) )
|
35
35
|
end
|
@@ -41,6 +41,14 @@ class TranslateController < ActionController::Base
|
|
41
41
|
redirect_to :action => 'index'
|
42
42
|
end
|
43
43
|
|
44
|
+
def download
|
45
|
+
params.permit!
|
46
|
+
initialize_keys
|
47
|
+
text = Translate::Storage.new(@to_locale).read_from_file
|
48
|
+
send_data text, :filename => @to_locale.to_s + ".yml"
|
49
|
+
|
50
|
+
end
|
51
|
+
|
44
52
|
private
|
45
53
|
def initialize_keys
|
46
54
|
@files = Translate::Keys.files
|
data/config/routes.rb
CHANGED
@@ -2,4 +2,5 @@ Rails.application.routes.draw do
|
|
2
2
|
get 'translate' => 'translate#index', :as => :translate_list
|
3
3
|
post 'translate' => 'translate#translate', :as => :translate
|
4
4
|
get 'translate/reload' => 'translate#reload', :as => :translate_reload
|
5
|
+
get 'translate/download' => 'translate#download', :as => :translate_download
|
5
6
|
end
|
data/lib/translate/file.rb
CHANGED
@@ -19,11 +19,16 @@ class Translate::File
|
|
19
19
|
File.exists?(path) ? YAML::load(IO.read(path)) : {}
|
20
20
|
end
|
21
21
|
|
22
|
+
def read_raw
|
23
|
+
File.exists?(path) ? File.read(path) : ""
|
24
|
+
end
|
25
|
+
|
22
26
|
# Stringifying keys for prettier YAML
|
23
27
|
def self.deep_stringify_keys(hash)
|
24
28
|
hash.inject({}) { |result, (key, value)|
|
25
29
|
value = deep_stringify_keys(value) if value.is_a? Hash
|
26
|
-
|
30
|
+
|
31
|
+
result[(key.to_s rescue key).present? ? key.to_s : key] = value
|
27
32
|
result
|
28
33
|
}
|
29
34
|
end
|
@@ -49,18 +54,20 @@ class Translate::File
|
|
49
54
|
k.plain = true
|
50
55
|
k.quoted = false
|
51
56
|
k.style = Psych::Nodes::Scalar::ANY
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
+
|
58
|
+
|
59
|
+
if k.to_ruby.to_s == "false" || k.to_ruby.to_s == "true"
|
60
|
+
k.plain = false
|
61
|
+
k.quoted = true
|
62
|
+
k.style = Psych::Nodes::Scalar::DOUBLE_QUOTED
|
57
63
|
end
|
58
|
-
|
59
|
-
if v.to_ruby.to_s == "true" || v.to_ruby.to_s == "false"
|
64
|
+
|
65
|
+
if v.to_ruby.to_s == v.to_ruby.to_s.to_i.to_s || v.to_ruby.to_s == "true" || v.to_ruby.to_s == "false"
|
60
66
|
v.plain = true
|
61
67
|
v.quoted = false
|
62
68
|
v.style = Psych::Nodes::Scalar::ANY
|
63
69
|
end
|
70
|
+
|
64
71
|
end
|
65
72
|
end
|
66
73
|
|
data/lib/translate/storage.rb
CHANGED
@@ -8,6 +8,10 @@ class Translate::Storage
|
|
8
8
|
def write_to_file
|
9
9
|
Translate::File.new(file_path).write(keys)
|
10
10
|
end
|
11
|
+
|
12
|
+
def read_from_file
|
13
|
+
Translate::File.new(file_path).read_raw()
|
14
|
+
end
|
11
15
|
|
12
16
|
def self.file_paths(locale)
|
13
17
|
Dir.glob(File.join(root_dir, "config", "locales", "**","#{locale}.yml"))
|