forked from chatelao/php-addressbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
translate_inc_to_po.php
71 lines (64 loc) · 1.9 KB
/
translate_inc_to_po.php
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Description" content="PHP-Addressbook" />
<meta name="Keywords" content="" />
<link rel="icon" type="image/png" href="<?php echo $url_images; ?>icons/font.png" />
<title>Translate</title>
</head>
<body>
<?php
include "include/translation.ua.php";
include "include/translation.no.php";
if(isset($_GET['lang'])) {
function extractLang($lang, $is_pot) {
global $messages;
$str = '# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-10-25 14:49+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
';
foreach($messages as $key => $message) {
if(isset($message[$lang]) || $is_pot) {
$str .= 'msgid "'.$key.'"'."\n";
if(isset($_GET['pot'])) {
$str .= '""'."\n";
} else {
$str .= 'msgstr "'.$message[$lang].'"'."\n";
}
$str .= "\n";
}
}
return $str;
}
/*
if(false){
/*/
if(true){
// */
echo extractLang($_GET['lang'], isset($_GET['pot']));
} else {
$trans = extractLang("en", true);
file_put_contents ( "translations/php-addressbook.pot", $trans);
foreach($supported_langs as $lang) {
$trans = extractLang($lang, false);
$res = file_put_contents ( "translations/".$lang.".po", $trans);
echo "Wrote $lang: $res<br>";
}
}
}
?>