|
17 | 17 | <tbody>\n";
|
18 | 18 |
|
19 | 19 | $current_repo = $search->getRepository();
|
| 20 | +$extra_locale = $url['path'] == '3locales'; |
| 21 | + |
20 | 22 | // Display results
|
21 | 23 | foreach ($entities as $entity) {
|
22 | 24 | if (in_array($current_repo, ['firefox_ios', 'mozilla_org'])) {
|
|
31 | 33 | $bz_target_string = $target_string = isset($tmx_target[$entity])
|
32 | 34 | ? Utils::secureText($tmx_target[$entity])
|
33 | 35 | : '@@missing@@';
|
| 36 | + |
34 | 37 | // Highlight special characters only after strings have been escaped
|
35 | 38 | $target_string = Strings::highlightSpecial($target_string);
|
36 | 39 | $source_string = Strings::highlightSpecial(Utils::secureText($tmx_source[$entity]));
|
37 | 40 |
|
38 | 41 | $clipboard_target_string = 'clip_' . md5($target_string);
|
| 42 | + $string_id = md5($entity . mt_rand()); |
| 43 | + $regular_string_id = 'string_' . $string_id; |
| 44 | + |
| 45 | + /* |
| 46 | + Find if we need to transliterate the string. |
| 47 | + The string gets transliterated if the target local is serbian, |
| 48 | + if we aren't in the 3locales view and if we have a $target_string |
| 49 | + */ |
| 50 | + $transliterate = $locale == 'sr' && ! $extra_locale && $target_string && $target_string != '@@missing@@'; |
| 51 | + |
| 52 | + if ($transliterate) { |
| 53 | + $transliterated_string = Utils::secureText($tmx_target[$entity]); |
| 54 | + $transliterated_string = ShowResults::getTransliteratedString(urlencode($transliterated_string), 'sr-Cyrl'); |
| 55 | + $transliterated_string = Strings::highlightSpecial($transliterated_string); |
| 56 | + $transliterate_string_id = 'transliterate_' . $string_id; |
| 57 | + } |
39 | 58 |
|
40 | 59 | // Don't show meta links by default
|
41 | 60 | $meta_source = $meta_target = $meta_target2 = '';
|
42 | 61 |
|
43 | 62 | // 3locales view
|
44 |
| - if ($url['path'] == '3locales') { |
| 63 | + if ($extra_locale) { |
45 | 64 | $bz_target_string2 = $target_string2 = isset($tmx_target2[$entity])
|
46 | 65 | ? Utils::secureText($tmx_target2[$entity])
|
47 | 66 | : '';
|
|
135 | 154 | } elseif (! $target_string) {
|
136 | 155 | $target_string = '<em class="error">Warning: Empty string</em>';
|
137 | 156 | } else {
|
138 |
| - $meta_target = " |
139 |
| - {$error_message} |
140 |
| - <span class='clipboard' data-clipboard-target='#{$clipboard_target_string}' alt='Copy to clipboard'></span>"; |
| 157 | + $meta_target = "<span class='clipboard' data-clipboard-target='#{$regular_string_id}' alt='Copy to clipboard'></span>"; |
| 158 | + if ($transliterate) { |
| 159 | + $meta_target .= "<input type='button' value='To Latin' data-transliterated-id='{$string_id}' class='transliterate_button button action'>"; |
| 160 | + } |
| 161 | + $meta_target .= $error_message; |
141 | 162 | }
|
142 | 163 |
|
143 | 164 | $table .= "
|
|
158 | 179 | </td>
|
159 | 180 | <td dir='{$direction2}'>
|
160 | 181 | <span class='celltitle'>{$locale}</span>
|
161 |
| - <div class='string' id='{$clipboard_target_string}'>{$target_string}</div> |
| 182 | + <div class='string' id='{$regular_string_id}'>{$target_string}</div>"; |
| 183 | + if ($transliterate) { |
| 184 | + $table .= "<div class='string toggle' id='{$transliterate_string_id}' style='display: none;'>{$transliterated_string}</div>"; |
| 185 | + } |
| 186 | + $table .= " |
162 | 187 | <div dir='ltr' class='result_meta_link'>
|
163 | 188 | <a class='source_link' href='{$path_locale2}'><source></a>
|
164 | 189 | {$file_bug}
|
|
0 commit comments