source: tools/po_convertor/lang_to_po.php

Last change on this file was 3, checked in by george, 14 years ago
  • Přidáno: Převaděč mezi lang a po jazykovými soubory.
File size: 1.0 KB
Line 
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);
10foreach($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);
33foreach($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
43file_put_contents($PoFileName, implode("\n", $Output));
44
45?>
Note: See TracBrowser for help on using the repository browser.