Rev 223 | Rev 230 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 223 | Rev 224 | ||
---|---|---|---|
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>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 | ol { |
7 | ol { |
8 | padding-left: 0; |
8 | padding-left: 0; |
9 | list-style-type: none; |
9 | list-style-type: none; |
10 | } |
10 | } |
11 | 11 | ||
12 | ol li { |
12 | ol li { |
13 | margin-left: 0; |
13 | margin-left: 0; |
14 | } |
14 | } |
15 | 15 | ||
16 | ol ol { |
16 | ol ol { |
17 | padding-left: 1em; |
17 | padding-left: 1em; |
18 | } |
18 | } |
19 | </style> |
19 | </style> |
20 | </head> |
20 | </head> |
21 | 21 | ||
22 | <body> |
22 | <body> |
23 | <h1>Modern Golic Vulcan – Federation Standard English Dictionary</h1> |
23 | <h1>Modern Golic Vulcan – Federation Standard English Dictionary</h1> |
24 | <?php
|
24 | <?php
|
25 | define('REGEXP_PREFIX_EXAMPLE', '/^ex\s*=\s*/'); |
25 | define('REGEXP_PREFIX_EXAMPLE', '/^ex\s*=\s*/'); |
26 | 26 | ||
27 | $source_lang = 'vuh-Latn-Gol-modern'; |
27 | $source_lang = 'vuh-Latn-Gol-modern'; |
28 | $target_lang = 'en-Latn-Federation'; |
28 | $target_lang = 'en-Latn-Federation'; |
29 | $lines = file('vul-gol-en.dict'); |
29 | $lines = file('vul-gol-en.dict'); |
30 | 30 | ||
31 | if ($lines) |
31 | if ($lines) |
32 | {
|
32 | {
|
33 | $last_indent = -1; |
33 | $last_indent = -1; |
34 | $last_phrases = array(); |
34 | $last_phrases = array(); |
35 | 35 | ||
36 | foreach ($lines as $line) |
36 | foreach ($lines as $line) |
37 | {
|
37 | {
|
38 | preg_match('/^(?<lws>\s*)(?<phrase>[^:]+)\s*:\s*(?<transl>.+)/u', $line, $matches); |
38 | preg_match('/^(?<lws>\s*)(?<phrase>[^:]+)\s*:\s*(?<transl>.+)/u', $line, $matches); |
39 | // var_dump($matches);
|
39 | // var_dump($matches);
|
40 | if ($matches) |
40 | if ($matches) |
41 | {
|
41 | {
|
42 | $phrase = $matches['phrase']; |
42 | $phrase = $matches['phrase']; |
43 | 43 | ||
44 | if (mb_strpos($phrase, '#') === false) |
44 | if (mb_strpos($phrase, '#') === false) |
45 | {
|
45 | {
|
46 | $indent = mb_strlen($matches['lws']) / 2; |
46 | $indent = mb_strlen($matches['lws']) / 2; |
47 | 47 | ||
48 | if ($indent > $last_indent) |
48 | if ($indent > $last_indent) |
49 | {
|
49 | {
|
50 | echo '<ol>'; |
50 | echo '<ol>'; |
51 | }
|
51 | }
|
52 | else
|
52 | else
|
53 | {
|
53 | {
|
54 | echo str_repeat('</ol>', $last_indent - $indent); |
54 | echo str_repeat('</ol>', $last_indent - $indent); |
55 | }
|
55 | }
|
56 | 56 | ||
57 | echo '<li>'; |
57 | echo '<li>'; |
58 | 58 | ||
59 | $is_example = preg_match(REGEXP_PREFIX_EXAMPLE, $phrase); |
59 | $is_example = preg_match(REGEXP_PREFIX_EXAMPLE, $phrase); |
60 | if ($is_example) |
60 | if ($is_example) |
61 | {
|
61 | {
|
62 | $phrase = preg_replace(REGEXP_PREFIX_EXAMPLE, '', $phrase); |
62 | $phrase = preg_replace(REGEXP_PREFIX_EXAMPLE, '', $phrase); |
63 | }
|
63 | }
|
64 | 64 | ||
65 | if ($indent > $last_indent) |
65 | if ($indent > $last_indent) |
66 | {
|
66 | {
|
67 | $last_phrases[] = $phrase; |
67 | $last_phrases[] = $phrase; |
68 | }
|
68 | }
|
69 | else if ($indent < $last_indent) |
69 | else if ($indent < $last_indent) |
70 | {
|
70 | {
|
71 | $last_phrases = array_slice($last_phrases, 0, $indent + 1); |
71 | $last_phrases = array_slice($last_phrases, 0, $indent + 1); |
72 | }
|
72 | }
|
73 | 73 | ||
74 | if ($indent <= $last_indent) |
74 | if ($indent <= $last_indent) |
75 | {
|
75 | {
|
76 | $last_phrases[count($last_phrases) - 1] = $phrase; |
76 | $last_phrases[count($last_phrases) - 1] = $phrase; |
77 | }
|
77 | }
|
78 | 78 | ||
79 | $phrase = preg_replace( |
79 | $phrase = preg_replace( |
80 | array( |
80 | array( |
81 | '/~/', |
81 | '/~/', |
82 | '/[()]/', |
82 | '/[()]/', |
83 | ), |
83 | ), |
84 | array( |
84 | array( |
85 | '=', |
85 | '=', |
86 | '|', |
86 | '|', |
87 | ), |
87 | ), |
88 | $phrase); |
88 | $phrase); |
89 | 89 | ||
90 | if ($last_phrases) |
90 | if ($last_phrases) |
91 | {
|
91 | {
|
92 | end($last_phrases); |
92 | end($last_phrases); |
93 | 93 | ||
94 | while (($last_phrase = prev($last_phrases)) !== false) |
94 | while (($last_phrase = prev($last_phrases)) !== false) |
95 | {
|
95 | {
|
96 | while (mb_strlen($last_phrase) > 1) |
96 | while (mb_strlen($last_phrase) > 1) |
97 | {
|
97 | {
|
98 | if (preg_match('/' . preg_quote($last_phrase) . '/i', |
98 | if (preg_match('/' . preg_quote($last_phrase) . '/i', |
99 | $phrase, $last_sub_matches)) |
99 | $phrase, $last_sub_matches)) |
100 | {
|
100 | {
|
101 | $phrase = preg_replace('/' . $last_sub_matches[0] . '/i', |
101 | $phrase = preg_replace('/' . $last_sub_matches[0] . '/i', |
102 | '<u>\\0</u>', $phrase); |
102 | '<u>\\0</u>', $phrase); |
103 | break 2; |
103 | break 2; |
104 | }
|
104 | }
|
105 | 105 | ||
106 | $last_phrase = mb_strcut($last_phrase, 0, mb_strlen($last_phrase) - 1); |
106 | $last_phrase = mb_strcut($last_phrase, 0, mb_strlen($last_phrase) - 1); |
107 | }
|
107 | }
|
108 | }
|
108 | }
|
109 | }
|
109 | }
|
110 | 110 | ||
111 | $transl = preg_replace( |
111 | $transl = preg_replace( |
112 | array( |
112 | array( |
113 | '/"([^"]+)"/', |
113 | '/"([^"]+)"/', |
114 | '/\\/([\\s\\w\'()-]+)\\//u', |
114 | '/\\/([\\s\\w\'()-]+)\\//u', |
115 | '/\|(.*)(?<!\|)/', |
115 | '/\|(.*)(?<!\|)/', |
116 | '/\\s+~/', |
116 | '/\\s+~/', |
117 | ), |
117 | ), |
118 | array( |
118 | array( |
119 | '“\\1”', |
119 | '“\\1”', |
120 | '<i lang="' . $source_lang . '">\\1</i>', |
120 | '<i lang="' . $source_lang . '">\\1</i>', |
121 | '/\\1', |
121 | '/\\1', |
122 | ' ~', |
122 | ' ~', |
123 | ), |
123 | ), |
124 | strip_tags($matches['transl'])); |
124 | $matches['transl']); |
125 | 125 | ||
126 | echo ($is_example ? "<i lang='$source_lang'>" : "<b lang='$source_lang'>") |
126 | echo ($is_example ? "<i lang='$source_lang'>" : "<b lang='$source_lang'>") |
127 | . $phrase |
127 | . $phrase |
128 | . ($is_example ? '</i>' : '</b>') |
128 | . ($is_example ? '</i>' : '</b>') |
129 | . " <span lang='$target_lang'>" . $transl . '</span>'; |
129 | . " <span lang='$target_lang'>" . $transl . '</span>'; |
130 | 130 | ||
131 | $last_indent = $indent; |
131 | $last_indent = $indent; |
132 | }
|
132 | }
|
133 | }
|
133 | }
|
134 | }
|
134 | }
|
135 | ?>
|
135 | ?>
|
136 | </ol> |
136 | </ol> |
137 | <?php } ?> |
137 | <?php } ?> |
138 | </body> |
138 | </body> |
139 | </html> |
139 | </html> |