forked from PowerKiKi/qTranslate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qtranslate_configuration.php
651 lines (617 loc) · 33.4 KB
/
qtranslate_configuration.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
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
<?php // encoding: utf-8
/* Copyright 2008 Qian Qin (email : [email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* qTranslate Management Interface */
function qtrans_adminMenu() {
global $menu, $submenu, $q_config;
/* Configuration Page */
add_options_page(__('Language Management', 'qtranslate'), __('Languages', 'qtranslate'), 'manage_options', 'qtranslate', 'qtranslate_conf');
/* Language Switcher for Admin */
// don't display menu if there is only 1 language active
if(sizeof($q_config['enabled_languages']) <= 1) return;
// generate menu with flags for every enabled language
foreach($q_config['enabled_languages'] as $id => $language) {
$link = add_query_arg('lang', $language);
$link = (strpos($link, "wp-admin/") === false) ? preg_replace('#[^?&]*/#i', '', $link) : preg_replace('#[^?&]*wp-admin/#i', '', $link);
if(strpos($link, "?")===0||strpos($link, "index.php?")===0) {
if(current_user_can('manage_options'))
$link = 'options-general.php?page=qtranslate&godashboard=1&lang='.$language;
else
$link = 'edit.php?lang='.$language;
}
add_menu_page(__($q_config['language_name'][$language], 'qtranslate'), __($q_config['language_name'][$language], 'qtranslate'), 'read', $link, NULL, trailingslashit(WP_CONTENT_URL).$q_config['flag_location'].$q_config['flag'][$language]);
}
}
function qtranslate_language_form($lang = '', $language_code = '', $language_name = '', $language_locale = '', $language_date_format = '', $language_time_format = '', $language_flag ='', $language_na_message = '', $language_default = '', $original_lang='') {
global $q_config;
?>
<input type="hidden" name="original_lang" value="<?php echo $original_lang; ?>" />
<div class="form-field">
<label for="language_code"><?php _e('Language Code', 'qtranslate') ?></label>
<input name="language_code" id="language_code" type="text" value="<?php echo $language_code; ?>" size="2" maxlength="2"/>
<p><?php _e('2-Letter <a href="http://www.w3.org/WAI/ER/IG/ert/iso639.htm#2letter">ISO Language Code</a> for the Language you want to insert. (Example: en)', 'qtranslate'); ?></p>
</div>
<div class="form-field">
<label for="language_flag"><?php _e('Flag', 'qtranslate') ?></label>
<?php
$files = array();
if($dir_handle = @opendir(trailingslashit(WP_CONTENT_DIR).$q_config['flag_location'])) {
while (false !== ($file = readdir($dir_handle))) {
if(preg_match("/\.(jpeg|jpg|gif|png)$/i",$file)) {
$files[] = $file;
}
}
sort($files);
}
if(sizeof($files)>0){
?>
<select name="language_flag" id="language_flag" onchange="switch_flag(this.value);" onclick="switch_flag(this.value);" onkeypress="switch_flag(this.value);">
<?php
foreach ($files as $file) {
?>
<option value="<?php echo $file; ?>" <?php echo ($language_flag==$file)?'selected="selected"':''?>><?php echo $file; ?></option>
<?php
}
?>
</select>
<img src="" alt="Flag" id="preview_flag" style="vertical-align:middle; display:none"/>
<?php
} else {
_e('Incorrect Flag Image Path! Please correct it!', 'qtranslate');
}
?>
<p><?php _e('Choose the corresponding country flag for language. (Example: gb.png)', 'qtranslate'); ?></p>
</div>
<script type="text/javascript">
//<![CDATA[
function switch_flag(url) {
document.getElementById('preview_flag').style.display = "inline";
document.getElementById('preview_flag').src = "<?php echo trailingslashit(WP_CONTENT_URL).$q_config['flag_location'];?>" + url;
}
switch_flag(document.getElementById('language_flag').value);
//]]>
</script>
<div class="form-field">
<label for="language_name"><?php _e('Name', 'qtranslate') ?></label>
<input name="language_name" id="language_name" type="text" value="<?php echo $language_name; ?>"/>
<p><?php _e('The Name of the language, which will be displayed on the site. (Example: English)', 'qtranslate'); ?></p>
</div>
<div class="form-field">
<label for="language_locale"><?php _e('Locale', 'qtranslate') ?></label>
<input name="language_locale" id="language_locale" type="text" value="<?php echo $language_locale; ?>" size="5" maxlength="5"/>
<p>
<?php _e('PHP and Wordpress Locale for the language. (Example: en_US)', 'qtranslate'); ?><br />
<?php _e('You will need to install the .mo file for this language.', 'qtranslate'); ?>
</p>
</div>
<div class="form-field">
<label for="language_date_format"><?php _e('Date Format', 'qtranslate') ?></label>
<input name="language_date_format" id="language_date_format" type="text" value="<?php echo $language_date_format; ?>"/>
<p><?php _e('Depending on your Date / Time Conversion Mode, you can either enter a <a href="http://www.php.net/manual/function.strftime.php">strftime</a> (use %q for day suffix (st,nd,rd,th)) or <a href="http://www.php.net/manual/function.date.php">date</a> format. This field is optional. (Example: %A %B %e%q, %Y)', 'qtranslate'); ?></p>
</div>
<div class="form-field">
<label for="language_time_format"><?php _e('Time Format', 'qtranslate') ?></label>
<input name="language_time_format" id="language_time_format" type="text" value="<?php echo $language_time_format; ?>"/>
<p><?php _e('Depending on your Date / Time Conversion Mode, you can either enter a <a href="http://www.php.net/manual/function.strftime.php">strftime</a> or <a href="http://www.php.net/manual/function.date.php">date</a> format. This field is optional. (Example: %I:%M %p)', 'qtranslate'); ?></p>
</div>
<div class="form-field">
<label for="language_na_message"><?php _e('Not Available Message', 'qtranslate') ?></label>
<input name="language_na_message" id="language_na_message" type="text" value="<?php echo $language_na_message; ?>"/>
<p>
<?php _e('Message to display if post is not available in the requested language. (Example: Sorry, this entry is only available in %LANG:, : and %.)', 'qtranslate'); ?><br />
<?php _e('%LANG:<normal_seperator>:<last_seperator>% generates a list of languages seperated by <normal_seperator> except for the last one, where <last_seperator> will be used instead.', 'qtranslate'); ?><br />
</p>
</div>
<?php
}
function qtrans_checkSetting($var, $updateOption = false, $type = QT_STRING) {
global $q_config;
switch($type) {
case QT_URL:
$_POST[$var] = trailingslashit($_POST[$var]);
case QT_LANGUAGE:
case QT_STRING:
if(isset($_POST['submit']) && isset($_POST[$var])) {
if($type != QT_LANGUAGE || qtrans_isEnabled($_POST[$var])) {
$q_config[$var] = $_POST[$var];
}
if($updateOption) {
update_option('qtranslate_'.$var, $q_config[$var]);
}
return true;
} else {
return false;
}
break;
case QT_BOOLEAN:
if(isset($_POST['submit'])) {
if(isset($_POST[$var])&&$_POST[$var]==1) {
$q_config[$var] = true;
} else {
$q_config[$var] = false;
}
if($updateOption) {
if($q_config[$var]) {
update_option('qtranslate_'.$var, '1');
} else {
update_option('qtranslate_'.$var, '0');
}
}
return true;
} else {
return false;
}
break;
case QT_INTEGER:
if(isset($_POST['submit']) && isset($_POST[$var])) {
$q_config[$var] = intval($_POST[$var]);
if($updateOption) {
update_option('qtranslate_'.$var, $q_config[$var]);
}
return true;
} else {
return false;
}
break;
}
return false;
}
function qtrans_language_columns($columns) {
return array(
'flag' => 'Flag',
'name' => __('Name', 'qtranslate'),
'status' => __('Action', 'qtranslate'),
'status2' => '',
'status3' => ''
);
}
function qtranslate_conf() {
global $q_config, $wpdb;
// do redirection for dashboard
if(isset($_GET['godashboard'])) {
echo '<h2>'.__('Switching Language', 'qtranslate').'</h2>'.sprintf(__('Switching language to %1$s... If the Dashboard isn\'t loading, use this <a href="%2$s" title="Dashboard">link</a>.','qtranslate'),$q_config['language_name'][qtrans_getLanguage()],admin_url()).'<script type="text/javascript">document.location="'.admin_url().'";</script>';
exit();
}
// init some needed variables
$error = '';
$original_lang = '';
$language_code = '';
$language_name = '';
$language_locale = '';
$language_date_format = '';
$language_time_format = '';
$language_na_message = '';
$language_flag = '';
$language_default = '';
$altered_table = false;
$message = apply_filters('qtranslate_configuration_pre','');
// check for action
if(isset($_POST['qtranslate_reset']) && isset($_POST['qtranslate_reset2'])) {
$message = __('qTranslate has been reset.', 'qtranslate');
} elseif(isset($_POST['default_language'])) {
// save settings
qtrans_checkSetting('default_language', true, QT_LANGUAGE);
qtrans_checkSetting('flag_location', true, QT_URL);
qtrans_checkSetting('ignore_file_types', true, QT_STRING);
qtrans_checkSetting('detect_browser_language', true, QT_BOOLEAN);
qtrans_checkSetting('hide_untranslated', true, QT_INTEGER);
qtrans_checkSetting('use_strftime', true, QT_INTEGER);
qtrans_checkSetting('url_mode', true, QT_INTEGER);
qtrans_checkSetting('auto_update_mo', true, QT_BOOLEAN);
qtrans_checkSetting('hide_default_language', true, QT_BOOLEAN);
if(isset($_POST['update_mo_now']) && $_POST['update_mo_now']=='1' && qtrans_updateGettextDatabases(true))
$message = __('Gettext databases updated.', 'qtranslate');
}
if(isset($_POST['original_lang'])) {
// validate form input
if($_POST['language_na_message']=='') $error = __('The Language must have a Not-Available Message!', 'qtranslate');
if(strlen($_POST['language_locale'])<2) $error = __('The Language must have a Locale!', 'qtranslate');
if($_POST['language_name']=='') $error = __('The Language must have a name!', 'qtranslate');
if(strlen($_POST['language_code'])!=2) $error = __('Language Code has to be 2 characters long!', 'qtranslate');
if($_POST['original_lang']==''&&$error=='') {
// new language
if(isset($q_config['language_name'][$_POST['language_code']])) {
$error = __('There is already a language with the same Language Code!', 'qtranslate');
}
}
if($_POST['original_lang']!=''&&$error=='') {
// language update
if($_POST['language_code']!=$_POST['original_lang']&&isset($q_config['language_name'][$_POST['language_code']])) {
$error = __('There is already a language with the same Language Code!', 'qtranslate');
} else {
// remove old language
unset($q_config['language_name'][$_POST['original_lang']]);
unset($q_config['flag'][$_POST['original_lang']]);
unset($q_config['locale'][$_POST['original_lang']]);
unset($q_config['date_format'][$_POST['original_lang']]);
unset($q_config['time_format'][$_POST['original_lang']]);
unset($q_config['not_available'][$_POST['original_lang']]);
if(in_array($_POST['original_lang'],$q_config['enabled_languages'])) {
// was enabled, so set modified one to enabled too
for($i = 0; $i < sizeof($q_config['enabled_languages']); $i++) {
if($q_config['enabled_languages'][$i] == $_POST['original_lang']) {
$q_config['enabled_languages'][$i] = $_POST['language_code'];
}
}
}
if($_POST['original_lang']==$q_config['default_language'])
// was default, so set modified the default
$q_config['default_language'] = $_POST['language_code'];
}
}
if(get_magic_quotes_gpc()) {
if(isset($_POST['language_date_format'])) $_POST['language_date_format'] = stripslashes($_POST['language_date_format']);
if(isset($_POST['language_time_format'])) $_POST['language_time_format'] = stripslashes($_POST['language_time_format']);
}
if($error=='') {
// everything is fine, insert language
$q_config['language_name'][$_POST['language_code']] = $_POST['language_name'];
$q_config['flag'][$_POST['language_code']] = $_POST['language_flag'];
$q_config['locale'][$_POST['language_code']] = $_POST['language_locale'];
$q_config['date_format'][$_POST['language_code']] = $_POST['language_date_format'];
$q_config['time_format'][$_POST['language_code']] = $_POST['language_time_format'];
$q_config['not_available'][$_POST['language_code']] = $_POST['language_na_message'];
}
if($error!=''||isset($_GET['edit'])) {
// get old values in the form
$original_lang = $_POST['original_lang'];
$language_code = $_POST['language_code'];
$language_name = $_POST['language_name'];
$language_locale = $_POST['language_locale'];
$language_date_format = $_POST['language_date_format'];
$language_time_format = $_POST['language_time_format'];
$language_na_message = $_POST['language_na_message'];
$language_flag = $_POST['language_flag'];
$language_default = $_POST['language_default'];
}
} elseif(isset($_GET['convert'])){
// update language tags
global $wpdb;
$wpdb->show_errors();
foreach($q_config['enabled_languages'] as $lang) {
$wpdb->query('UPDATE '.$wpdb->posts.' set post_title = REPLACE(post_title, "[lang_'.$lang.']","<!--:'.$lang.'-->")');
$wpdb->query('UPDATE '.$wpdb->posts.' set post_title = REPLACE(post_title, "[/lang_'.$lang.']","<!--:-->")');
$wpdb->query('UPDATE '.$wpdb->posts.' set post_content = REPLACE(post_content, "[lang_'.$lang.']","<!--:'.$lang.'-->")');
$wpdb->query('UPDATE '.$wpdb->posts.' set post_content = REPLACE(post_content, "[/lang_'.$lang.']","<!--:-->")');
}
$message = "Database Update successful!";
} elseif(isset($_GET['markdefault'])){
// update language tags
global $wpdb;
$wpdb->show_errors();
$result = $wpdb->get_results('SELECT ID, post_title, post_content FROM '.$wpdb->posts.' WHERE NOT (post_content LIKE "%<!--:-->%" OR post_title LIKE "%<!--:-->%")');
foreach($result as $post) {
$content = qtrans_split($post->post_content);
$title = qtrans_split($post->post_title);
foreach($q_config['enabled_languages'] as $language) {
if($language != $q_config['default_language']) {
$content[$language] = "";
$title[$language] = "";
}
}
$content = qtrans_join($content);
$title = qtrans_join($title);
$wpdb->query('UPDATE '.$wpdb->posts.' set post_content = "'.mysql_escape_string($content).'", post_title = "'.mysql_escape_string($title).'" WHERE ID='.$post->ID);
}
$message = "All Posts marked as default language!";
} elseif(isset($_GET['edit'])){
$original_lang = $_GET['edit'];
$language_code = $_GET['edit'];
$language_name = $q_config['language_name'][$_GET['edit']];
$language_locale = $q_config['locale'][$_GET['edit']];
$language_date_format = $q_config['date_format'][$_GET['edit']];
$language_time_format = $q_config['time_format'][$_GET['edit']];
$language_na_message = $q_config['not_available'][$_GET['edit']];
$language_flag = $q_config['flag'][$_GET['edit']];
} elseif(isset($_GET['delete'])) {
// validate delete (protect code)
if($q_config['default_language']==$_GET['delete'])
$error = 'Cannot delete Default Language!';
if(!isset($q_config['language_name'][$_GET['delete']])||strtolower($_GET['delete'])=='code')
$error = 'No such language!';
if($error=='') {
// everything seems fine, delete language
qtrans_disableLanguage($_GET['delete']);
unset($q_config['language_name'][$_GET['delete']]);
unset($q_config['flag'][$_GET['delete']]);
unset($q_config['locale'][$_GET['delete']]);
unset($q_config['date_format'][$_GET['delete']]);
unset($q_config['time_format'][$_GET['delete']]);
unset($q_config['not_available'][$_GET['delete']]);
}
} elseif(isset($_GET['enable'])) {
// enable validate
if(!qtrans_enableLanguage($_GET['enable'])) {
$error = __('Language is already enabled or invalid!', 'qtranslate');
}
} elseif(isset($_GET['disable'])) {
// enable validate
if($_GET['disable']==$q_config['default_language'])
$error = __('Cannot disable Default Language!', 'qtranslate');
if(!qtrans_isEnabled($_GET['disable']))
if(!isset($q_config['language_name'][$_GET['disable']]))
$error = __('No such language!', 'qtranslate');
// everything seems fine, disable language
if($error=='' && !qtrans_disableLanguage($_GET['disable'])) {
$error = __('Language is already disabled!', 'qtranslate');
}
} elseif(isset($_GET['moveup'])) {
$languages = qtrans_getSortedLanguages();
$message = __('No such language!', 'qtranslate');
foreach($languages as $key => $language) {
if($language==$_GET['moveup']) {
if($key==0) {
$message = __('Language is already first!', 'qtranslate');
break;
}
$languages[$key] = $languages[$key-1];
$languages[$key-1] = $language;
$q_config['enabled_languages'] = $languages;
$message = __('New order saved.', 'qtranslate');
break;
}
}
} elseif(isset($_GET['movedown'])) {
$languages = qtrans_getSortedLanguages();
$message = __('No such language!', 'qtranslate');
foreach($languages as $key => $language) {
if($language==$_GET['movedown']) {
if($key==sizeof($languages)-1) {
$message = __('Language is already last!', 'qtranslate');
break;
}
$languages[$key] = $languages[$key+1];
$languages[$key+1] = $language;
$q_config['enabled_languages'] = $languages;
$message = __('New order saved.', 'qtranslate');
break;
}
}
}
$everything_fine = ((isset($_POST['submit'])||isset($_GET['delete'])||isset($_GET['enable'])||isset($_GET['disable'])||isset($_GET['moveup'])||isset($_GET['movedown']))&&$error=='');
if($everything_fine) {
// settings might have changed, so save
qtrans_saveConfig();
if(empty($message)) {
$message = __('Options saved.', 'qtranslate');
}
}
if($q_config['auto_update_mo']) {
if(!is_dir(WP_LANG_DIR) || !$ll = @fopen(trailingslashit(WP_LANG_DIR).'qtranslate.test','a')) {
$error = sprintf(__('Could not write to "%s", Gettext Databases could not be downloaded!', 'qtranslate'), WP_LANG_DIR);
} else {
@fclose($ll);
@unlink(trailingslashit(WP_LANG_DIR).'qtranslate.test');
}
}
// don't accidently delete/enable/disable twice
$clean_uri = preg_replace("/&(delete|enable|disable|convert|markdefault|moveup|movedown)=[^&#]*/i","",$_SERVER['REQUEST_URI']);
$clean_uri = apply_filters('qtranslate_clean_uri', $clean_uri);
// Generate XHTML
?>
<?php if ($message) : ?>
<div id="message" class="updated fade"><p><strong><?php echo $message; ?></strong></p></div>
<?php endif; ?>
<?php if ($error!='') : ?>
<div id="message" class="error fade"><p><strong><?php echo $error; ?></strong></p></div>
<?php endif; ?>
<?php if(isset($_GET['edit'])) { ?>
<div class="wrap">
<h2><?php _e('Edit Language', 'qtranslate'); ?></h2>
<form action="" method="post" id="qtranslate-edit-language">
<?php qtranslate_language_form($language_code, $language_code, $language_name, $language_locale, $language_date_format, $language_time_format, $language_flag, $language_na_message, $language_default, $original_lang); ?>
<p class="submit"><input type="submit" name="submit" value="<?php _e('Save Changes »', 'qtranslate'); ?>" /></p>
</form>
</div>
<?php } else { ?>
<div class="wrap">
<h2><?php _e('Language Management (qTranslate Configuration)', 'qtranslate'); ?></h2>
<div class="tablenav"><?php printf(__('For help on how to configure qTranslate correctly, take a look at the <a href="%1$s">qTranslate FAQ</a> and the <a href="%2$s">Support Forum</a>.', 'qtranslate'), 'http://www.qianqin.de/qtranslate/faq/', 'http://www.qianqin.de/qtranslate/forum/viewforum.php?f=3'); ?></div>
<form action="<?php echo $clean_uri;?>" method="post">
<h3><?php _e('General Settings', 'qtranslate') ?></h3>
<table class="form-table">
<tr>
<th scope="row"><?php _e('Default Language / Order', 'qtranslate') ?></th>
<td>
<fieldset><legend class="hidden"><?php _e('Default Language', 'qtranslate') ?></legend>
<?php
foreach ( qtrans_getSortedLanguages() as $key => $language ) {
echo "\t<label title='" . $q_config['language_name'][$language] . "'><input type='radio' name='default_language' value='" . $language . "'";
if ( $language == $q_config['default_language'] ) {
echo " checked='checked'";
}
echo ' />';
echo ' <a href="'.add_query_arg('moveup', $language, $clean_uri).'"><img src="'.WP_PLUGIN_URL.'/'.basename(__DIR__).'/arrowup.png" alt="up" /></a>';
echo ' <a href="'.add_query_arg('movedown', $language, $clean_uri).'"><img src="'.WP_PLUGIN_URL.'/'.basename(__DIR__).'/arrowdown.png" alt="down" /></a>';
echo ' <img src="' . trailingslashit(WP_CONTENT_URL) .$q_config['flag_location'].$q_config['flag'][$language] . '" alt="' . $q_config['language_name'][$language] . '" /> ';
echo ' '.$q_config['language_name'][$language] . "</label><br />\n";
}
?>
</br>
<?php printf(__('Choose the default language of your blog. This is the language which will be shown on %s. You can also change the order the languages by clicking on the arrows above.', 'qtranslate'), get_bloginfo('url')); ?>
</fieldset>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Untranslated Content', 'qtranslate');?></th>
<td>
<fieldset><legend class="hidden"><?php _e('URL Modification Mode', 'qtranslate') ?></legend>
<label title="Hide untranslated"><input type="radio" name="hide_untranslated" value="<?php echo QT_UNTRANSLATED_HIDE; ?>" <?php echo ($q_config['hide_untranslated']==QT_UNTRANSLATED_HIDE)?"checked=\"checked\"":""; ?> /> <?php _e('Hide Content which is not available for the selected language.', 'qtranslate'); ?></label><br />
<label title="Show messages"><input type="radio" name="hide_untranslated" value="<?php echo QT_UNTRANSLATED_MESSAGE; ?>" <?php echo ($q_config['hide_untranslated']==QT_UNTRANSLATED_MESSAGE)?"checked=\"checked\"":""; ?> /> <?php _e('Display a message showing all the languages the content is available in.', 'qtranslate'); ?></label><br />
<label title="Show default language"><input type="radio" name="hide_untranslated" value="<?php echo QT_UNTRANSLATED_DEFAULT; ?>" <?php echo ($q_config['hide_untranslated']==QT_UNTRANSLATED_DEFAULT)?"checked=\"checked\"":""; ?> /> <?php _e('Display the content in default language (or the first available language)', 'qtranslate'); ?></label><br />
</fieldset><br/>
<?php _e('This function will not work correctly if you installed qTranslate on a blog with existing entries. In this case you will need to take a look at "Convert Database" under "Advanced Settings".', 'qtranslate'); ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Detect Browser Language', 'qtranslate');?></th>
<td>
<label for="detect_browser_language"><input type="checkbox" name="detect_browser_language" id="detect_browser_language" value="1"<?php echo ($q_config['detect_browser_language'])?' checked="checked"':''; ?>/> <?php _e('Detect the language of the browser and redirect accordingly.', 'qtranslate'); ?></label>
<br/>
<?php _e('When the frontpage is visited via bookmark/external link/type-in, the visitor will be forwarded to the correct URL for the language specified by his browser.', 'qtranslate'); ?>
</td>
</tr>
</table>
<h3><?php _e('Advanced Settings', 'qtranslate') ?><span id="qtranslate-show-advanced" style="display:none"> (<a name="advanced_settings" href="#advanced_settings" onclick="showAdvanced();"><?php _e('Show', 'qtranslate'); ?></a>)</span></h3>
<table class="form-table" id="qtranslate-advanced">
<tr>
<th scope="row"><?php _e('URL Modification Mode', 'qtranslate') ?></th>
<td>
<fieldset><legend class="hidden"><?php _e('URL Modification Mode', 'qtranslate') ?></legend>
<label title="Query Mode"><input type="radio" name="url_mode" value="<?php echo QT_URL_QUERY; ?>" <?php echo ($q_config['url_mode']==QT_URL_QUERY)?"checked=\"checked\"":""; ?> /> <?php _e('Use Query Mode (?lang=en)', 'qtranslate'); ?></label><br />
<label title="Pre-Path Mode"><input type="radio" name="url_mode" value="<?php echo QT_URL_PATH; ?>" <?php echo ($q_config['url_mode']==QT_URL_PATH)?"checked=\"checked\"":""; ?> /> <?php _e('Use Pre-Path Mode (Default, puts /en/ in front of URL)', 'qtranslate'); ?></label><br />
<label title="Pre-Domain Mode"><input type="radio" name="url_mode" value="<?php echo QT_URL_DOMAIN; ?>" <?php echo ($q_config['url_mode']==QT_URL_DOMAIN)?"checked=\"checked\"":""; ?> /> <?php _e('Use Pre-Domain Mode (uses http://en.yoursite.com)', 'qtranslate'); ?></label><br />
</fieldset><br/>
<?php _e('Pre-Path and Pre-Domain mode will only work with mod_rewrite/pretty permalinks. Additional Configuration is needed for Pre-Domain mode!', 'qtranslate'); ?><br/>
<label for="hide_default_language"><input type="checkbox" name="hide_default_language" id="hide_default_language" value="1"<?php echo ($q_config['hide_default_language'])?' checked="checked"':''; ?>/> <?php _e('Hide URL language information for default language.', 'qtranslate'); ?></label>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Flag Image Path', 'qtranslate');?></th>
<td>
<?php echo trailingslashit(WP_CONTENT_URL); ?><input type="text" name="flag_location" id="flag_location" value="<?php echo $q_config['flag_location']; ?>" style="width:50%"/>
<br/>
<?php _e('Path to the flag images under wp-content, with trailing slash. (Default: plugins/qtranslate/flags/)', 'qtranslate'); ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Ignore Links', 'qtranslate');?></th>
<td>
<input type="text" name="ignore_file_types" id="ignore_file_types" value="<?php echo $q_config['ignore_file_types']; ?>" style="width:100%"/>
<br/>
<?php _e('Don\'t convert Links to files of the given file types. (Default: gif,jpg,jpeg,png,pdf,swf,tif,rar,zip,7z,mpg,divx,mpeg,avi,css,js)', 'qtranslate'); ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Update Gettext Databases', 'qtranslate');?></th>
<td>
<label for="auto_update_mo"><input type="checkbox" name="auto_update_mo" id="auto_update_mo" value="1"<?php echo ($q_config['auto_update_mo'])?' checked="checked"':''; ?>/> <?php _e('Automatically check for .mo-Database Updates of installed languages.', 'qtranslate'); ?></label>
<br/>
<label for="update_mo_now"><input type="checkbox" name="update_mo_now" id="update_mo_now" value="1" /> <?php _e('Update Gettext databases now.', 'qtranslate'); ?></label>
<br/>
<?php _e('qTranslate will query the Wordpress Localisation Repository every week and download the latest Gettext Databases (.mo Files).', 'qtranslate'); ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Date / Time Conversion', 'qtranslate');?></th>
<td>
<label><input type="radio" name="use_strftime" value="<?php echo QT_DATE; ?>" <?php echo ($q_config['use_strftime']==QT_DATE)?' checked="checked"':''; ?>/> <?php _e('Use emulated date function.', 'qtranslate'); ?></label><br />
<label><input type="radio" name="use_strftime" value="<?php echo QT_DATE_OVERRIDE; ?>" <?php echo ($q_config['use_strftime']==QT_DATE_OVERRIDE)?' checked="checked"':''; ?>/> <?php _e('Use emulated date function and replace formats with the predefined formats for each language.', 'qtranslate'); ?></label><br />
<label><input type="radio" name="use_strftime" value="<?php echo QT_STRFTIME; ?>" <?php echo ($q_config['use_strftime']==QT_STRFTIME)?' checked="checked"':''; ?>/> <?php _e('Use strftime instead of date.', 'qtranslate'); ?></label><br />
<label><input type="radio" name="use_strftime" value="<?php echo QT_STRFTIME_OVERRIDE; ?>" <?php echo ($q_config['use_strftime']==QT_STRFTIME_OVERRIDE)?' checked="checked"':''; ?>/> <?php _e('Use strftime instead of date and replace formats with the predefined formats for each language.', 'qtranslate'); ?></label><br />
<?php _e('Depending on the mode selected, additional customizations of the theme may be needed.', 'qtranslate'); ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Reset qTranslate', 'qtranslate');?></th>
<td>
<label for="qtranslate_reset"><input type="checkbox" name="qtranslate_reset" id="qtranslate_reset" value="1"/> <?php _e('Check this box and click Save Changes to reset all qTranslate settings.', 'qtranslate'); ?></label>
<br/>
<label for="qtranslate_reset2"><input type="checkbox" name="qtranslate_reset2" id="qtranslate_reset2" value="1"/> <?php _e('Yes, I really want to reset qTranslate.', 'qtranslate'); ?></label>
<br/>
<label for="qtranslate_reset3"><input type="checkbox" name="qtranslate_reset3" id="qtranslate_reset3" value="1"/> <?php _e('Also delete Translations for Categories/Tags/Link Categories.', 'qtranslate'); ?></label>
<br/>
<?php _e('If something isn\'t working correctly, you can always try to reset all qTranslate settings. A Reset won\'t delete any posts but will remove all settings (including all languages added).', 'qtranslate'); ?>
</td>
</tr>
<tr>
<th scope="row"><?php _e('Convert Database', 'qtranslate');?></th>
<td>
<?php printf(__('If you are updating from qTranslate 1.x or Polyglot, <a href="%s">click here</a> to convert posts to the new language tag format.', 'qtranslate'), $clean_uri.'&convert=true'); ?>
<?php printf(__('If you have installed qTranslate for the first time on a Wordpress with existing posts, you can either go through all your posts manually and save them in the correct language or <a href="%s">click here</a> to mark all existing posts as written in the default language.', 'qtranslate'), $clean_uri.'&markdefault=true'); ?>
<?php _e('Both processes are <b>irreversible</b>! Be sure to make a full database backup before clicking one of the links.', 'qtranslate'); ?>
</td>
</tr>
<tr>
<th scope="row"><?php _e('Debugging Information', 'qtranslate');?></th>
<td>
<p><?php printf(__('If you encounter any problems and you are unable to solve them yourself, you can visit the <a href="%s">Support Forum</a>. Posting the following Content will help other detect any misconfigurations.', 'qtranslate'), 'http://www.qianqin.de/qtranslate/forum/'); ?></p>
<textarea readonly="readonly" id="qtranslate_debug"><?php
$q_config_copy = $q_config;
// remove information to keep data anonymous and other not needed things
unset($q_config_copy['url_info']);
unset($q_config_copy['js']);
unset($q_config_copy['windows_locale']);
unset($q_config_copy['pre_domain']);
unset($q_config_copy['term_name']);
echo htmlspecialchars(print_r($q_config_copy, true));
?></textarea>
</td>
</tr>
</table>
<script type="text/javascript">
// <![CDATA[
function showAdvanced() {
document.getElementById('qtranslate-advanced').style.display='block';
document.getElementById('qtranslate-show-advanced').style.display='none';
return false;
}
if(location.hash!='#advanced_settings') {
document.getElementById('qtranslate-show-advanced').style.display='inline';
document.getElementById('qtranslate-advanced').style.display='none';
}
// ]]>
</script>
<?php do_action('qtranslate_configuration', $clean_uri); ?>
<p class="submit">
<input type="submit" name="submit" class="button-primary" value="<?php _e('Save Changes', 'qtranslate') ?>" />
</p>
</form>
</div>
<div class="wrap">
<h2><?php _e('Languages', 'qtranslate') ?></h2>
<div id="col-container">
<div id="col-right">
<div class="col-wrap">
<table class="widefat">
<thead>
<tr>
<?php print_column_headers('language'); ?>
</tr>
</thead>
<tfoot>
<tr>
<?php print_column_headers('language', false); ?>
</tr>
</tfoot>
<tbody id="the-list" class="list:cat">
<?php foreach($q_config['language_name'] as $lang => $language){ if($lang!='code') { ?>
<tr>
<td><img src="<?php echo trailingslashit(WP_CONTENT_URL).$q_config['flag_location'].$q_config['flag'][$lang]; ?>" alt="<?php echo $language; ?> Flag"></td>
<td><?php echo $language; ?></td>
<td><?php if(in_array($lang,$q_config['enabled_languages'])) { ?><a class="edit" href="<?php echo $clean_uri; ?>&disable=<?php echo $lang; ?>"><?php _e('Disable', 'qtranslate'); ?></a><?php } else { ?><a class="edit" href="<?php echo $clean_uri; ?>&enable=<?php echo $lang; ?>"><?php _e('Enable', 'qtranslate'); ?></a><?php } ?></td>
<td><a class="edit" href="<?php echo $clean_uri; ?>&edit=<?php echo $lang; ?>"><?php _e('Edit', 'qtranslate'); ?></a></td>
<td><?php if($q_config['default_language']==$lang) { ?><?php _e('Default', 'qtranslate'); ?><?php } else { ?><a class="delete" href="<?php echo $clean_uri; ?>&delete=<?php echo $lang; ?>"><?php _e('Delete', 'qtranslate'); ?></a><?php } ?></td>
</tr>
<?php }} ?>
</tbody>
</table>
<p><?php _e('Enabling a language will cause qTranslate to update the Gettext-Database for the language, which can take a while depending on your server\'s connection speed.','qtranslate');?></p>
</div>
</div><!-- /col-right -->
<div id="col-left">
<div class="col-wrap">
<div class="form-wrap">
<h3><?php _e('Add Language', 'qtranslate'); ?></h3>
<form name="addcat" id="addcat" method="post" class="add:the-list: validate">
<?php qtranslate_language_form($language_code, $language_code, $language_name, $language_locale, $language_date_format, $language_time_format, $language_flag, $language_default, $language_na_message); ?>
<p class="submit"><input type="submit" name="submit" value="<?php _e('Add Language »', 'qtranslate'); ?>" /></p>
</form></div>
</div>
</div><!-- /col-left -->
</div><!-- /col-container -->
<?php
}
}
?>