| 4,47 → 4,29 |
| <meta charset="UTF-8"> |
| <title>Modern Golic Vulcan – Federation Standard English Dictionary</title> |
| <style type="text/css"> |
| body { |
| font-family: serif; |
| } |
| |
| ol |
| { |
| ol { |
| padding-left: 0; |
| list-style-type: none; |
| } |
| |
| ol li |
| { |
| ol li { |
| margin-left: 0; |
| } |
| |
| ol ol |
| { |
| ol ol { |
| padding-left: 1em; |
| } |
| |
| .type-or-context { |
| font-family: sans-serif; |
| font-size: small; |
| font-weight: bold; |
| } |
| |
| i em { |
| font-weight: bold; |
| } |
| </style> |
| </head> |
| |
| <body> |
| <h1>Modern Golic Vulcan – Federation Standard English Dictionary</h1> |
| <?php |
| define('REGEXP_PREFIX_EXAMPLE', '/^ex\s*=\s*/'); |
| |
| $source_lang = 'vuh-Latn-Gol-modern'; |
| $target_lang = 'en-Latn-Federation'; |
| $lines = file('vul-gol-en.dict'); |
| ?> |
| <h1>Modern Golic Vulcan – Federation Standard English Dictionary</h1> |
| <?php |
| define('REGEXP_PREFIX_EXAMPLE', '/^ex\s*=\s*/'); |
| |
| if ($lines) |
| { |
| 129,18 → 111,14 |
| $transl = preg_replace( |
| array( |
| '/"([^"]+)"/', |
| '/\{([^\}]+)\}/', |
| '/(^|[\\s+\\[])\\/([\\s\\w\'()-]+)\\/(?=[,.;:\\s+\\]]|$)/u', |
| '/\\/([\\s\\w\'()-]+)\\//u', |
| '/\|(.*)(?<!\|)/', |
| '/\*(.+?)\*/', |
| '/\\s+~/', |
| ), |
| array( |
| '“\\1”', |
| '<abbr class="type-or-context" lang="' . $target_lang . '">\\1</abbr>', |
| '\\1<i lang="' . $source_lang . '">\\2</i>', |
| '<i lang="' . $source_lang . '">\\1</i>', |
| '/\\1', |
| '<em>\\1</em>', |
| ' ~', |
| ), |
| $matches['transl']); |
| 154,88 → 132,8 |
| } |
| } |
| } |
| echo '</ol>'; |
| |
| // $phrases = array(); |
| |
| // foreach ($lines as $line) |
| // { |
| // preg_match('/^(?<lws>\s*)(?<phrase>[^:]+)\s*:\s*(?<transl>.+)/u', $line, $matches); |
| // if ($matches) |
| // { |
| // $phrase = $matches['phrase']; |
| |
| // /* if not a comment */ |
| // if (mb_strpos($phrase, '#') === false) |
| // { |
| // $transl = $matches['transl']; |
| |
| // $is_example = preg_match(REGEXP_PREFIX_EXAMPLE, $phrase); |
| // if ($is_example) |
| // { |
| // /* assign example to previous phrase; indentation irrelevant */ |
| // $phrase = preg_replace(REGEXP_PREFIX_EXAMPLE, '', $phrase); |
| |
| // $prev_phrase['examples'][$phrase] = $transl; |
| // } |
| // else |
| // { |
| // /* create new phrase */ |
| // $level = mb_strlen($matches['lws']) / 2; |
| |
| // $phrases[$phrase] = array( |
| // 'translation' => $transl, |
| // 'level' => $level |
| // ); |
| // $prev_phrase =& $phrases[$phrase]; |
| // } |
| // } |
| // } |
| // } |
| |
| // // var_dump($phrases); |
| |
| // if ($phrases) |
| // { |
| // $prev_level = -1; |
| |
| // foreach ($phrases as $phrase => $data) |
| // { |
| // $level = $data['level']; |
| |
| // if ($level > $prev_level) |
| // { |
| // echo "\n<ol>\n"; |
| // } |
| // else if ($level < $prev_level) |
| // { |
| // echo str_repeat("</ol>\n", $prev_level - $level); |
| // } |
| |
| // $translation = $data['translation']; |
| |
| // echo "\n<li>$prev_level => $level <b lang='$source_lang'>" . htmlspecialchars($phrase) . '</b>' |
| // . " <span lang='$target_lang'>" . $translation . '</span>'; |
| |
| // if (isset($data['examples'])) |
| // { |
| // echo '<ul>'; |
| |
| // foreach ($data['examples'] as $original => $translation) |
| // { |
| // echo "<li><i lang='$source_lang'>" . htmlspecialchars($original) . '</i>' |
| // . " <span lang='$target_lang'>" . $translation . '</span></li>'; |
| // } |
| |
| // echo '</ul>'; |
| // } |
| |
| // $prev_level = $level; |
| // } |
| |
| // echo '</ol>'; |
| // } |
| ?> |
| </ol> |
| <?php } ?> |
| </body> |
| </html> |