Follow up r80376. Added missing file FORMAT.
[lhc/web/wiklou.git] / languages / classes / LanguageBe_tarask.php
1 <?php
2 /** Belarusian in Taraškievica orthography (Беларуская тарашкевіца)
3 *
4 * @ingroup Language
5 *
6 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
7 * @link http://be-x-old.wikipedia.org/wiki/Project_talk:LanguageBe_tarask.php
8 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
9 * @license http://www.gnu.org/copyleft/fdl.html GNU Free Documentation License
10 */
11
12 class LanguageBe_tarask extends Language {
13 /**
14 * Plural form transformations
15 *
16 * $wordform1 - singular form (for 1, 21, 31, 41...)
17 * $wordform2 - plural form (for 2, 3, 4, 22, 23, 24, 32, 33, 34...)
18 * $wordform3 - plural form (for 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 26...)
19 */
20
21 function convertPlural( $count, $forms ) {
22 if ( !count( $forms ) ) { return ''; }
23
24 // if no number with word, then use $form[0] for singular and $form[1] for plural or zero
25 if ( count( $forms ) === 2 ) return $count == 1 ? $forms[0] : $forms[1];
26
27 // FIXME: CLDR defines 4 plural forms instead of 3
28 // http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
29 $forms = $this->preConvertPlural( $forms, 3 );
30
31 if ( $count > 10 && floor( ( $count % 100 ) / 10 ) == 1 ) {
32 return $forms[2];
33 } else {
34 switch ( $count % 10 ) {
35 case 1: return $forms[0];
36 case 2:
37 case 3:
38 case 4: return $forms[1];
39 default: return $forms[2];
40 }
41 }
42 }
43
44 /*
45 * The Belarusian language uses apostrophe sign,
46 * but the characters used for this could be both U+0027 and U+2019.
47 * This function unifies apostrophe sign in search index values
48 * to enable seach using both apostrophe signs.
49 */
50 function normalizeForSearch( $string ) {
51 wfProfileIn( __METHOD__ );
52
53 # MySQL fulltext index doesn't grok utf-8, so we
54 # need to fold cases and convert to hex
55
56 # Replacing apostrophe sign U+2019 with U+0027
57 $s = preg_replace( '/\xe2\x80\x99/', '\'', $string );
58
59 $s = parent::normalizeForSearch( $s );
60
61 wfProfileOut( __METHOD__ );
62 return $s;
63 }
64
65 /*
66 * Four-digit number should be without group commas (spaces)
67 * So "1 234 567", "12 345" but "1234"
68 */
69 function commafy( $_ ) {
70 if ( preg_match( '/^-?\d{1,4}(\.\d*)?$/', $_ ) ) {
71 return $_;
72 } else {
73 return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
74 }
75 }
76 }