Sha256: c1cdb8e35614cbce8c9c139a551278b3ad67208bc2ba8a9cde66aa77585833e9

Contents?: true

Size: 707 Bytes

Versions: 2

Compression:

Stored size: 707 Bytes

Contents

module RailsI18n
  module Pluralization
    module Serbian
      FROM_2_TO_4   = (2..4).to_a.freeze
      FROM_12_TO_14 = (12..14).to_a.freeze

      def self.rule
        lambda do |n|
          n ||= 0
          mod10 = n % 10
          mod100 = n % 100

          if mod10 == 1 && mod100 != 11
            :one
          elsif FROM_2_TO_4.include?(mod10) && !FROM_12_TO_14.include?(mod100)
            :few
          else
            :other
          end
        end
      end

      def self.with_locale(locale)
          { locale => {
              :i18n => {
                :plural => {
                  :keys => [:one, :few, :other],
                  :rule => rule }}}}
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails-i18n-7.0.3 lib/rails_i18n/common_pluralizations/serbian.rb
rails-i18n-7.0.2 lib/rails_i18n/common_pluralizations/serbian.rb