SOURCE CODE: Uize.Loc.Plurals.Langs.ru (view docs)

/*______________
|       ______  |   U I Z E    J A V A S C R I P T    F R A M E W O R K
|     /      /  |   ---------------------------------------------------
|    /    O /   |    MODULE : Uize.Loc.Plurals.Langs.ru Package
|   /    / /    |
|  /    / /  /| |    ONLINE : http://uize.com
| /____/ /__/_| | COPYRIGHT : (c)2015-2016 UIZE
|          /___ |   LICENSE : Available under MIT License or GNU General Public License
|_______________|             http://uize.com/license.html
*/

/* Module Meta Data
  type: Package
  importance: 1
  codeCompleteness: 100
  docCompleteness: 100
*/

/*?
  Introduction
    The =Uize.Loc.Plurals.Langs.ru= module implements a feature for determining a plural category from a number value for the ru language.

    *DEVELOPERS:* `Chris van Rensburg`

    Plural Categories
      ........................................................
      << table >>

      title: Plural Categories
      data:
      :| Category | Rule |
      :| one | v = 0 and i % 10 = 1 and i % 100 != 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001, … |
      :| few | v = 0 and i % 10 = 2..4 and i % 100 != 12..14 @integer 2~4, 22~24, 32~34, 42~44, 52~54, 62, 102, 1002, … |
      :| many | v = 0 and i % 10 = 0 or v = 0 and i % 10 = 5..9 or v = 0 and i % 100 = 11..14 @integer 0, 5~19, 100, 1000, 10000, 100000, 1000000, … |
      :| other |    @decimal 0.0~1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, … |
      ........................................................
*/

Uize.module ({
  name:'Uize.Loc.Plurals.Langs.ru',
  required:'Uize.Loc.Plurals.Util',
  builder:function () {
    'use strict';

    return Uize.package ({
      getPluralCategory:function (_value) {
        return Uize.Loc.Plurals.Util.getPluralCategory (
          _value,
          function (n,i,f,t,v,w,within) {
            return v == 0 && i % 10 == 1 && i % 100 != 11 ? 'one' : v == 0 && within (i % 10,[[2,4]]) && !within (i % 100,[[12,14]]) ? 'few' : v == 0 && i % 10 == 0 || v == 0 && within (i % 10,[[5,9]]) || v == 0 && within (i % 100,[[11,14]]) ? 'many' : 'other';
          }
        );
      }
    });
  }
});