Rev 224 | Rev 232 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 224 | Rev 230 | ||
|---|---|---|---|
| Line 2... | Line 2... | ||
| 2 | <html lang="en""> |
2 | <html lang="en""> |
| 3 | <head> |
3 | <head> |
| 4 | <meta charset="UTF-8"> |
4 | <meta charset="UTF-8"> |
| 5 | <title>Modern Golic Vulcan – Federation Standard English Dictionary</title> |
5 | <title>Modern Golic Vulcan – Federation Standard English Dictionary</title> |
| 6 | <style type="text/css"> |
6 | <style type="text/css"> |
| - | 7 | body {
|
|
| - | 8 | font-family: serif; |
|
| - | 9 | } |
|
| - | 10 | ||
| 7 | ol {
|
11 | ol |
| - | 12 | {
|
|
| 8 | padding-left: 0; |
13 | padding-left: 0; |
| 9 | list-style-type: none; |
14 | list-style-type: none; |
| 10 | } |
15 | } |
| 11 | 16 | ||
| 12 | ol li {
|
17 | ol li |
| - | 18 | {
|
|
| 13 | margin-left: 0; |
19 | margin-left: 0; |
| 14 | } |
20 | } |
| 15 | 21 | ||
| 16 | ol ol {
|
22 | ol ol |
| - | 23 | {
|
|
| 17 | padding-left: 1em; |
24 | padding-left: 1em; |
| 18 | } |
25 | } |
| - | 26 | ||
| - | 27 | .type-or-context {
|
|
| - | 28 | font-family: sans-serif; |
|
| - | 29 | font-size: small; |
|
| - | 30 | font-weight: bold; |
|
| - | 31 | } |
|
| - | 32 | ||
| - | 33 | i em {
|
|
| - | 34 | font-weight: bold; |
|
| - | 35 | } |
|
| 19 | </style> |
36 | </style> |
| 20 | </head> |
37 | </head> |
| 21 | 38 | ||
| 22 | <body> |
39 | <body> |
| 23 | <h1>Modern Golic Vulcan – Federation Standard English Dictionary</h1> |
- | |
| 24 | <?php
|
40 | <?php
|
| 25 | define('REGEXP_PREFIX_EXAMPLE', '/^ex\s*=\s*/'); |
- | |
| 26 | - | ||
| 27 | $source_lang = 'vuh-Latn-Gol-modern'; |
41 | $source_lang = 'vuh-Latn-Gol-modern'; |
| 28 | $target_lang = 'en-Latn-Federation'; |
42 | $target_lang = 'en-Latn-Federation'; |
| 29 | $lines = file('vul-gol-en.dict'); |
43 | $lines = file('vul-gol-en.dict'); |
| - | 44 | ?>
|
|
| - | 45 | <h1>Modern Golic Vulcan – Federation Standard English Dictionary</h1> |
|
| - | 46 | <?php
|
|
| - | 47 | define('REGEXP_PREFIX_EXAMPLE', '/^ex\s*=\s*/'); |
|
| 30 | 48 | ||
| 31 | if ($lines) |
49 | if ($lines) |
| 32 | {
|
50 | {
|
| 33 | $last_indent = -1; |
51 | $last_indent = -1; |
| 34 | $last_phrases = array(); |
52 | $last_phrases = array(); |
| Line 109... | Line 127... | ||
| 109 | }
|
127 | }
|
| 110 | 128 | ||
| 111 | $transl = preg_replace( |
129 | $transl = preg_replace( |
| 112 | array( |
130 | array( |
| 113 | '/"([^"]+)"/', |
131 | '/"([^"]+)"/', |
| 114 | '/\\/([\\s\\w\'()-]+)\\//u', |
132 | '/\{([^\}]+)\}/', |
| - | 133 | '/(^|[\\s+\\[])\\/([\\s\\w\'()-]+)\\/(?=[,.;:\\s+\\]]|$)/u', |
|
| 115 | '/\|(.*)(?<!\|)/', |
134 | '/\|(.*)(?<!\|)/', |
| - | 135 | '/\*(.+?)\*/', |
|
| 116 | '/\\s+~/', |
136 | '/\\s+~/', |
| 117 | ), |
137 | ), |
| 118 | array( |
138 | array( |
| 119 | '“\\1”', |
139 | '“\\1”', |
| - | 140 | '<abbr class="type-or-context" lang="' . $target_lang . '">\\1</abbr>', |
|
| 120 | '<i lang="' . $source_lang . '">\\1</i>', |
141 | '\\1<i lang="' . $source_lang . '">\\2</i>', |
| 121 | '/\\1', |
142 | '/\\1', |
| - | 143 | '<em>\\1</em>', |
|
| 122 | ' ~', |
144 | ' ~', |
| 123 | ), |
145 | ), |
| 124 | $matches['transl']); |
146 | $matches['transl']); |
| 125 | 147 | ||
| 126 | echo ($is_example ? "<i lang='$source_lang'>" : "<b lang='$source_lang'>") |
148 | echo ($is_example ? "<i lang='$source_lang'>" : "<b lang='$source_lang'>") |
| Line 130... | Line 152... | ||
| 130 | 152 | ||
| 131 | $last_indent = $indent; |
153 | $last_indent = $indent; |
| 132 | }
|
154 | }
|
| 133 | }
|
155 | }
|
| 134 | }
|
156 | }
|
| - | 157 | echo '</ol>'; |
|
| - | 158 | ||
| - | 159 | // $phrases = array();
|
|
| - | 160 | ||
| - | 161 | // foreach ($lines as $line)
|
|
| - | 162 | // {
|
|
| - | 163 | // preg_match('/^(?<lws>\s*)(?<phrase>[^:]+)\s*:\s*(?<transl>.+)/u', $line, $matches);
|
|
| - | 164 | // if ($matches)
|
|
| - | 165 | // {
|
|
| - | 166 | // $phrase = $matches['phrase'];
|
|
| - | 167 | ||
| - | 168 | // /* if not a comment */
|
|
| - | 169 | // if (mb_strpos($phrase, '#') === false)
|
|
| - | 170 | // {
|
|
| - | 171 | // $transl = $matches['transl'];
|
|
| - | 172 | ||
| - | 173 | // $is_example = preg_match(REGEXP_PREFIX_EXAMPLE, $phrase);
|
|
| - | 174 | // if ($is_example)
|
|
| - | 175 | // {
|
|
| - | 176 | // /* assign example to previous phrase; indentation irrelevant */
|
|
| - | 177 | // $phrase = preg_replace(REGEXP_PREFIX_EXAMPLE, '', $phrase);
|
|
| - | 178 | ||
| - | 179 | // $prev_phrase['examples'][$phrase] = $transl;
|
|
| - | 180 | // }
|
|
| - | 181 | // else
|
|
| - | 182 | // {
|
|
| - | 183 | // /* create new phrase */
|
|
| - | 184 | // $level = mb_strlen($matches['lws']) / 2;
|
|
| - | 185 | ||
| - | 186 | // $phrases[$phrase] = array(
|
|
| - | 187 | // 'translation' => $transl,
|
|
| - | 188 | // 'level' => $level
|
|
| - | 189 | // );
|
|
| - | 190 | // $prev_phrase =& $phrases[$phrase];
|
|
| - | 191 | // }
|
|
| - | 192 | // }
|
|
| - | 193 | // }
|
|
| - | 194 | // }
|
|
| - | 195 | ||
| - | 196 | // // var_dump($phrases);
|
|
| - | 197 | ||
| - | 198 | // if ($phrases)
|
|
| - | 199 | // {
|
|
| - | 200 | // $prev_level = -1;
|
|
| - | 201 | ||
| - | 202 | // foreach ($phrases as $phrase => $data)
|
|
| - | 203 | // {
|
|
| - | 204 | // $level = $data['level'];
|
|
| - | 205 | ||
| - | 206 | // if ($level > $prev_level)
|
|
| - | 207 | // {
|
|
| - | 208 | // echo "\n<ol>\n";
|
|
| - | 209 | // }
|
|
| - | 210 | // else if ($level < $prev_level)
|
|
| - | 211 | // {
|
|
| - | 212 | // echo str_repeat("</ol>\n", $prev_level - $level);
|
|
| - | 213 | // }
|
|
| - | 214 | ||
| - | 215 | // $translation = $data['translation'];
|
|
| - | 216 | ||
| - | 217 | // echo "\n<li>$prev_level => $level <b lang='$source_lang'>" . htmlspecialchars($phrase) . '</b>'
|
|
| - | 218 | // . " <span lang='$target_lang'>" . $translation . '</span>';
|
|
| - | 219 | ||
| - | 220 | // if (isset($data['examples']))
|
|
| - | 221 | // {
|
|
| - | 222 | // echo '<ul>';
|
|
| - | 223 | ||
| - | 224 | // foreach ($data['examples'] as $original => $translation)
|
|
| - | 225 | // {
|
|
| - | 226 | // echo "<li><i lang='$source_lang'>" . htmlspecialchars($original) . '</i>'
|
|
| - | 227 | // . " <span lang='$target_lang'>" . $translation . '</span></li>';
|
|
| - | 228 | // }
|
|
| - | 229 | ||
| - | 230 | // echo '</ul>';
|
|
| - | 231 | // }
|
|
| - | 232 | ||
| - | 233 | // $prev_level = $level;
|
|
| - | 234 | // }
|
|
| - | 235 | ||
| - | 236 | // echo '</ol>';
|
|
| - | 237 | // }
|
|
| 135 | ?>
|
238 | ?>
|
| 136 | </ol> |
- | |
| 137 | <?php } ?> |
239 | <?php } ?> |
| 138 | </body> |
240 | </body> |
| 139 | </html> |
241 | </html> |
| 140 | 242 | ||