globalize3_helpers 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- actionpack (3.2.5)
5
- activemodel (= 3.2.5)
6
- activesupport (= 3.2.5)
4
+ actionpack (3.2.6)
5
+ activemodel (= 3.2.6)
6
+ activesupport (= 3.2.6)
7
7
  builder (~> 3.0.0)
8
8
  erubis (~> 2.7.0)
9
9
  journey (~> 1.0.1)
@@ -11,15 +11,15 @@ GEM
11
11
  rack-cache (~> 1.2)
12
12
  rack-test (~> 0.6.1)
13
13
  sprockets (~> 2.1.3)
14
- activemodel (3.2.5)
15
- activesupport (= 3.2.5)
14
+ activemodel (3.2.6)
15
+ activesupport (= 3.2.6)
16
16
  builder (~> 3.0.0)
17
- activerecord (3.2.5)
18
- activemodel (= 3.2.5)
19
- activesupport (= 3.2.5)
17
+ activerecord (3.2.6)
18
+ activemodel (= 3.2.6)
19
+ activesupport (= 3.2.6)
20
20
  arel (~> 3.0.2)
21
21
  tzinfo (~> 0.3.29)
22
- activesupport (3.2.5)
22
+ activesupport (3.2.6)
23
23
  i18n (~> 0.6)
24
24
  multi_json (~> 1.0)
25
25
  arel (3.0.2)
@@ -37,7 +37,7 @@ GEM
37
37
  git (>= 1.2.5)
38
38
  rake
39
39
  rdoc
40
- journey (1.0.3)
40
+ journey (1.0.4)
41
41
  json (1.7.3)
42
42
  multi_json (1.3.6)
43
43
  paper_trail (2.6.3)
@@ -50,9 +50,9 @@ GEM
50
50
  rack
51
51
  rack-test (0.6.1)
52
52
  rack (>= 1.0)
53
- railties (3.2.5)
54
- actionpack (= 3.2.5)
55
- activesupport (= 3.2.5)
53
+ railties (3.2.6)
54
+ actionpack (= 3.2.6)
55
+ activesupport (= 3.2.6)
56
56
  rack-ssl (~> 1.3.2)
57
57
  rake (>= 0.8.7)
58
58
  rdoc (~> 3.4)
@@ -70,7 +70,7 @@ GEM
70
70
  hike (~> 1.2)
71
71
  rack (~> 1.0)
72
72
  tilt (~> 1.1, != 1.3.0)
73
- thor (0.15.2)
73
+ thor (0.15.3)
74
74
  tilt (1.3.3)
75
75
  tzinfo (0.3.33)
76
76
 
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ globalize3_helpers
2
+ ==================
3
+
4
+ Form helpers for globalize3.
5
+
6
+ ## Install globalize3_helpers
7
+
8
+ ###Installing gem:
9
+
10
+ `gem install globalize3_helpers`
11
+
12
+ ## Using it
13
+
14
+ ### Model:
15
+ Inside your model:
16
+
17
+ `accepts_nested_attributes_for :translations`
18
+
19
+ ### View:
20
+ Supports form_for and simple_form
21
+
22
+ With array of locales:
23
+ (haml syntax)
24
+
25
+ - f.globalize_fields_for_locales [ :en, :el ] do |l|
26
+ = l.input :name, input_html: { :class => :span5 }
27
+ = l.input :description, as: :text, input_html: { :class => 'span6 without_radius' }
28
+
29
+ With single locale:
30
+ (haml syntax)
31
+
32
+ - f.globalize_fields_for_locale :en do |l|
33
+ = l.input :name, input_html: { :class => :span5 }
34
+ = l.input :description, as: :text, input_html: { :class => 'span6 without_radius' }
35
+
36
+ ### Contributing
37
+ 1. Fork the code, add more helpers
38
+ 2. Most important contribution would be testing
39
+
40
+ ### Notice
41
+ I know the current code has a lot of duplication, in the next days i will fix it.
42
+
43
+ ### Copyrights
44
+ Copyright (c) 2012 Lefteris Georgatos. See LICENSE.txt for
45
+ further details.
46
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.9
1
+ 0.2.0
@@ -5,23 +5,20 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "globalize3_helpers"
8
- s.version = "0.1.9"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Lefteris Georgatos"]
12
- s.date = "2012-06-12"
12
+ s.date = "2012-06-21"
13
13
  s.description = "Use globalize3 helpers in your views. Forked from https://github.com/fidel/batch_translations "
14
14
  s.email = "lefteris.georgatos@gmail.com"
15
15
  s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.rdoc"
16
+ "README.md"
18
17
  ]
19
18
  s.files = [
20
- ".document",
21
19
  "Gemfile",
22
20
  "Gemfile.lock",
23
- "LICENSE.txt",
24
- "README.rdoc",
21
+ "README.md",
25
22
  "Rakefile",
26
23
  "VERSION",
27
24
  "globalize3_helpers.gemspec",
@@ -1,7 +1,27 @@
1
1
  module ActionView
2
2
  module Helpers
3
3
  class FormBuilder
4
- def globalize_fields_for(locale, *args, &proc)
4
+
5
+ def globalize_fields_for_locales(locales = [], *args, &proc)
6
+ raise ArgumentError, "Missing block" unless block_given?
7
+ globalize_fields_for(locales.first.to_s, *args, &proc) if locales.count <= 1
8
+ translations_fields = []
9
+
10
+ locales.each do |locale|
11
+ @index = @index ? @index + 1 : 1
12
+ object_name = "#{@object_name}[translations_attributes][#{@index}]"
13
+ object = @object.translations.find_by_locale locale.to_s
14
+ @template.concat @template.hidden_field_tag("#{object_name}[id]", object ? object.id : "")
15
+ @template.concat @template.hidden_field_tag("#{object_name}[locale]", locale)
16
+ if @template.respond_to? :simple_fields_for
17
+ @template.concat @template.simple_fields_for(object_name, object, *args, &proc)
18
+ else
19
+ @template.concat @template.fields_for(object_name, object, *args, &proc)
20
+ end
21
+ end
22
+ end
23
+
24
+ def globalize_fields_for_locale(locale, *args, &proc)
5
25
  raise ArgumentError, "Missing block" unless block_given?
6
26
  @index = @index ? @index + 1 : 1
7
27
  object_name = "#{@object_name}[translations_attributes][#{@index}]"
@@ -14,6 +34,7 @@ module ActionView
14
34
  @template.fields_for(object_name, object, *args, &proc)
15
35
  end
16
36
  end
37
+
17
38
  end
18
39
  end
19
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: globalize3_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-12 00:00:00.000000000 Z
12
+ date: 2012-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -144,14 +144,11 @@ email: lefteris.georgatos@gmail.com
144
144
  executables: []
145
145
  extensions: []
146
146
  extra_rdoc_files:
147
- - LICENSE.txt
148
- - README.rdoc
147
+ - README.md
149
148
  files:
150
- - .document
151
149
  - Gemfile
152
150
  - Gemfile.lock
153
- - LICENSE.txt
154
- - README.rdoc
151
+ - README.md
155
152
  - Rakefile
156
153
  - VERSION
157
154
  - globalize3_helpers.gemspec
@@ -175,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
175
172
  version: '0'
176
173
  segments:
177
174
  - 0
178
- hash: -4256764274457213517
175
+ hash: -3718987842454061666
179
176
  required_rubygems_version: !ruby/object:Gem::Requirement
180
177
  none: false
181
178
  requirements:
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/LICENSE.txt DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2012 Lefteris Georgatos
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc DELETED
@@ -1,21 +0,0 @@
1
- = globalize3_helpers
2
-
3
- Helper that renders globalize_translations fields on a per-locale basis, so you can use them separately in the same form and still saving them all at once in the same request.
4
- Globalize3_helpers gem is just a convertion, of https://github.com/fidel/batch_translations of fidel, from plugin to gem.
5
-
6
- == Contributing to globalize3_helpers
7
-
8
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
9
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
10
- * Fork the project.
11
- * Start a feature/bugfix branch.
12
- * Commit and push until you are happy with your contribution.
13
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
14
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
15
- * Write tests now there is none
16
-
17
- == Copyright
18
-
19
- Copyright (c) 2012 Lefteris Georgatos. See LICENSE.txt for
20
- further details.
21
-