air18n 0.1.46 → 0.1.47
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/air18n/class_methods.rb +14 -4
- data/lib/air18n/version.rb +1 -1
- metadata +1 -1
data/lib/air18n/class_methods.rb
CHANGED
@@ -55,15 +55,25 @@ module Air18n
|
|
55
55
|
# => '%{smart_count} Review||||%{smart_count} Reviews'
|
56
56
|
def pluralize(count, singular, plural=nil)
|
57
57
|
raise TypeError if count.is_a?(String)
|
58
|
-
default_text = "%{smart_count} #{singular}#{SmartCount::DELIMITER}
|
59
|
-
|
58
|
+
default_text = "%{smart_count} #{singular}#{SmartCount::DELIMITER}" +
|
59
|
+
"%{smart_count} #{plural || singular.pluralize}"
|
60
60
|
if count == nil
|
61
|
-
translate(
|
61
|
+
translate(pluralize_key(singular),
|
62
|
+
:default => default_text,
|
63
|
+
:suppress_ct => true)
|
62
64
|
else
|
63
|
-
translate(
|
65
|
+
translate(pluralize_key(singular),
|
66
|
+
:default => default_text,
|
67
|
+
:smart_count => count,
|
68
|
+
:suppress_ct => true)
|
64
69
|
end
|
65
70
|
end
|
66
71
|
|
72
|
+
# Returns the phrase key used by pluralize().
|
73
|
+
def pluralize_key(singular)
|
74
|
+
"shared.pluralize.#{singular}"
|
75
|
+
end
|
76
|
+
|
67
77
|
# For given locale (like :en, :en-GB, :pt-PT, or "en", "en-GB", "pt-PT"),
|
68
78
|
# returns the "language" part (like :en or :pt).
|
69
79
|
# If locale is invalid or nil, returns the default language.
|
data/lib/air18n/version.rb
CHANGED