Skip to content
Snippets Groups Projects
Commit abfc5dac authored by Demian Katz's avatar Demian Katz Committed by GitHub
Browse files

Improve language tool interface. (#906)

parent 25abc8d5
No related merge requests found
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -65,7 +65,7 @@ VuFind.register('lightbox', function Lightbox() { ...@@ -65,7 +65,7 @@ VuFind.register('lightbox', function Lightbox() {
*/ */
var _constrainLink; // function declarations to avoid style warnings var _constrainLink; // function declarations to avoid style warnings
var _formSubmit; // about circular references var _formSubmit; // about circular references
function _update(content) { function render(content) {
if (!content.match) { if (!content.match) {
return; return;
} }
...@@ -173,7 +173,7 @@ VuFind.register('lightbox', function Lightbox() { ...@@ -173,7 +173,7 @@ VuFind.register('lightbox', function Lightbox() {
} }
_currentUrl = _originalUrl; // Now that we're logged in, where were we? _currentUrl = _originalUrl; // Now that we're logged in, where were we?
} }
_update(content); render(content);
}) })
.fail(function lbAjaxFail(deferred, errorType, msg) { .fail(function lbAjaxFail(deferred, errorType, msg) {
showAlert(VuFind.translate('error_occurred') + '<br/>' + msg, 'danger'); showAlert(VuFind.translate('error_occurred') + '<br/>' + msg, 'danger');
...@@ -376,6 +376,7 @@ VuFind.register('lightbox', function Lightbox() { ...@@ -376,6 +376,7 @@ VuFind.register('lightbox', function Lightbox() {
bind: bind, bind: bind,
flashMessage: flashMessage, flashMessage: flashMessage,
reload: reload, reload: reload,
render: render,
// Reset // Reset
reset: reset, reset: reset,
// Init // Init
......
...@@ -92,6 +92,15 @@ img {max-width: 100%;} ...@@ -92,6 +92,15 @@ img {max-width: 100%;}
padding-right: 1em; padding-right: 1em;
} }
/* --- Devtools --- */
.translation-output {
width: 100%;
max-width: none;
font-family: @font-family-monospace;
font-size: 12px;
white-space: pre;
}
/* --- PubDateVis --- */ /* --- PubDateVis --- */
#dateVisColorSettings { #dateVisColorSettings {
background-color: #fff; // background of box background-color: #fff; // background of box
......
...@@ -93,6 +93,15 @@ img {max-width: 100%;} ...@@ -93,6 +93,15 @@ img {max-width: 100%;}
padding-right: 1em; padding-right: 1em;
} }
/* --- Devtools --- */
.translation-output {
width: 100%;
max-width: none;
font-family: $font-family-monospace;
font-size: 12px;
white-space: nowrap;
}
/* --- PubDateVis --- */ /* --- PubDateVis --- */
#dateVisColorSettings { #dateVisColorSettings {
background-color: #fff; // background of box background-color: #fff; // background of box
......
...@@ -9,48 +9,46 @@ ...@@ -9,48 +9,46 @@
<table class="table table-striped"> <table class="table table-striped">
<tr><th>Language</th><th>Missing Lines</th><th>Extra Lines</th><th>Percent Translated</th><th>Extra Help Files</th></tr> <tr><th>Language</th><th>Missing Lines</th><th>Extra Lines</th><th>Percent Translated</th><th>Extra Help Files</th></tr>
<? foreach ($details as $langCode => $diffs): ?> <? foreach ($details as $langCode => $diffs): ?>
<?
$extraCount = count($diffs['notInL1']);
$missingCount = count($diffs['notInL2']);
?>
<tr> <tr>
<td><?=$this->escapeHtml($langCode . ' (' . $diffs['name'] . ')')?></td> <td><?=$this->escapeHtml($langCode . ' (' . $diffs['name'] . ')')?></td>
<td><?=count($diffs['notInL2'])?></td> <td><?=$missingCount ?><? if($missingCount > 0): ?> (<a href="#" onclick="diffManager.showMissing('<?=$langCode ?>')"><?=$this->transEsc('show') ?></a>)<? endif; ?></td>
<td><?=count($diffs['notInL1'])?></td> <td><?=$extraCount ?><? if($extraCount > 0): ?> (<a href="#" onclick="diffManager.showExtra('<?=$langCode ?>')"><?=$this->transEsc('show') ?></a>)<? endif; ?></td>
<td><?=$this->escapeHtml($diffs['l2Percent'])?></td> <td><?=$this->escapeHtml($diffs['l2Percent'])?></td>
<td><?=count($diffs['helpFiles'])?></td> <td><?=count($diffs['helpFiles'])?></td>
</tr> </tr>
<? endforeach; ?> <? endforeach; ?>
</table> </table>
<div class="accordion" id="accordion"> <?
<? foreach ($details as $langCode => $diffs): ?> $json = json_encode($details);
<? if (count($diffs['notInL1']) > 0): ?> $script = <<<JS
<div class="accordion-group"> function createDiffManager() {
<div class="accordion-heading"> var details = {$json};
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#extra_<?=$langCode ?>"> function makeRow(opArray, lang) {
Extra Lines In <?=$this->escapeHtml($diffs['name'])?> (<?=$this->escapeHtml($langCode)?>.ini) var arr = [];
</a> for (var i = 0; i < opArray.length; i++) {
</div> console.log(details[lang].object[opArray[i]] || details.en.object[opArray[i]]);
<div id="extra_<?=$langCode ?>" class="accordion-body collapse"> arr.push(opArray[i] + ' = "' + (details[lang].object[opArray[i]] || details.en.object[opArray[i]]) + '"');
<div class="accordion-inner"> }
<? foreach ($diffs['notInL1'] as $key): ?> return '<textarea class="translation-output form-control" rows="' + Math.min(arr.length + 1, 25)+ '" onClick="this.select()">' + arr.join('\\n') + '</textarea>';
<?=$this->escapeHtml($key)?> = "<?=$this->escapeHtml($diffs['object'][$key])?>"<br /> }
<? endforeach; ?> function showExtra(lang) {
</div> VuFind.lightbox.render('<h2>Extra Lines</h2>'+makeRow(details[lang].notInL1, lang));
</div> return false;
</div> }
<? endif; ?> function showMissing(lang) {
<? if (count($diffs['notInL2']) > 0): ?> VuFind.lightbox.render('<h2>Missing Lines</h2>'+makeRow(details[lang].notInL2, lang));
<div class="accordion-group"> return false;
<div class="accordion-heading"> }
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#missing_<?=$langCode ?>"> return {
Missing From <?=$this->escapeHtml($diffs['name'])?> (<?=$this->escapeHtml($langCode)?>.ini) showExtra: showExtra,
<span class="pull-right flip"></span> showMissing: showMissing
</a> }
</div> }
<div id="missing_<?=$langCode ?>" class="accordion-body collapse"> var diffManager = createDiffManager();
<div class="accordion-inner"> JS;
<textarea class="form-control" rows="15"><? foreach ($diffs['notInL2'] as $key): ?><?=$this->escapeHtml($key)?> = "<?=$this->escapeHtml($main[$key])?>" ?>
<? endforeach; ?></textarea> <?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET') ?>
</div> \ No newline at end of file
</div>
</div>
<? endif; ?>
<? endforeach; ?>
</div>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment