/usr/share/php/Horde/Support/Numerizer/Locale/De.php is in php-horde-support 2.2.0-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | <?php
/**
* Copyright 2010-2017 Horde LLC (http://www.horde.org/)
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @author Jan Schneider <jan@horde.org>
* @license http://www.horde.org/licenses/bsd BSD
* @category Horde
* @package Support
*/
/**
* @author Chuck Hagenbuch <chuck@horde.org>
* @author Jan Schneider <jan@horde.org>
* @license http://www.horde.org/licenses/bsd BSD
* @category Horde
* @package Support
*/
class Horde_Support_Numerizer_Locale_De extends Horde_Support_Numerizer_Locale_Base
{
public $DIRECT_NUMS = array(
'dreizehn' => 13,
'vierzehn' => 14,
'fünfzehn' => 15,
'sechzehn' => 16,
'siebzehn' => 17,
'achtzehn' => 18,
'neunzehn' => 19,
'ein[se]?' => 1,
'zwei' => 2,
'zwo' => 2,
'drei' => 3,
'vier' => 4,
'fünf' => 5,
'sechs' => 6,
'sieben' => 7,
'acht' => 8,
'neun' => 9,
'zehn' => 10,
'elf' => 11,
'zwölf' => 12,
);
public $TEN_PREFIXES = array(
'zwanzig' => 20,
'dreißig' => 30,
'vierzig' => 40,
'fünfzig' => 50,
'sechzig' => 60,
'siebzig' => 70,
'achtzig' => 80,
'neunzig' => 90,
);
public $BIG_PREFIXES = array(
'hundert' => 100,
'tausend' => 1000,
'million *' => 1000000,
'milliarde *' => 1000000000,
'billion *' => 1000000000000,
);
/**
* Rules:
*
* - there are irregular word for 11 and 12 like in English
* - numbers below one million are written together (1 M = "eine Million", 100 = "einhundert")
* - "a" is declinable (see above, "one" = "eins", "a" = "ein/eine")
* - numbers below 100 are flipped compared to english, and have an "and = "und" (21 = "twenty-one" = "einundzwanzig")
*/
public function numerize($string)
{
$string = $this->_replaceTenPrefixes($string);
$string = $this->_directReplacements($string);
$string = $this->_replaceBigPrefixes($string);
$string = $this->_fractionalAddition($string);
return $string;
}
/**
* ten, twenty, etc.
*/
protected function _replaceTenPrefixes($string)
{
foreach ($this->TEN_PREFIXES as $tp => $tp_replacement) {
$string = preg_replace_callback(
"/(?:$tp)( *\d(?=[^\d]|\$))*/i",
function ($m) use ($tp_replacement) {
return $tp_replacement + (isset($m[1]) ? (int)$m[1] : 0);
},
$string
);
}
return $string;
}
/**
* hundreds, thousands, millions, etc.
*/
protected function _replaceBigPrefixes($string)
{
foreach ($this->BIG_PREFIXES as $bp => $bp_replacement) {
$string = preg_replace_callback(
'/(\d*) *' . $bp . '(\d?)/i',
function ($m) use ($bp_replacement) {
$factor = (int)$m[1];
if (!$factor) {
$factor = 1;
}
return ($bp_replacement * $factor)
. ($bp_replacement == 100 ? ($m[2] ? 'und' : '') : 'und')
. $m[2];
},
$string
);
$string = $this->_andition($string);
}
return $string;
}
protected function _andition($string)
{
while (preg_match('/(\d+)((?: *und *)+)(\d*)(?=\w|$)/i', $string, $sc, PREG_OFFSET_CAPTURE)) {
$string = substr($string, 0, $sc[1][1])
. ((int)$sc[1][0] + (int)$sc[3][0])
. substr($string, $sc[3][1] + strlen($sc[3][0]));
}
return $string;
}
}
|