forked from webERP-team/webERP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Z_poEditLangHeader.php
114 lines (85 loc) · 4.2 KB
/
Z_poEditLangHeader.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
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
<?php
/* Steve Kitchen */
//$PageSecurity = 15;
include ('includes/session.php');
$Title = _('Edit Header');// _('Edit a Language File Header')
$ViewTopic = "SpecialUtilities";
$BookMark = "Z_poEditLangHeader";// Anchor's id in the manual's html document.
include('includes/header.php');
echo '<p class="page_title_text"><img alt="" src="' . $RootPath . '/css/' . $Theme .
'/images/maintenance.png" title="' .
_('Edit a Language File Header') . '" />' . ' ' .
_('Edit a Language File Header') . '</p>';
/* Your webserver user MUST have read/write access to here, otherwise you'll be wasting your time */
echo '<br /> <a href="' . $RootPath . '/Z_poAdmin.php">' . _('Back to the translation menu') . '</a>';
echo '<br /><br /> ' . _('Utility to edit a language file header');
echo '<br /> ' . _('Current language is') . ' ' . $_SESSION['Language'];
$PathToLanguage = './locale/' . $_SESSION['Language'] . '/LC_MESSAGES/messages.po';
$PathToNewLanguage = './locale/' . $_SESSION['Language'] . '/LC_MESSAGES/messages.po.new';
$fpIn = fopen($PathToLanguage, 'r');
for ($i=1; $i<=17; $i++){ /* message.po header is 17 lines long - this is easily broken */
$LanguageHeader[$i] = fgets($fpIn);
}
if (isset($_POST['submit'])) {
echo '<br /><table><tr><td>';
echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
/* write the new header then the rest of the language file to a new file */
prnMsg (_('Writing the language file header') . '.....<br />', 'info', ' ');
$fpOut = fopen($PathToNewLanguage, 'w');
for ($i=1; $i<=17; $i++) {
$Result = fputs($fpOut, stripslashes(html_entity_decode($_POST['Header_'.$i]))."\n");
}
prnMsg (_('Writing the rest of the language file') . '.....<br />', 'info', ' ');
while (!feof($fpIn)) {
$FileContents = fgets($fpIn);
$Result = fputs($fpOut, $FileContents);
}
$Result = fclose($fpIn);
$Result = fclose($fpOut);
/* Done writing, now move the original file to a .old */
/* and the new one to the default */
if (file_exists($PathToLanguage . '.old')) {
$Result = rename($PathToLanguage . '.old', $PathToLanguage . '.bak');
}
$Result = rename($PathToLanguage, $PathToLanguage . '.old');
$Result = rename($PathToNewLanguage, $PathToLanguage);
if (file_exists($PathToLanguage . '.bak')) {
$Result = unlink($PathToLanguage . '.bak');
}
prnMsg (_('Done') . '<br />', 'info', ' ');
echo '</form>';
echo '</td></tr></table>';
} else {
$Result = fclose($fpIn);
if (!is_writable('./locale/' . $_SESSION['Language'])) {
prnMsg(_('You do not have write access to the required files please contact your system administrator'),'error');
}
else
{
echo '<br /><br /> ' . _('To change language click on the user name at the top left, change to language desired and click Modify');
echo '<br /> ' . _('Make sure you have selected the correct language to translate!');
echo '<br /> ' . _('When finished modifying you must click on Modify at the bottom in order to save changes');
echo '<div class="centre">';
echo '<br />';
prnMsg (_('Your existing translation file (messages.po) will be backed up as messages.po.old') . '<br /><br />' .
_('Make sure you know what you are doing BEFORE you edit the header'), 'info', _('PLEASE NOTE'));
echo '<br /></div>';
echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
echo '<table><tr><th" colspan="2" ALIGN="center">' . _('Language File Header for') . ' "' . $_POST['language'] . '"</th></tr>';
echo '<tr><td colspan="2"></td></tr>';
for ($i=1; $i<=17; $i++) {
echo '<tr>';
echo '<td>' . _('Header Line') . ' # ' . $i . '</td>';
echo '<td><input type="text" size="80" name="Header_' . $i . '" value="' . htmlspecialchars($LanguageHeader[$i]) . '" /></td>';
echo '</tr>';
}
echo '</table>';
echo '<br /><div class="centre"><input type="submit" name="submit" value="' . _('Modify') . '" /> ';
echo '<input type="hidden" name="language" value="' . $_POST['language'] . '" /></div>';
echo '</form>';
}
}
include('includes/footer.php');
?>