1 | <?php
|
---|
2 |
|
---|
3 | $SourceFileName = 'lang-en.php';
|
---|
4 | $PoFileName = 'boonex-dolphin-7-en.pot';
|
---|
5 |
|
---|
6 | // Build dictionary
|
---|
7 | $Dictionary = array();
|
---|
8 | $Source = file_get_contents($SourceFileName);
|
---|
9 | $Source = explode("\n", $Source);
|
---|
10 | foreach($Source as $Line)
|
---|
11 | {
|
---|
12 | $Parts = explode('=>', $Line);
|
---|
13 | if(count($Parts) == 2)
|
---|
14 | {
|
---|
15 | $MsgId = substr(trim($Parts[0]), 1, -1);
|
---|
16 | $MsgStr = trim($Parts[1]);
|
---|
17 | if(substr($MsgStr, -1) == ',') $MsgStr = substr($MsgStr, 0, -1);
|
---|
18 | $MsgStr = substr($MsgStr, 1, -1);
|
---|
19 | $Dictionary[$MsgStr] = '';
|
---|
20 | }
|
---|
21 | }
|
---|
22 |
|
---|
23 | // Create PO file
|
---|
24 | $Output = array(
|
---|
25 | '# Converted from Dolphin lang file',
|
---|
26 | 'msgid ""',
|
---|
27 | 'msgstr ""',
|
---|
28 | '"MIME-Version: 1.0\n"',
|
---|
29 | '"Content-Type: text/plain; charset=utf-8\n"',
|
---|
30 | '"Content-Transfer-Encoding: 8bit\n"',
|
---|
31 | '',
|
---|
32 | );
|
---|
33 | foreach($Dictionary as $Word => $Item)
|
---|
34 | {
|
---|
35 | $Word = str_replace("\\'", "'", $Word);
|
---|
36 | $Word = str_replace('"', '\"', $Word);
|
---|
37 | $Output[] = 'msgid "'.$Word.'"';
|
---|
38 | $Output[] = 'msgstr ""';
|
---|
39 | $Output[] = '';
|
---|
40 | }
|
---|
41 |
|
---|
42 |
|
---|
43 | file_put_contents($PoFileName, implode("\n", $Output));
|
---|
44 |
|
---|
45 | ?> |
---|