rich_i18n 1.2.2 → 1.2.3

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.
data/CHANGELOG CHANGED
@@ -1,5 +1,14 @@
1
1
  = Rich-i18n CHANGELOG
2
2
 
3
+ == Version 1.2.3 (October 19, 2010)
4
+
5
+ * Using SeatHolder v0.8.8 in order to tell SeatHolder not to react on focus events (yay!)
6
+ * Corrected Rich.I18n.afterUpdate() so certain page elements will be updated again after updating translations
7
+ * Added some manual source file requirements
8
+ * Changed formtastic dependency to '1.0.1' and i18n to '>= 0.3.7' which fixes the gem installation error
9
+ * Being able to edit translations within the WYSIWYG editor Cleditor (:as => :html)
10
+ * Telling Formtastic not to escape labels when required
11
+
3
12
  == Version 1.2.2 (October 9, 2010)
4
13
 
5
14
  * Fixed cached translations (adding I18n.locale as criteria just now, doh!)
@@ -134,7 +134,7 @@ You can combine translations by using passed string containing translation keys
134
134
 
135
135
  h3. Translation meta data with EnrichedString
136
136
 
137
- When translating text, you possibly want to know the @key@, the @value@, the @locale@ and the @derivative key@ (the argument passed for translation). Rich-i18n preserves just that in an @EnrichedString@ which is a subclass of @String@. Calling @.meta_data@ returns a hash with the meta data:
137
+ When translating text, you possibly want to know the @key@, the @value@, the @locale@ and the @derivative key@ (the argument passed for translation). Rich-i18n preserves just that in an @EnrichedString@ which is a wrapper containing meta data and the translation. Calling @.meta_data@ returns a hash with the meta data:
138
138
 
139
139
  <pre>
140
140
  >> "MORE".t.class
data/Rakefile CHANGED
@@ -12,10 +12,10 @@ begin
12
12
  gemspec.homepage = "http://codehero.es/rails_gems_plugins/rich_i18n"
13
13
  gemspec.author = "Paul Engel"
14
14
 
15
- gemspec.add_dependency "i18n" , "0.3.7"
16
- gemspec.add_dependency "jzip" , ">= 1.0.10"
15
+ gemspec.add_dependency "formtastic", "1.0.1"
17
16
  gemspec.add_dependency "hpricot"
18
- gemspec.add_dependency "formtastic", "0.9.7"
17
+ gemspec.add_dependency "i18n" , ">= 0.3.7"
18
+ gemspec.add_dependency "jzip" , ">= 1.0.10"
19
19
  end
20
20
  Jeweler::GemcutterTasks.new
21
21
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.2
1
+ 1.2.3
@@ -1,7 +1,7 @@
1
1
  if (typeof(SeatHolder) == "undefined") {
2
2
 
3
3
  // *
4
- // * SeatHolder 0.8.7 (Uncompressed)
4
+ // * SeatHolder 0.8.8 (Uncompressed)
5
5
  // * The modest Javascript placeholder (used in http://gettopup.com)
6
6
  // *
7
7
  // * This library requires jQuery (http://jquery.com)
@@ -10,11 +10,11 @@ if (typeof(SeatHolder) == "undefined") {
10
10
  // * Except otherwise noted, SeatHolder is licensed under
11
11
  // * http://creativecommons.org/licenses/by-sa/3.0
12
12
  // *
13
- // * $Date: 2010-09-01 23:14:04 +0100 (Wed, 01 September 2010) $
13
+ // * $Date: 2010-10-19 23:23:28 +0100 (Tue, 19 October 2010) $
14
14
  // *
15
15
 
16
16
  SeatHolder = (function() {
17
- var hintClass = "sh_hint", hideClass = "sh_hide", ignored_types = ["file", "submit"];
17
+ var hintClass = "sh_hint", hideClass = "sh_hide", ignored_types = ["file", "submit"], reacting = true;
18
18
 
19
19
  var injectCode = function() {
20
20
  var style = "<style>" +
@@ -24,6 +24,7 @@ SeatHolder = (function() {
24
24
 
25
25
  jQuery(style).prependTo("head");
26
26
  };
27
+
27
28
  var bind = function() {
28
29
  var hintedElements = [];
29
30
 
@@ -81,14 +82,27 @@ SeatHolder = (function() {
81
82
  });
82
83
  };
83
84
 
85
+ var react = function(bool) {
86
+ reacting = typeof(bool) == "undefined" ? true : bool;
87
+ };
88
+
84
89
  var onHintFocus = function(event) {
90
+ if (!reacting) {
91
+ return;
92
+ }
93
+
85
94
  var hintElement = jQuery(event.target).addClass(hideClass);
86
95
 
87
96
  hintElement.data("hinted_element")
88
97
  .removeClass(hideClass)
89
98
  .focus();
90
99
  };
100
+
91
101
  var onFocus = function(event) {
102
+ if (!reacting) {
103
+ return;
104
+ }
105
+
92
106
  var element = jQuery(event.target);
93
107
  var seatholder = element.attr("seatholder");
94
108
 
@@ -107,6 +121,7 @@ SeatHolder = (function() {
107
121
  input.setSelectionRange(0, element.val().length);
108
122
  }
109
123
  };
124
+
110
125
  var onBlur = function(event, element) {
111
126
  if (element == null) {
112
127
  element = jQuery(event.target);
@@ -135,7 +150,7 @@ SeatHolder = (function() {
135
150
  };
136
151
 
137
152
  return {
138
- version: "0.8.7",
153
+ version: "0.8.8",
139
154
  selector: "[seatholder]",
140
155
  hintColor: "#AAA",
141
156
  init: function() {
@@ -147,9 +162,8 @@ SeatHolder = (function() {
147
162
  bind();
148
163
  });
149
164
  },
150
- rebind: function() {
151
- bind();
152
- }
165
+ rebind: bind,
166
+ react: react
153
167
  };
154
168
  }());
155
169
 
@@ -12,7 +12,7 @@ Rich.I18n = (function() {
12
12
  },
13
13
  afterUpdate: function(form, response, selector, specs, identifier) {
14
14
  $.each(response.translations, function(key, value) {
15
- $( "span.i18n" + identifier + "[data-derivative_key=" + key + "]") .attr("data-value", response.value).html( value);
15
+ $( ".i18n" + identifier + "[data-derivative_key=" + key + "]") .attr("data-value", response.value).html( value);
16
16
  $("input.i18n" + identifier + "[data-derivative_key=" + key + "][value]") .attr("data-value", response.value).attr("value" , value);
17
17
  $("input.i18n" + identifier + "[data-derivative_key=" + key + "][seatholder]").attr("data-value", response.value).attr("seatholder", value);
18
18
  });
@@ -14,12 +14,13 @@ module Rich
14
14
  doc = Hpricot html
15
15
 
16
16
  (doc/"head i18n").each do |i18n|
17
- i18n.swap i18n.inner_html
17
+ i18n.swap CGI.unescapeHTML(i18n.raw_attributes["data-i18n_translation"])
18
18
  end
19
19
 
20
20
  (doc/"i18n").each do |i18n|
21
- elem = Hpricot::Elem.new "span", i18n.raw_attributes.merge({:class => "i18n"})
22
- elem.inner_html = i18n.inner_html
21
+ elem = Hpricot::Elem.new i18n.raw_attributes["data-editable_input_type"] == "html" ? "div" : "span",
22
+ i18n.raw_attributes.reject{|k, v| k == "data-i18n_translation"}.merge({:class => "i18n"})
23
+ elem.inner_html = CGI.unescapeHTML(i18n.raw_attributes["data-i18n_translation"])
23
24
  i18n.swap elem.to_html
24
25
  end
25
26
 
@@ -44,10 +45,10 @@ module Rich
44
45
 
45
46
  i18n = Hpricot(input.attributes[input_attr]).children.first
46
47
  i18n.raw_attributes.each do |key, value|
47
- input.attributes[key] = value
48
+ input.attributes[key] = value unless key == "data-i18n_translation"
48
49
  end
49
-
50
- input.attributes[input_attr] = i18n.inner_html
50
+
51
+ input.attributes[input_attr] = CGI.unescapeHTML(i18n.raw_attributes["data-i18n_translation"])
51
52
  input.attributes["class"] = ["i18n", input.attributes["class"]].uniq.join(" ").strip
52
53
  end
53
54
 
@@ -25,14 +25,19 @@ module Rich
25
25
  private
26
26
 
27
27
  def to_tag
28
+ tag = :i18n
29
+ attrs = []
30
+
28
31
  keys = [:key, :value, :locale, :derivative_key]
29
32
  data = @meta_data.reject{|k, v| !keys.include?(k.to_sym)}
30
33
 
31
- tag = :i18n
32
- attrs = data.collect{|k, v| "data-#{k}=\"#{::ERB::Util.html_escape v}\""}.join " "
33
- value = @string
34
+ data[:editable_input_type] = @meta_data[:as] if %w(string text html).include? @meta_data[:as].to_s.downcase
35
+
36
+ attrs << @meta_data[:html].collect{|k, v| "#{k}=\"#{::ERB::Util.html_escape v}\""}.join(" ") if @meta_data[:html]
37
+ attrs << data .collect{|k, v| "data-#{k}=\"#{::ERB::Util.html_escape v}\""}.join(" ")
38
+ attrs << "data-i18n_translation=\"#{::ERB::Util.html_escape @string}\""
34
39
 
35
- "<#{tag} #{attrs}>#{value}</#{tag}>"
40
+ "<#{tag} #{attrs}></#{tag}>"
36
41
  end
37
42
 
38
43
  end
@@ -56,19 +56,19 @@ module Rich
56
56
  end
57
57
  end
58
58
 
59
- unless s.gsub!(/^=\s+/, "")
59
+ unless s.gsub!(/^=\s+/, "") || options[:as].to_s == "html"
60
60
  s.cp_case! options[:capitalize] ? default.capitalize : default
61
61
  end
62
62
 
63
63
  array << " " unless array.empty?
64
- array << EnrichedString.new(s, {:key => key, :value => value, :locale => I18n.locale, :derivative_key => string})
64
+ array << EnrichedString.new(s, options.reject{|k, v| !%w(html as).include? k.to_s}.merge({:key => key, :value => value, :locale => I18n.locale, :derivative_key => string}))
65
65
 
66
66
  end.join
67
67
  end
68
68
 
69
69
  private
70
70
 
71
- RICH_I18N_OPTIONS = [:count, :pluralize, :capitalize, :translate_callback]
71
+ RICH_I18N_OPTIONS = [:count, :pluralize, :capitalize, :translate_callback, :html, :as]
72
72
  LOGGER_PROC = Proc.new{|translation, key, options| puts "== RICH-I18N: I18n.t #{key.inspect}, #{options.inspect}"}
73
73
 
74
74
  @@i18n_translations = {}
@@ -18,6 +18,7 @@ module Rich
18
18
  end
19
19
 
20
20
  ::Jzip::Engine.add_template_location({File.join(File.dirname(__FILE__), "..", "..", "assets", "jzip") => File.join(RAILS_ROOT, "public", "javascripts")})
21
+ ::Formtastic::SemanticFormBuilder.escape_html_entities_in_hints_and_labels = false if ::Formtastic::SemanticFormBuilder.respond_to?(:escape_html_entities_in_hints_and_labels)
21
22
 
22
23
  load_i18n test_class
23
24
  end
@@ -1,5 +1,10 @@
1
+ require "jzip"
2
+
3
+ require "formtastic"
4
+ ActionView::Base.send :include, Formtastic::SemanticFormHelper
1
5
 
2
6
  require "rich/i18n"
3
7
  require "rich/i18n/core"
4
8
  require "rich/i18n/actionpack"
5
9
  require "rich/i18n/engine"
10
+ require "rich/i18n/formtastic"
@@ -1,7 +1,7 @@
1
1
  class <%= model_class_name %> < ActiveRecord::Base
2
2
 
3
3
  def to_rich_cms_response(params)
4
- {:value => value, :translations => Hash[*params[:derivative_keys].split(";").uniq.collect{|x| [x, x.t]}.flatten]}
4
+ {:value => value, :translations => Hash[*params[:derivative_keys].split(";").uniq.collect{|x| [x, x.t({:as => params[:editable_input_type]})]}.flatten]}
5
5
  end
6
6
 
7
7
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rich_i18n}
8
- s.version = "1.2.2"
8
+ s.version = "1.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Paul Engel"]
12
- s.date = %q{2010-10-09}
12
+ s.date = %q{2010-10-20}
13
13
  s.description = %q{Rich-i18n is a module of E9s (http://github.com/archan937/e9s) which enriches I18n, Formtastic, the String and Symbol classes. This simplifies internationalization of your Rails application making a Rails developers life much easier.}
14
14
  s.email = %q{paul.engel@holder.nl}
15
15
  s.extra_rdoc_files = [
@@ -90,21 +90,21 @@ Gem::Specification.new do |s|
90
90
  s.specification_version = 3
91
91
 
92
92
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
93
- s.add_runtime_dependency(%q<i18n>, ["= 0.3.7"])
94
- s.add_runtime_dependency(%q<jzip>, [">= 1.0.10"])
93
+ s.add_runtime_dependency(%q<formtastic>, ["= 1.0.1"])
95
94
  s.add_runtime_dependency(%q<hpricot>, [">= 0"])
96
- s.add_runtime_dependency(%q<formtastic>, ["= 0.9.7"])
95
+ s.add_runtime_dependency(%q<i18n>, [">= 0.3.7"])
96
+ s.add_runtime_dependency(%q<jzip>, [">= 1.0.10"])
97
97
  else
98
- s.add_dependency(%q<i18n>, ["= 0.3.7"])
99
- s.add_dependency(%q<jzip>, [">= 1.0.10"])
98
+ s.add_dependency(%q<formtastic>, ["= 1.0.1"])
100
99
  s.add_dependency(%q<hpricot>, [">= 0"])
101
- s.add_dependency(%q<formtastic>, ["= 0.9.7"])
100
+ s.add_dependency(%q<i18n>, [">= 0.3.7"])
101
+ s.add_dependency(%q<jzip>, [">= 1.0.10"])
102
102
  end
103
103
  else
104
- s.add_dependency(%q<i18n>, ["= 0.3.7"])
105
- s.add_dependency(%q<jzip>, [">= 1.0.10"])
104
+ s.add_dependency(%q<formtastic>, ["= 1.0.1"])
106
105
  s.add_dependency(%q<hpricot>, [">= 0"])
107
- s.add_dependency(%q<formtastic>, ["= 0.9.7"])
106
+ s.add_dependency(%q<i18n>, [">= 0.3.7"])
107
+ s.add_dependency(%q<jzip>, [">= 1.0.10"])
108
108
  end
109
109
  end
110
110
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rich_i18n
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 2
10
- version: 1.2.2
9
+ - 3
10
+ version: 1.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Paul Engel
@@ -15,27 +15,27 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-09 00:00:00 +02:00
18
+ date: 2010-10-20 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: i18n
22
+ name: formtastic
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - "="
28
28
  - !ruby/object:Gem::Version
29
- hash: 29
29
+ hash: 21
30
30
  segments:
31
+ - 1
31
32
  - 0
32
- - 3
33
- - 7
34
- version: 0.3.7
33
+ - 1
34
+ version: 1.0.1
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: jzip
38
+ name: hpricot
39
39
  prerelease: false
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
@@ -44,40 +44,40 @@ dependencies:
44
44
  - !ruby/object:Gem::Version
45
45
  hash: 3
46
46
  segments:
47
- - 1
48
47
  - 0
49
- - 10
50
- version: 1.0.10
48
+ version: "0"
51
49
  type: :runtime
52
50
  version_requirements: *id002
53
51
  - !ruby/object:Gem::Dependency
54
- name: hpricot
52
+ name: i18n
55
53
  prerelease: false
56
54
  requirement: &id003 !ruby/object:Gem::Requirement
57
55
  none: false
58
56
  requirements:
59
57
  - - ">="
60
58
  - !ruby/object:Gem::Version
61
- hash: 3
59
+ hash: 29
62
60
  segments:
63
61
  - 0
64
- version: "0"
62
+ - 3
63
+ - 7
64
+ version: 0.3.7
65
65
  type: :runtime
66
66
  version_requirements: *id003
67
67
  - !ruby/object:Gem::Dependency
68
- name: formtastic
68
+ name: jzip
69
69
  prerelease: false
70
70
  requirement: &id004 !ruby/object:Gem::Requirement
71
71
  none: false
72
72
  requirements:
73
- - - "="
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- hash: 53
75
+ hash: 3
76
76
  segments:
77
+ - 1
77
78
  - 0
78
- - 9
79
- - 7
80
- version: 0.9.7
79
+ - 10
80
+ version: 1.0.10
81
81
  type: :runtime
82
82
  version_requirements: *id004
83
83
  description: Rich-i18n is a module of E9s (http://github.com/archan937/e9s) which enriches I18n, Formtastic, the String and Symbol classes. This simplifies internationalization of your Rails application making a Rails developers life much easier.