1 | <?php namespace Fisharebest\Localization; |
||
10 | class Translation |
||
11 | { |
||
12 | // Constants for processing .MO files |
||
13 | const MO_MAGIC_LITTLE_ENDIAN = '950412de'; |
||
14 | const MO_MAGIC_BIG_ENDIAN = 'de120495'; |
||
15 | const PACK_LITTLE_ENDIAN = 'V'; |
||
16 | const PACK_BIG_ENDIAN = 'N'; |
||
17 | |||
18 | /** @var array An association of English -> translated messages */ |
||
19 | private $translations; |
||
20 | |||
21 | /** |
||
22 | * The code for this variant. |
||
23 | * |
||
24 | * @param string $filename |
||
25 | */ |
||
26 | public function __construct($filename) |
||
57 | |||
58 | /** |
||
59 | * The translation strings |
||
60 | * |
||
61 | * @return array |
||
62 | */ |
||
63 | public function asArray() |
||
67 | |||
68 | /** |
||
69 | * Read specific binary data (32 bit words) from a .MO file |
||
70 | * |
||
71 | * @param resource $fp |
||
72 | * @param int $offset |
||
73 | * @param int $count |
||
74 | * @param string $pack "N" for big-endian, "V" for little-endian |
||
75 | * |
||
76 | * @return int[] |
||
77 | */ |
||
78 | private function readMoWords($fp, $offset, $count, $pack) |
||
84 | |||
85 | /** |
||
86 | * Read and parse a .MO (gettext) file |
||
87 | * |
||
88 | * @link https://www.gnu.org/software/gettext/manual/html_node/MO-Files.html |
||
89 | * |
||
90 | * @param resource $fp |
||
91 | * |
||
92 | * @return void |
||
93 | */ |
||
94 | private function readMoFile($fp) |
||
125 | } |
||
126 |