Repository navigation
Expand file tree
/
Copy pathselect_lang_pair.php
More file actions
131 lines (115 loc) · 4.02 KB
/
Copy pathselect_lang_pair.php
File metadata and controls
131 lines (115 loc) · 4.02 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
<?php
/**
* \file
* \brief Display Language Pair Selection Window for Wizard
*
* Call: select_lang_pair.php
*
* @author https://sourceforge.net/projects/lwt/ LWT Project
* @since 1.5.11
*/
require_once 'inc/session_utility.php';
require_once 'inc/langdefs.php';
/// Returns a dropdown menu of the different languages
function get_wizard_selectoptions($v): string
{
global $langDefs;
$r = "<option value=\"\"" . get_selected($v, "") . ">[Choose...]</option>";
$keys = array_keys($langDefs);
foreach ($keys as $item) {
$r .= "<option value=\"" . $item . "\"" . get_selected($v, $item) . ">" . $item . "</option>";
}
return $r;
}
pagestart_nobody('Language Settings Wizard', 'html{background-color: rgba(0, 0, 0, 0);}');
$currentnativelanguage = getSetting('currentnativelanguage');
?>
<script type="text/javascript">
//<![CDATA[
const LANGDEFS = <?php echo json_encode($langDefs); ?>;
/// Execute the wizard
function wizard_go() {
const l1 = $('#l1').val();
const l2 = $('#l2').val();
if (l1 == '') {
alert ('Please choose your native language (L1)!');
return;
}
if (l2 == '') {
alert ('Please choose your language you want to read/study (L2)!');
return;
}
if (l2 == l1) {
alert ('L1 L2 Languages must not be equal!');
return;
}
var w = window.opener;
if (typeof w == 'undefined') {
alert ('Language setting cannot be set. Please try again.');
wizard_exit();
}
var context = w.document;
$('input[name="LgName"]',context).val(l2);
$('input[name="LgDict1URI"]',context).val(
'https://de.glosbe.com/' + LANGDEFS[l2][0] + '/' +
LANGDEFS[l1][0] + '/lwt_term'
);
$('input[name="LgDict1PopUp"]', context).attr('checked', true);
$('input[name="LgGoogleTranslateURI"]',context).val(
'http://translate.google.com/?ie=UTF-8&sl=' +
LANGDEFS[l2][1] + '&tl=' + LANGDEFS[l1][1] + '&text=lwt_term'
);
$('input[name="LgGoogleTranslatePopUp"]', context).attr('checked', true);
$('input[name="LgTextSize"]',context).val(LANGDEFS[l2][2] ? 200 : 150);
$('input[name="LgRegexpSplitSentences"]',context).val(LANGDEFS[l2][4]);
$('input[name="LgRegexpWordCharacters"]',context).val(LANGDEFS[l2][3]);
$('select[name="LgSplitEachChar"]',context).val(LANGDEFS[l2][5] ? 1 : 0);
$('select[name="LgRemoveSpaces"]',context).val(LANGDEFS[l2][6] ? 1 : 0);
$('select[name="LgRightToLeft"]',context).val(LANGDEFS[l2][7] ? 1 : 0);
wizard_exit();
}
/// Closes the wizard
function wizard_exit() {
window.close();
}
$(function(){
$('.center').addClass('backlightyellow');
const bg = $('.center').css('background-color');
$('body').css('background-color',bg);
$('.center').removeClass('backlightyellow');
});
//]]>
</script>
<div class="center">
<p class="wizard">
<img src="icn/wizard.png" title="Language Settings Wizard" alt="Language Settings Wizard" />
</p>
<h1 class="wizard">
Language Settings Wizard
</h1>
<p class="wizard">
<b>My Native language is:</b>
<br />
L1:
<select name="l1" id="l1" onchange="{do_ajax_save_setting('currentnativelanguage',($('#l1').val()));}">
<?php echo get_wizard_selectoptions($currentnativelanguage); ?>
</select>
</p>
<p class="wizard">
<b>I want to study:</b>
<br />
L2:
<select name="l2" id="l2">
<?php echo get_wizard_selectoptions(''); ?>
</select>
</p>
<p class="wizard">
<input type="button" style="font-size:1.1em;" value="Set Language Settings" onclick="wizard_go();" />
</p>
<p class="wizard">
<input type="button" value="Cancel" onclick="wizard_exit();" />
</p>
</div>
<?php
pageend();
?>