// Copyright 2012 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview Ordinal rules.
 *
 * This file is autogenerated by script:
 *   http://go/generate_pluralrules.py
 * File generated from CLDR ver. 24
 *
 * Before check in, this file could have been manually edited. This is to
 * incorporate changes before we could fix CLDR. All manual modification must be
 * documented in this section, and should be removed after those changes land to
 * CLDR.
 */

goog.provide('goog.i18n.ordinalRules');
/**
 * Ordinal pattern keyword
 * @enum {string}
 */
goog.i18n.ordinalRules.Keyword = {
  ZERO: 'zero',
  ONE: 'one',
  TWO: 'two',
  FEW: 'few',
  MANY: 'many',
  OTHER: 'other'
};


/**
 * Default Ordinal select rule.
 * @param {number} n The count of items.
 * @param {number=} opt_precision optional, precision.
 * @return {goog.i18n.ordinalRules.Keyword} Default value.
 * @private
 */
goog.i18n.ordinalRules.defaultSelect_ = function(n, opt_precision) {
  return goog.i18n.ordinalRules.Keyword.OTHER;
};

/**
 * Returns the fractional part of a number (3.1416 => 1416)
 * @param {number} n The count of items.
 * @return {number} The fractional part.
 * @private
 */
goog.i18n.ordinalRules.decimals_ = function(n) {
  var str = n + '';
  var result = str.indexOf('.');
  return (result == -1) ? 0 : str.length - result - 1;
};

/**
 * Calculates v and f as per CLDR plural rules.
 * @param {number} n The count of items.
 * @param {number=} opt_precision optional, precision.
 * @return {Object} The v and f.
 * @private
 */
goog.i18n.ordinalRules.get_vf_ = function(n, opt_precision) {
  var DEFAULT_DIGITS = 3;

  if (undefined === opt_precision) {
    var v = Math.min(goog.i18n.ordinalRules.decimals_(n), DEFAULT_DIGITS);
  } else {
    var v = opt_precision;
  }

  var base = Math.pow(10, v);
  var f = ((n * base) | 0) % base;

  return {'v': v, 'f': f};
};

/**
 * Calculates w and t as per CLDR plural rules.
 * @param {number} v Calculated previously.
 * @param {number} f Calculated previously.
 * @return {Object} The w and t.
 * @private
 */
goog.i18n.ordinalRules.get_wt_ = function(v, f) {
  if (f === 0) {
    return {'w': 0, 't': 0};
  }

  while ((f % 10) === 0) {
    f /= 10;
    v--;
  }

  return {'w': v, 't': f};
};

/**
 * Ordinal select rules for en locale
 *
 * @param {number} n  The count of items.
 * @param {number=} opt_precision Precision for number formatting, if not default.
 * @return {goog.i18n.ordinalRules.Keyword} Locale-specific ordinal value.
 * @private
 */
goog.i18n.ordinalRules.enSelect_ = function(n, opt_precision) {
  if (n % 10 == 1 && n % 100 != 11) {
    return goog.i18n.ordinalRules.Keyword.ONE;
  }
  if (n % 10 == 2 && n % 100 != 12) {
    return goog.i18n.ordinalRules.Keyword.TWO;
  }
  if (n % 10 == 3 && n % 100 != 13) {
    return goog.i18n.ordinalRules.Keyword.FEW;
  }
  return goog.i18n.ordinalRules.Keyword.OTHER;
};

/**
 * Ordinal select rules for sv locale
 *
 * @param {number} n  The count of items.
 * @param {number=} opt_precision Precision for number formatting, if not default.
 * @return {goog.i18n.ordinalRules.Keyword} Locale-specific ordinal value.
 * @private
 */
goog.i18n.ordinalRules.svSelect_ = function(n, opt_precision) {
  if ((n % 10 == 1 || n % 10 == 2) && n % 100 != 11 && n % 100 != 12) {
    return goog.i18n.ordinalRules.Keyword.ONE;
  }
  return goog.i18n.ordinalRules.Keyword.OTHER;
};

/**
 * Ordinal select rules for fr locale
 *
 * @param {number} n  The count of items.
 * @param {number=} opt_precision Precision for number formatting, if not default.
 * @return {goog.i18n.ordinalRules.Keyword} Locale-specific ordinal value.
 * @private
 */
goog.i18n.ordinalRules.frSelect_ = function(n, opt_precision) {
  if (n == 1) {
    return goog.i18n.ordinalRules.Keyword.ONE;
  }
  return goog.i18n.ordinalRules.Keyword.OTHER;
};

/**
 * Ordinal select rules for hu locale
 *
 * @param {number} n  The count of items.
 * @param {number=} opt_precision Precision for number formatting, if not default.
 * @return {goog.i18n.ordinalRules.Keyword} Locale-specific ordinal value.
 * @private
 */
goog.i18n.ordinalRules.huSelect_ = function(n, opt_precision) {
  if (n == 1 || n == 5) {
    return goog.i18n.ordinalRules.Keyword.ONE;
  }
  return goog.i18n.ordinalRules.Keyword.OTHER;
};

/**
 * Ordinal select rules for zu locale
 *
 * @param {number} n  The count of items.
 * @param {number=} opt_precision Precision for number formatting, if not default.
 * @return {goog.i18n.ordinalRules.Keyword} Locale-specific ordinal value.
 * @private
 */
goog.i18n.ordinalRules.zuSelect_ = function(n, opt_precision) {
  if (n == 1) {
    return goog.i18n.ordinalRules.Keyword.ONE;
  }
  if (n >= 2 && n <= 9) {
    return goog.i18n.ordinalRules.Keyword.FEW;
  }
  if (n >= 10 && n <= 19 || n >= 100 && n <= 199 || n >= 1000 && n <= 1999) {
    return goog.i18n.ordinalRules.Keyword.MANY;
  }
  return goog.i18n.ordinalRules.Keyword.OTHER;
};

/**
 * Ordinal select rules for mr locale
 *
 * @param {number} n  The count of items.
 * @param {number=} opt_precision Precision for number formatting, if not default.
 * @return {goog.i18n.ordinalRules.Keyword} Locale-specific ordinal value.
 * @private
 */
goog.i18n.ordinalRules.mrSelect_ = function(n, opt_precision) {
  if (n == 1) {
    return goog.i18n.ordinalRules.Keyword.ONE;
  }
  if (n == 2 || n == 3) {
    return goog.i18n.ordinalRules.Keyword.TWO;
  }
  if (n == 4) {
    return goog.i18n.ordinalRules.Keyword.FEW;
  }
  return goog.i18n.ordinalRules.Keyword.OTHER;
};

/**
 * Ordinal select rules for ca locale
 *
 * @param {number} n  The count of items.
 * @param {number=} opt_precision Precision for number formatting, if not default.
 * @return {goog.i18n.ordinalRules.Keyword} Locale-specific ordinal value.
 * @private
 */
goog.i18n.ordinalRules.caSelect_ = function(n, opt_precision) {
  if (n == 1 || n == 3) {
    return goog.i18n.ordinalRules.Keyword.ONE;
  }
  if (n == 2) {
    return goog.i18n.ordinalRules.Keyword.TWO;
  }
  if (n == 4) {
    return goog.i18n.ordinalRules.Keyword.FEW;
  }
  return goog.i18n.ordinalRules.Keyword.OTHER;
};

/**
 * Ordinal select rules for bn locale
 *
 * @param {number} n  The count of items.
 * @param {number=} opt_precision Precision for number formatting, if not default.
 * @return {goog.i18n.ordinalRules.Keyword} Locale-specific ordinal value.
 * @private
 */
goog.i18n.ordinalRules.bnSelect_ = function(n, opt_precision) {
  if (n == 1 || n == 5 || n == 7 || n == 8 || n == 9 || n == 10) {
    return goog.i18n.ordinalRules.Keyword.ONE;
  }
  if (n == 2 || n == 3) {
    return goog.i18n.ordinalRules.Keyword.TWO;
  }
  if (n == 4) {
    return goog.i18n.ordinalRules.Keyword.FEW;
  }
  if (n == 6) {
    return goog.i18n.ordinalRules.Keyword.MANY;
  }
  return goog.i18n.ordinalRules.Keyword.OTHER;
};

/**
 * Ordinal select rules for it locale
 *
 * @param {number} n  The count of items.
 * @param {number=} opt_precision Precision for number formatting, if not default.
 * @return {goog.i18n.ordinalRules.Keyword} Locale-specific ordinal value.
 * @private
 */
goog.i18n.ordinalRules.itSelect_ = function(n, opt_precision) {
  if (n == 11 || n == 8 || n == 80 || n == 800) {
    return goog.i18n.ordinalRules.Keyword.MANY;
  }
  return goog.i18n.ordinalRules.Keyword.OTHER;
};

/**
 * Ordinal select rules for gu locale
 *
 * @param {number} n  The count of items.
 * @param {number=} opt_precision Precision for number formatting, if not default.
 * @return {goog.i18n.ordinalRules.Keyword} Locale-specific ordinal value.
 * @private
 */
goog.i18n.ordinalRules.guSelect_ = function(n, opt_precision) {
  if (n == 1) {
    return goog.i18n.ordinalRules.Keyword.ONE;
  }
  if (n == 2 || n == 3) {
    return goog.i18n.ordinalRules.Keyword.TWO;
  }
  if (n == 4) {
    return goog.i18n.ordinalRules.Keyword.FEW;
  }
  if (n == 6) {
    return goog.i18n.ordinalRules.Keyword.MANY;
  }
  return goog.i18n.ordinalRules.Keyword.OTHER;
};

/**
 * Selected Ordinal rules by locale.
 */
goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.enSelect_;
if (goog.LOCALE == 'af') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'am') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'ar') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'bg') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'bn') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.bnSelect_;
}
if (goog.LOCALE == 'br') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'ca') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.caSelect_;
}
if (goog.LOCALE == 'chr') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'cs') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'cy') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'da') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'de') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'de_AT' || goog.LOCALE == 'de-AT') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'de_CH' || goog.LOCALE == 'de-CH') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'el') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'en') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.enSelect_;
}
if (goog.LOCALE == 'en_AU' || goog.LOCALE == 'en-AU') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.enSelect_;
}
if (goog.LOCALE == 'en_GB' || goog.LOCALE == 'en-GB') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.enSelect_;
}
if (goog.LOCALE == 'en_IE' || goog.LOCALE == 'en-IE') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.enSelect_;
}
if (goog.LOCALE == 'en_IN' || goog.LOCALE == 'en-IN') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.enSelect_;
}
if (goog.LOCALE == 'en_ISO' || goog.LOCALE == 'en-ISO') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.enSelect_;
}
if (goog.LOCALE == 'en_SG' || goog.LOCALE == 'en-SG') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.enSelect_;
}
if (goog.LOCALE == 'en_US' || goog.LOCALE == 'en-US') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.enSelect_;
}
if (goog.LOCALE == 'en_ZA' || goog.LOCALE == 'en-ZA') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.enSelect_;
}
if (goog.LOCALE == 'es') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'es_419' || goog.LOCALE == 'es-419') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'es_ES' || goog.LOCALE == 'es-ES') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'et') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'eu') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'fa') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'fi') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'fil') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.frSelect_;
}
if (goog.LOCALE == 'fr') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.frSelect_;
}
if (goog.LOCALE == 'fr_CA' || goog.LOCALE == 'fr-CA') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.frSelect_;
}
if (goog.LOCALE == 'gl') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'gsw') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'gu') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.guSelect_;
}
if (goog.LOCALE == 'haw') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'he') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'hi') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.guSelect_;
}
if (goog.LOCALE == 'hr') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'hu') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.huSelect_;
}
if (goog.LOCALE == 'id') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'in') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'is') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'it') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.itSelect_;
}
if (goog.LOCALE == 'iw') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'ja') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'kn') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'ko') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'ln') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'lt') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'lv') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'ml') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'mo') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.frSelect_;
}
if (goog.LOCALE == 'mr') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.mrSelect_;
}
if (goog.LOCALE == 'ms') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.frSelect_;
}
if (goog.LOCALE == 'mt') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'nb') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'nl') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'no') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'or') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'pl') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'pt') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'pt_BR' || goog.LOCALE == 'pt-BR') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'pt_PT' || goog.LOCALE == 'pt-PT') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'ro') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.frSelect_;
}
if (goog.LOCALE == 'ru') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'sk') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'sl') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'sq') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'sr') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'sv') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.svSelect_;
}
if (goog.LOCALE == 'sw') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'ta') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'te') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'th') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'tl') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.frSelect_;
}
if (goog.LOCALE == 'tr') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'uk') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'ur') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'vi') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.frSelect_;
}
if (goog.LOCALE == 'zh') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'zh_CN' || goog.LOCALE == 'zh-CN') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'zh_HK' || goog.LOCALE == 'zh-HK') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'zh_TW' || goog.LOCALE == 'zh-TW') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.defaultSelect_;
}
if (goog.LOCALE == 'zu') {
  goog.i18n.ordinalRules.select = goog.i18n.ordinalRules.zuSelect_;
}
