SOURCE CODE: Uize.Loc.Plurals.Langs.br

VIEW REFERENCE

/*______________
|       ______  |   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.br Package
|   /    / /    |
|  /    / /  /| |    ONLINE : http://uize.com
| /____/ /__/_| | COPYRIGHT : (c)2014 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.br= module implements a .

    *DEVELOPERS:* `Chris van Rensburg`

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

      title: Plural Categories
      data:
      :| Category | Rule |
      :| one | n % 10 = 1 and n % 100 != 11,71,91 @integer 1, 21, 31, 41, 51, 61, 81, 101, 1001, … @decimal 1.0, 21.0, 31.0, 41.0, 51.0, 61.0, 81.0, 101.0, 1001.0, … |
      :| two | n % 10 = 2 and n % 100 != 12,72,92 @integer 2, 22, 32, 42, 52, 62, 82, 102, 1002, … @decimal 2.0, 22.0, 32.0, 42.0, 52.0, 62.0, 82.0, 102.0, 1002.0, … |
      :| few | n % 10 = 3..4,9 and n % 100 != 10..19,70..79,90..99 @integer 3, 4, 9, 23, 24, 29, 33, 34, 39, 43, 44, 49, 103, 1003, … @decimal 3.0, 4.0, 9.0, 23.0, 24.0, 29.0, 33.0, 34.0, 103.0, 1003.0, … |
      :| many | n != 0 and n % 1000000 = 0 @integer 1000000, … @decimal 1000000.0, 1000000.00, 1000000.000, … |
      :| other |  @integer 0, 5~8, 10~20, 100, 1000, 10000, 100000, … @decimal 0.0~0.9, 1.1~1.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, … |
      ........................................................
*/

Uize.module ({
  name:'Uize.Loc.Plurals.Langs.br',
  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 n % 10 == 1 && within (n % 100,[11,71,91]) ? 'one' : n % 10 == 2 && within (n % 100,[12,72,92]) ? 'two' : within (n % 10,[[3,4],9]) && within (n % 100,[[10,19],[70,79],[90,99]]) ? 'few' : n != 0 && n % 1000000 == 0 ? 'many' : 'other';
          }
        );
      }
    });
  }
});