[d3c216]: g.php  Maximize  Restore  History

Download this file

229 lines (161 with data), 6.0 kB

  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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?php
//php g.php &&
$list[]='index.shtml';//repair
$list[]='news.html';
$list[]='ssi/menu.html';
$list[]='releases/index.shtml';
/*
$list[]='releases/2010.4.0/en.shtml';
$list[]='releases/2010.2.0/en.shtml';
$list[]='releases/2009.4.0/en.shtml';
$list[]='releases/2009.2.0/en.shtml';
$list[]='releases/2010.0.0/en.shtml';
$list[]='releases/2010.0.0/en.shtml';
$list[]='releases/0.8.0/en.shtml';
$list[]='releases/0.7.0/en.shtml';
*/
$list[]='download/index.shtml';
$list[]='screenshots/index.shtml';
$list[]='tutorials/index.shtml';
$list[]='tutorials/architectural/en.shtml';
$list[]='tutorials/Blend-masks/en.shtml';
$list[]='tutorials/enblend-svg/en.shtml';
$list[]='tutorials/multi-lens/en.shtml';
$list[]='tutorials/overview/en.shtml';
$list[]='tutorials/scans/en.shtml';
$list[]='tutorials/tca/en.shtml';
$list[]='tutorials/auto-exposure/en.shtml';
$list[]='tutorials/calibration/en.shtml';
$list[]='tutorials/enfuse-360/en.shtml';
$list[]='tutorials/Mosaic-mode/en.shtml';
$list[]='tutorials/multi-row/en.shtml';
$list[]='tutorials/perspective/en.shtml';
$list[]='tutorials/surveying/en.shtml';
$list[]='tutorials/two-photos/en.shtml';
$list[]='docs/index.shtml';
$list[]='tech/index.shtml';//repair
$list[]='links/index.shtml';
$list[]='community/index.shtml';
$list[]='community/authors/index.shtml';
$list[]='community/charter/index.shtml';//repair
$minimal_list=array(
'index.shtml',
'news.html',
'ssi/menu.html',
'releases/index.shtml');
$Languages=array(
'cs'=>array(
'language'=>'cs',
'codeset'=>'cs_CZ.UTF-8',
'pages'=>$minimal_list, //pages to translate by gettext
'translated-pages'=>array( //before gettext translations
'releases/2011.2.0/en.shtml'=>'releases/2011.2.0/cs.shtml',
'releases/2010.0.0/en.shtml'=>'releases/2010.0.0/cs.shtml',
'releases/2009.4.0/en.shtml'=>'releases/2009.4.0/cs.shtml',
'releases/2009.2.0/en.shtml'=>'releases/2009.2.0/cs.shtml'
)
),
'de'=>array(
'language'=>'de',
'codeset'=>'de_DE.UTF-8',
'pages'=>$minimal_list,
'translated-pages'=>array(
'releases/2010.0.0/en.shtml'=>'releases/2010.0.0/de.shtml',
'releases/2010.4.0/en.shtml'=>'releases/2010.4.0/de.shtml',
'releases/2009.2.0/en.shtml'=>'releases/2009.2.0/de.shtml',
'releases/2011.2.0/en.shtml'=>'releases/2011.2.0/de.shtml',
'releases/2010.2.0/en.shtml'=>'releases/2010.2.0/de.shtml',
'releases/0.8.0/en.shtml'=>'releases/0.8.0/de.shtml',
'releases/2011.0.0/en.shtml'=>'releases/2011.0.0/de.shtml',
'releases/2009.4.0/en.shtml'=>'releases/2009.4.0/de.shtml'
)
));
require_once 'JSLikeHTMLElement.php';
Foreach($Languages as $LangId =>$Lang){
exec('msgfmt translation/'.$Lang['language'].'/LC_MESSAGES/messages.po');
// translation domain
$domain = "messages";
// affects directory
putenv ( "LANG=" . $Lang['language'] );
bind_textdomain_codeset($domain, "UTF8");
// language neviroment
setlocale(LC_ALL,$Lang['codeset']);
// dir with localization
bindtextdomain($domain, realpath("translation"));
// runs domain with translations
textdomain($domain);
$catalog=fopen('translation/'.$Lang['language'].'/LC_MESSAGES/catalog.pot','w+');
fwrite($catalog,
'# Hugin web translation
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: https://launchpad.net/hugin"
"\n"
"POT-Creation-Date: 2011-06-19 17:11-0400\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
');
foreach ($Lang['pages'] as $file){
if(!isset($Languages[$LangId]['translated-pages'][$file]))
{
if(substr($file,-6)=='.shtml'){
$newfilename=str_replace('.shtml','.'.$Lang['language'].'.shtml',$file);
}elseif(substr($file,-5)=='.html'){
$newfilename=str_replace('.html','.'.$Lang['language'].'.html',$file);
}
HandleFile($file,$newfilename);
$Languages[$LangId]['translated-pages'][$file]=$newfilename;
}
}
fclose($catalog);
exec('msguniq translation/'.$Lang['language'].'/LC_MESSAGES/catalog.pot > translation/'.$Lang['language'].'/LC_MESSAGES/catalog-u.pot');
if (file_exists('translation/'.$Lang['language'].'/LC_MESSAGES/messages.po')){
exec('msgmerge -U translation/'.$Lang['language'].'/LC_MESSAGES/messages.po translation/'.$Lang['language'].'/LC_MESSAGES/catalog-u.pot');
}else{
exec('msginit -o translation/'.$Lang['language'].'/LC_MESSAGES/messages.po -i translation/'.$Lang['language'].'/LC_MESSAGES/catalog-u.pot --no-translator -l'.$Lang['codeset']);
}
}
function HandleFile($Filename,$NewFilename){
global $catalog;
$dom_doc = new DOMDocument();
$dom_doc->registerNodeClass('DOMElement', 'JSLikeHTMLElement');
$html_file = file_get_contents($Filename);
// The next line will likely generate lots of warnings if your html isn't perfect
// Put an @ in front to suppress the warnings once you review them
$dom_doc->loadHTML( $html_file );
foreach(array('p','h1','h2','h3','title','li') as $tagname) {
$tags = $dom_doc->getElementsByTagName($tagname);
// Extract text value and replace with something else
foreach($tags as $tag) {
$tag_value = trim($tag->innerHTML);
if($tag_value!=''){
fwrite($catalog,"\n".
'#:'.$Filename."\n");
$rows=explode("\n",$tag_value);
$cnt=count($rows);
if($cnt>1){
fwrite($catalog, 'msgid ""'."\n");
$i=1;
foreach($rows as $row){
fwrite($catalog, ' "'.str_replace('"','\"',$row) .($i==$cnt?'':'\n').'"'."\n");
$i++;
}
}else{
fwrite($catalog, 'msgid "'.str_replace('"','\"',$tag_value) .'"'."\n");
}
fwrite($catalog,'msgstr ""'."\n");
}
$k=gettext($tag_value);
$tag->innerHTML=$k;
}
}
// save page with translated text
$translated_page = $dom_doc->saveHTML();
file_put_contents($NewFilename,$translated_page);
//echo $translated_page;
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks