Rev 232 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 232 | Rev 289 | ||
---|---|---|---|
1 | <!DOCTYPE html> |
1 | <!DOCTYPE html> |
2 | <html lang="en""> |
2 | <html lang="en"> |
3 | <head> |
3 | <head> |
4 | <meta charset="UTF-8"> |
4 | <meta charset="UTF-8"> |
5 | <title>Golic Vulcan – Federation Standard English Dictionary</title> |
5 | <title>Golic Vulcan – Federation Standard English Dictionary</title> |
6 | <style type="text/css"> |
6 | <style type="text/css"> |
7 | body { |
7 | body { |
8 | font-family: serif; |
8 | font-family: serif; |
9 | } |
9 | } |
10 | 10 | ||
11 | ol |
11 | ol |
12 | { |
12 | { |
13 | padding-left: 0; |
13 | padding-left: 0; |
14 | list-style-type: none; |
14 | list-style-type: none; |
15 | } |
15 | } |
16 | 16 | ||
17 | ol li |
17 | ol li |
18 | { |
18 | { |
19 | margin-left: 0; |
19 | margin-left: 0; |
20 | } |
20 | } |
21 | 21 | ||
22 | ol ol |
22 | ol ol |
23 | { |
23 | { |
24 | padding-left: 1em; |
24 | padding-left: 1em; |
25 | } |
25 | } |
26 | 26 | ||
27 | .type-or-context { |
27 | .type-or-context { |
28 | font-family: sans-serif; |
28 | font-family: sans-serif; |
29 | font-size: small; |
29 | font-size: small; |
30 | font-weight: bold; |
30 | font-weight: bold; |
31 | } |
31 | } |
32 | 32 | ||
- | 33 | <?php
|
|
- | 34 | $source_lang = 'vuh-Latn-Gol'; |
|
- | 35 | ?>
|
|
- | 36 | i[lang="<?php echo $source_lang; ?>"] { |
|
- | 37 | font-style: normal; |
|
- | 38 | } |
|
- | 39 | ||
33 | i em { |
40 | i em { |
34 | font-weight: bold; |
41 | font-weight: bold; |
35 | } |
42 | } |
- | 43 | ||
- | 44 | #toggle { |
|
- | 45 | position: fixed; |
|
- | 46 | top: 0; |
|
- | 47 | right: 0; |
|
- | 48 | } |
|
36 | </style> |
49 | </style> |
- | 50 | <script type="text/javascript" src="/scripts/object.js"></script> |
|
- | 51 | <script type="text/javascript" src="/scripts/dom/xpath.js"></script> |
|
- | 52 | <script type="text/javascript">var LANG_VULCAN = '<?php echo $source_lang; ?>';</script> |
|
- | 53 | <script type="text/javascript" src="/application/scripts/vulcan-media-script.js"></script> |
|
37 | </head> |
54 | </head> |
38 | 55 | ||
39 | <body> |
56 | <body onload="document.getElementById('toggle').click()"> |
40 | <?php
|
57 | <?php
|
41 | $source_lang = 'vuh-Latn-Gol'; |
- | |
42 | $target_lang = 'en-Latn-Federation'; |
58 | $target_lang = 'en-Latn-Federation'; |
43 | $lines = file('vuh-gol-en.dict'); |
59 | $lines = file('vuh-gol-en.dict'); |
44 | ?>
|
60 | ?>
|
45 | <h1>Golic Vulcan – Federation Standard English Dictionary</h1> |
61 | <h1>Golic Vulcan – Federation Standard English Dictionary</h1> |
- | 62 | <button type="button" id="toggle" onclick="mediaScript(this)"><span class="text">Media Script</span></button> |
|
46 | <?php
|
63 | <?php
|
47 | define('REGEXP_PREFIX_EXAMPLE', '/^ex\s*=\s*/'); |
64 | define('REGEXP_PREFIX_EXAMPLE', '/^ex\s*=\s*/'); |
48 | 65 | ||
49 | if ($lines) |
66 | if ($lines) |
50 | {
|
67 | {
|
51 | $last_indent = -1; |
68 | $last_indent = -1; |
52 | $last_phrases = array(); |
69 | $last_phrases = array(); |
53 | 70 | ||
54 | foreach ($lines as $line) |
71 | foreach ($lines as $line) |
55 | {
|
72 | {
|
56 | preg_match('/^(?<lws>\s*)(?<phrase>[^:]+)\s*:\s*(?<transl>.+)/u', $line, $matches); |
73 | preg_match('/^(?<lws>\s*)(?<phrase>[^:]+)\s*:\s*(?<transl>.+)/u', $line, $matches); |
57 | // var_dump($matches);
|
74 | // var_dump($matches);
|
58 | if ($matches) |
75 | if ($matches) |
59 | {
|
76 | {
|
60 | $phrase = $matches['phrase']; |
77 | $phrase = $matches['phrase']; |
61 | 78 | ||
62 | if (mb_strpos($phrase, '#') === false) |
79 | if (mb_strpos($phrase, '#') === false) |
63 | {
|
80 | {
|
64 | $indent = mb_strlen($matches['lws']) / 2; |
81 | $indent = mb_strlen($matches['lws']) / 2; |
65 | 82 | ||
66 | if ($indent > $last_indent) |
83 | if ($indent > $last_indent) |
67 | {
|
84 | {
|
68 | echo '<ol>'; |
85 | echo '<ol>'; |
69 | }
|
86 | }
|
70 | else
|
87 | else
|
71 | {
|
88 | {
|
72 | echo str_repeat('</ol>', $last_indent - $indent); |
89 | echo str_repeat('</ol>', $last_indent - $indent); |
73 | }
|
90 | }
|
74 | 91 | ||
75 | echo '<li>'; |
92 | echo '<li>'; |
76 | 93 | ||
77 | $is_example = preg_match(REGEXP_PREFIX_EXAMPLE, $phrase); |
94 | $is_example = preg_match(REGEXP_PREFIX_EXAMPLE, $phrase); |
78 | if ($is_example) |
95 | if ($is_example) |
79 | {
|
96 | {
|
80 | $phrase = preg_replace(REGEXP_PREFIX_EXAMPLE, '', $phrase); |
97 | $phrase = preg_replace(REGEXP_PREFIX_EXAMPLE, '', $phrase); |
81 | }
|
98 | }
|
82 | 99 | ||
83 | if ($indent > $last_indent) |
100 | if ($indent > $last_indent) |
84 | {
|
101 | {
|
85 | $last_phrases[] = $phrase; |
102 | $last_phrases[] = $phrase; |
86 | }
|
103 | }
|
87 | else if ($indent < $last_indent) |
104 | else if ($indent < $last_indent) |
88 | {
|
105 | {
|
89 | $last_phrases = array_slice($last_phrases, 0, $indent + 1); |
106 | $last_phrases = array_slice($last_phrases, 0, $indent + 1); |
90 | }
|
107 | }
|
91 | 108 | ||
92 | if ($indent <= $last_indent) |
109 | if ($indent <= $last_indent) |
93 | {
|
110 | {
|
94 | $last_phrases[count($last_phrases) - 1] = $phrase; |
111 | $last_phrases[count($last_phrases) - 1] = $phrase; |
95 | }
|
112 | }
|
96 | 113 | ||
97 | $phrase = preg_replace( |
114 | $phrase = preg_replace( |
98 | array( |
115 | array( |
99 | '/~/', |
116 | '/~/', |
100 | '/[()]/', |
117 | '/[()]/', |
101 | ), |
118 | ), |
102 | array( |
119 | array( |
103 | '=', |
120 | '=', |
104 | '|', |
121 | '|', |
105 | ), |
122 | ), |
106 | $phrase); |
123 | $phrase); |
107 | 124 | ||
108 | if ($last_phrases) |
125 | if ($last_phrases) |
109 | {
|
126 | {
|
110 | end($last_phrases); |
127 | end($last_phrases); |
111 | 128 | ||
112 | while (($last_phrase = prev($last_phrases)) !== false) |
129 | while (($last_phrase = prev($last_phrases)) !== false) |
113 | {
|
130 | {
|
114 | while (mb_strlen($last_phrase) > 1) |
131 | while (mb_strlen($last_phrase) > 1) |
115 | {
|
132 | {
|
116 | if (preg_match('/' . preg_quote($last_phrase) . '/i', |
133 | if (preg_match('/' . preg_quote($last_phrase) . '/i', |
117 | $phrase, $last_sub_matches)) |
134 | $phrase, $last_sub_matches)) |
118 | {
|
135 | {
|
119 | $phrase = preg_replace('/' . $last_sub_matches[0] . '/i', |
136 | $phrase = preg_replace('/' . $last_sub_matches[0] . '/i', |
120 | '<u>\\0</u>', $phrase); |
137 | '<u>\\0</u>', $phrase); |
121 | break 2; |
138 | break 2; |
122 | }
|
139 | }
|
123 | 140 | ||
124 | $last_phrase = mb_strcut($last_phrase, 0, mb_strlen($last_phrase) - 1); |
141 | $last_phrase = mb_strcut($last_phrase, 0, mb_strlen($last_phrase) - 1); |
125 | }
|
142 | }
|
126 | }
|
143 | }
|
127 | }
|
144 | }
|
128 | 145 | ||
129 | $transl = preg_replace( |
146 | $transl = preg_replace( |
130 | array( |
147 | array( |
131 | '/"([^"]+)"/', |
148 | '/"([^"]+)"/', |
132 | '/\{([^\}]+)\}/', |
149 | '/\{([^\}]+)\}/', |
133 | '/(^|[\\s+\\[])\\/([\\s\\w\'()-]+)\\/(?=[,.;:\\s+\\]]|$)/u', |
150 | '/(^|[\\s+\\[])\\/([\\s\\w\'()-]+)\\/(?=[,.;:\\s+\\]]|$)/u', |
134 | '/\|(.*)(?<!\|)/', |
151 | '/\|(.*)(?<!\|)/', |
135 | '/\*(.+?)\*/', |
152 | '/\*(.+?)\*/', |
136 | '/\\s+~/', |
153 | '/\\s+~/', |
137 | ), |
154 | ), |
138 | array( |
155 | array( |
139 | '“\\1”', |
156 | '“\\1”', |
140 | '<abbr class="type-or-context" lang="' . $target_lang . '">\\1</abbr>', |
157 | '<abbr class="type-or-context" lang="' . $target_lang . '">\\1</abbr>', |
141 | '\\1<i lang="' . $source_lang . '">\\2</i>', |
158 | '\\1<i lang="' . $source_lang . '" class="text">\\2</i>', |
142 | '/\\1', |
159 | '/\\1', |
143 | '<em>\\1</em>', |
160 | '<em>\\1</em>', |
144 | ' ~', |
161 | ' ~', |
145 | ), |
162 | ), |
146 | $matches['transl']); |
163 | $matches['transl']); |
147 | 164 | ||
148 | echo ($is_example ? "<i lang='$source_lang'>" : "<b lang='$source_lang'>") |
165 | echo ($is_example ? "<i lang='$source_lang' class='text'>" : "<b lang='$source_lang' class='text'>") |
149 | . $phrase |
166 | . $phrase |
150 | . ($is_example ? '</i>' : '</b>') |
167 | . ($is_example ? '</i>' : '</b>') |
151 | . " <span lang='$target_lang'>" . $transl . '</span>'; |
168 | . " <span lang='$target_lang'>" . $transl . '</span>'; |
152 | 169 | ||
153 | $last_indent = $indent; |
170 | $last_indent = $indent; |
154 | }
|
171 | }
|
155 | }
|
172 | }
|
156 | }
|
173 | }
|
157 | echo '</ol>'; |
174 | echo '</ol>'; |
158 | 175 | ||
159 | // $phrases = array();
|
176 | // $phrases = array();
|
160 | 177 | ||
161 | // foreach ($lines as $line)
|
178 | // foreach ($lines as $line)
|
162 | // {
|
179 | // {
|
163 | // preg_match('/^(?<lws>\s*)(?<phrase>[^:]+)\s*:\s*(?<transl>.+)/u', $line, $matches);
|
180 | // preg_match('/^(?<lws>\s*)(?<phrase>[^:]+)\s*:\s*(?<transl>.+)/u', $line, $matches);
|
164 | // if ($matches)
|
181 | // if ($matches)
|
165 | // {
|
182 | // {
|
166 | // $phrase = $matches['phrase'];
|
183 | // $phrase = $matches['phrase'];
|
167 | 184 | ||
168 | // /* if not a comment */
|
185 | // /* if not a comment */
|
169 | // if (mb_strpos($phrase, '#') === false)
|
186 | // if (mb_strpos($phrase, '#') === false)
|
170 | // {
|
187 | // {
|
171 | // $transl = $matches['transl'];
|
188 | // $transl = $matches['transl'];
|
172 | 189 | ||
173 | // $is_example = preg_match(REGEXP_PREFIX_EXAMPLE, $phrase);
|
190 | // $is_example = preg_match(REGEXP_PREFIX_EXAMPLE, $phrase);
|
174 | // if ($is_example)
|
191 | // if ($is_example)
|
175 | // {
|
192 | // {
|
176 | // /* assign example to previous phrase; indentation irrelevant */
|
193 | // /* assign example to previous phrase; indentation irrelevant */
|
177 | // $phrase = preg_replace(REGEXP_PREFIX_EXAMPLE, '', $phrase);
|
194 | // $phrase = preg_replace(REGEXP_PREFIX_EXAMPLE, '', $phrase);
|
178 | 195 | ||
179 | // $prev_phrase['examples'][$phrase] = $transl;
|
196 | // $prev_phrase['examples'][$phrase] = $transl;
|
180 | // }
|
197 | // }
|
181 | // else
|
198 | // else
|
182 | // {
|
199 | // {
|
183 | // /* create new phrase */
|
200 | // /* create new phrase */
|
184 | // $level = mb_strlen($matches['lws']) / 2;
|
201 | // $level = mb_strlen($matches['lws']) / 2;
|
185 | 202 | ||
186 | // $phrases[$phrase] = array(
|
203 | // $phrases[$phrase] = array(
|
187 | // 'translation' => $transl,
|
204 | // 'translation' => $transl,
|
188 | // 'level' => $level
|
205 | // 'level' => $level
|
189 | // );
|
206 | // );
|
190 | // $prev_phrase =& $phrases[$phrase];
|
207 | // $prev_phrase =& $phrases[$phrase];
|
191 | // }
|
208 | // }
|
192 | // }
|
209 | // }
|
193 | // }
|
210 | // }
|
194 | // }
|
211 | // }
|
195 | 212 | ||
196 | // // var_dump($phrases);
|
213 | // // var_dump($phrases);
|
197 | 214 | ||
198 | // if ($phrases)
|
215 | // if ($phrases)
|
199 | // {
|
216 | // {
|
200 | // $prev_level = -1;
|
217 | // $prev_level = -1;
|
201 | 218 | ||
202 | // foreach ($phrases as $phrase => $data)
|
219 | // foreach ($phrases as $phrase => $data)
|
203 | // {
|
220 | // {
|
204 | // $level = $data['level'];
|
221 | // $level = $data['level'];
|
205 | 222 | ||
206 | // if ($level > $prev_level)
|
223 | // if ($level > $prev_level)
|
207 | // {
|
224 | // {
|
208 | // echo "\n<ol>\n";
|
225 | // echo "\n<ol>\n";
|
209 | // }
|
226 | // }
|
210 | // else if ($level < $prev_level)
|
227 | // else if ($level < $prev_level)
|
211 | // {
|
228 | // {
|
212 | // echo str_repeat("</ol>\n", $prev_level - $level);
|
229 | // echo str_repeat("</ol>\n", $prev_level - $level);
|
213 | // }
|
230 | // }
|
214 | 231 | ||
215 | // $translation = $data['translation'];
|
232 | // $translation = $data['translation'];
|
216 | 233 | ||
217 | // echo "\n<li>$prev_level => $level <b lang='$source_lang'>" . htmlspecialchars($phrase) . '</b>'
|
234 | // echo "\n<li>$prev_level => $level <b lang='$source_lang'>" . htmlspecialchars($phrase) . '</b>'
|
218 | // . " <span lang='$target_lang'>" . $translation . '</span>';
|
235 | // . " <span lang='$target_lang'>" . $translation . '</span>';
|
219 | 236 | ||
220 | // if (isset($data['examples']))
|
237 | // if (isset($data['examples']))
|
221 | // {
|
238 | // {
|
222 | // echo '<ul>';
|
239 | // echo '<ul>';
|
223 | 240 | ||
224 | // foreach ($data['examples'] as $original => $translation)
|
241 | // foreach ($data['examples'] as $original => $translation)
|
225 | // {
|
242 | // {
|
226 | // echo "<li><i lang='$source_lang'>" . htmlspecialchars($original) . '</i>'
|
243 | // echo "<li><i lang='$source_lang'>" . htmlspecialchars($original) . '</i>'
|
227 | // . " <span lang='$target_lang'>" . $translation . '</span></li>';
|
244 | // . " <span lang='$target_lang'>" . $translation . '</span></li>';
|
228 | // }
|
245 | // }
|
229 | 246 | ||
230 | // echo '</ul>';
|
247 | // echo '</ul>';
|
231 | // }
|
248 | // }
|
232 | 249 | ||
233 | // $prev_level = $level;
|
250 | // $prev_level = $level;
|
234 | // }
|
251 | // }
|
235 | 252 | ||
236 | // echo '</ol>';
|
253 | // echo '</ol>';
|
237 | // }
|
254 | // }
|
238 | ?>
|
255 | ?>
|
239 | <?php } ?> |
256 | <?php } ?> |
240 | </body> |
257 | </body> |
241 | </html> |
258 | </html> |