16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/ordinalize_full.rb', line 16
def ordinalize_in_full(gender: :masculine, plurality: :singular)
case I18n.locale
when :fr
value = I18n.t("ordinalize_full.n_#{self}_#{gender}", throw: false, default: "")
value = I18n.t("ordinalize_full.n_#{self}", throw: true) if value.empty?
value
when :es
value = I18n.t("ordinalize_full.n_#{self}", throw: false, default: "")
if value.empty?
value = [
I18n.t("ordinalize_full.n_#{(self / 10) * 10}", throw: true),
I18n.t("ordinalize_full.n_#{self % 10}", throw: true)
].join(" ")
end
value = value.split.map { |part| part.chop << "a" }.join(" ") if gender == :feminine
value << "s" if plurality == :plural
value = value.chop if value.end_with?("ero")
value
else
I18n.t("ordinalize_full.n_#{self}", throw: true)
end
rescue ArgumentError
raise NotImplementedError, "Unknown locale #{I18n.locale}"
end
|