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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c043e84b415c650f3dfef85e24b3168eec5a52b
4
- data.tar.gz: 9c517e1544f964b3c587b63e62f2a6527b5fa2c1
3
+ metadata.gz: 18b7016a4e2a75186ed46cb97f048463f1274b5e
4
+ data.tar.gz: fbaa2d21042297f854a2ec952f1d2f262e2a2e00
5
5
  SHA512:
6
- metadata.gz: 15858ad7c7b9df6802162e8810bae29b75651967f99f25112574576d1adcc4c8f6d7a7c33d5c0f575f65fd3aff9ea1dadfb109fded1b49cf6df5a14ce64b4741
7
- data.tar.gz: a34d3807117ae17b051f829f757c7e2cb5a3304e3bfae63de68bf2696ddacc8a5827334501441c37a6b16a2eb29a0bcab9c55902a4d9816bfdfeb80e7b6ae6ca
6
+ metadata.gz: 614704fb2b4f129c5626c6b7c08e01c7d571d44c4bd4203d948998e64a42d234175e3925c96a75b2479c4eb73ce9283661a9ccb0f2adf68b2d712377a96f59d7
7
+ data.tar.gz: ede6faa8f7275998fe472ef164e424af763d7e67b1c6d979d889e17a4cc8abb32990c9bd87deadcb8db80f4f0fe1a39ce0bce855c4cba6f9d03f6c569f98d604
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.13
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 stored"
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
@@ -52,6 +52,9 @@ show_filters << "changed" if @from_locale != @to_locale
52
52
  <p>
53
53
  <%= link_to "Reload messages", translate_reload_path %>
54
54
  </p>
55
+ <p>
56
+ <%= link_to "Download messages", translate_download_path %>
57
+ </p>
55
58
  </fieldset>
56
59
 
57
60
 
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
@@ -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
- result[(key.to_s rescue key) || key] = value
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
- if v.to_ruby.to_s == v.to_ruby.to_s.to_i.to_s
54
- v.plain = true
55
- v.quoted = false
56
- v.style = Psych::Nodes::Scalar::ANY
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
 
@@ -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"))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translate-rails3-plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Marklund