drogus-genderized 0.0.2 → 0.0.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/README.textile CHANGED
@@ -2,6 +2,41 @@ h1. Genderized
2
2
 
3
3
  Rails plugin supporting gender with I18n translations. It requires russian gem
4
4
 
5
+ h2. Install
6
+
7
+ Easiest way to add it to your rails app is to add line in environment.rb
8
+ <pre><code>
9
+ config.gem 'drogus-genderized', :lib => 'genderized', :source => 'http://gems.github.com'
10
+ </code></pre>
11
+
5
12
  h2. Usage
6
13
 
14
+ To use genders just drop :gender key to your attribute definitions (translation is for Polish word for lamp, it's similar in many languages):
15
+
16
+ <pre><code>
17
+ :activerecord => {
18
+ :attributes => {
19
+ :user => {
20
+ :lamp => {
21
+ :one => "lampa", :few => 'lampy', :many => 'lamp',
22
+ :other => 'lampy', :gender => :feminine
23
+ }
24
+ }
25
+ }
26
+ </code></pre>
27
+
28
+ Then all you need is to set messages for each gender:
29
+ <pre><code>
30
+ :errors => {
31
+ :messages => {
32
+ :empty => {
33
+ :masculine => "nie może być pusty",
34
+ :feminine => "nie może być pusta",
35
+ :neuter => "nie może być puste"
36
+ }
37
+ }
38
+ }
39
+ }
40
+ </code></pre>
7
41
 
42
+ On blank message it will generate: "Lampa nie może być pusta".
@@ -36,6 +36,21 @@ module I18n
36
36
  entry = interpolate locale, entry, values
37
37
  entry
38
38
  end
39
+
40
+ def pluralize(locale, entry, count)
41
+ return entry unless entry.is_a?(Hash) and count
42
+
43
+ key = :zero if count == 0 && entry.has_key?(:zero)
44
+ locale_pluralize = lookup(locale, :pluralize)
45
+ if locale_pluralize && locale_pluralize.respond_to?(:call)
46
+ key ||= locale_pluralize.call(count)
47
+ else
48
+ key ||= default_pluralizer(count)
49
+ end
50
+ return entry unless entry.has_key?(key)
51
+
52
+ entry[key]
53
+ end
39
54
  end
40
55
  end
41
56
  end
data/lib/genderized.rb CHANGED
@@ -15,7 +15,7 @@ module Genderized
15
15
  module VERSION
16
16
  MAJOR = 0
17
17
  MINOR = 0
18
- TINY = 2
18
+ TINY = 3
19
19
 
20
20
  STRING = [MAJOR, MINOR, TINY].join('.')
21
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drogus-genderized
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Sarnacki