1// Copyright 2016 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5//go:build ignore 6// +build ignore 7 8package main 9 10// Form defines a plural form. 11// 12// Not all languages support all forms. Also, the meaning of each form varies 13// per language. It is important to note that the name of a form does not 14// necessarily correspond one-to-one with the set of numbers. For instance, 15// for Croation, One matches not only 1, but also 11, 21, etc. 16// 17// Each language must at least support the form "other". 18type Form byte 19 20const ( 21 Other Form = iota 22 Zero 23 One 24 Two 25 Few 26 Many 27) 28 29var countMap = map[string]Form{ 30 "other": Other, 31 "zero": Zero, 32 "one": One, 33 "two": Two, 34 "few": Few, 35 "many": Many, 36} 37 38type pluralCheck struct { 39 // category: 40 // 3..7: opID 41 // 0..2: category 42 cat byte 43 setID byte 44} 45 46// opID identifies the type of operand in the plural rule, being i, n or f. 47// (v, w, and t are treated as filters in our implementation.) 48type opID byte 49 50const ( 51 opMod opID = 0x1 // is '%' used? 52 opNotEqual opID = 0x2 // using "!=" to compare 53 opI opID = 0 << 2 // integers after taking the absolute value 54 opN opID = 1 << 2 // full number (must be integer) 55 opF opID = 2 << 2 // fraction 56 opV opID = 3 << 2 // number of visible digits 57 opW opID = 4 << 2 // number of visible digits without trailing zeros 58 opBretonM opID = 5 << 2 // hard-wired rule for Breton 59 opItalian800 opID = 6 << 2 // hard-wired rule for Italian 60 opAzerbaijan00s opID = 7 << 2 // hard-wired rule for Azerbaijan 61) 62const ( 63 // Use this plural form to indicate the next rule needs to match as well. 64 // The last condition in the list will have the correct plural form. 65 andNext = 0x7 66 formMask = 0x7 67 68 opShift = 3 69 70 // numN indicates the maximum integer, or maximum mod value, for which we 71 // have inclusion masks. 72 numN = 100 73 // The common denominator of the modulo that is taken. 74 maxMod = 100 75) 76