lib/csl/locale/term.rb in csl-1.0.0.pre1 vs lib/csl/locale/term.rb in csl-1.0.0.pre2

- old
+ new

@@ -145,10 +145,13 @@ # @param options [Hash,nil] an optional configuration hash # # @option options [:singular,:plural] :number (:singular) whether to # return the term's singular or plural variant. + # @option options [Boolean] :plural (false) whether or not to return + # the term's plural variant (this option, if set, takes precedence + # over :number). # # @return [String] the term as a string def to_s(options = nil) if textnode? text @@ -167,15 +170,22 @@ private def pluralize?(options) return false if options.nil? - key = options[:number] || options['number'] + case + when options.key?(:plural) || options.key?('plural') + options[:plural] || options['plural'] + when options.key?(:number) || options.key?('number') + key = options[:number] || options['number'] - if key.is_a?(Fixnum) || key.to_s =~ /^[+-]?\d+$/ - key.to_i > 1 + if key.is_a?(Fixnum) || key.to_s =~ /^[+-]?\d+$/ + key.to_i > 1 + else + !key.blank? && key.to_s =~ /^plural/i + end else - !key.blank? && key.to_s =~ /^plural/i + false end end end \ No newline at end of file