first commit
This commit is contained in:
127
wp-content/plugins/loco-translate/tpl/admin/debug/debug-form.php
Normal file
127
wp-content/plugins/loco-translate/tpl/admin/debug/debug-form.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/* @var Loco_mvc_View $this */
|
||||
$this->extend('debug-layout');
|
||||
$this->start('form');
|
||||
|
||||
// Translators: This file is intentionally in English only.
|
||||
|
||||
/* @var Loco_mvc_ViewParams $form */
|
||||
/* @var Loco_mvc_ViewParams $default */
|
||||
?>
|
||||
<form action="" method="get" enctype="application/x-www-form-urlencoded">
|
||||
<input type="hidden" name="page" value="loco-debug" />
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="debug-msgid">Source string</label><br />
|
||||
</th>
|
||||
<td>
|
||||
<textarea required class="regular-text" name="msgid" rows="4" id="debug-msgid" placeholder="e.g. %s comment"><?php $form->e('msgid')?></textarea>
|
||||
<p class="description">
|
||||
Enter the original string <strong>exactly</strong>. This field is mandatory.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="debug-msgctxt">Context</label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" class="regular-text" name="msgctxt" id="debug-msgctxt" value="<?php $form->e('msgctxt')?>" placeholder="e.g. Comments title" />
|
||||
<p class="description">
|
||||
Context is optional. It's used to disambiguate duplicate strings. If in doubt, leave blank.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="debug-plural">Plural form</label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" class="regular-text" name="msgid_plural" id="debug-plural" value="<?php $form->e('msgid_plural')?>" placeholder="e.g. %s comments" />
|
||||
<label for="debug-n">n=</label>
|
||||
<input type="number" min="0" name="n" id="debug-n" value="<?php $form->e('n')?>" placeholder="<?php $default->e('n')?>" />
|
||||
<p class="description">
|
||||
Plural form is optional, and will only work if the string has been pluralized.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="debug-domain">Text domain</label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" class="regular-text" name="domain" id="debug-domain" value="<?php $form->e('domain')?>" placeholder="<?php $default->e('domain')?>"/>
|
||||
<p class="description">Leaving empty will use the WordPress core (default) text domain.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="debug-locale">Language</label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" class="regular-text" name="locale" id="debug-locale" value="<?php $form->e('locale')?>" placeholder="<?php $default->e('locale')?>" />
|
||||
<p class="description">Enter a valid locale code. Your translation files must be suffixed exactly with this value.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="debug-loader">Loader</label>
|
||||
</th>
|
||||
<td>
|
||||
<select name="loader" id="debug-loader"><?php $value = $form['loader'];?>
|
||||
<option value="">
|
||||
Auto (recommended)
|
||||
</option>
|
||||
<option value="plugin"<?php $value==='plugin' and print(' selected')?>>
|
||||
load_plugin_textdomain
|
||||
</option>
|
||||
<option value="theme"<?php $value==='theme' and print(' selected')?>>
|
||||
load_theme_textdomain
|
||||
</option>
|
||||
<option value="custom"<?php $value==='custom' and print(' selected')?>>
|
||||
load_textdomain
|
||||
</option>
|
||||
<option value="none"<?php $value==='none' and print(' selected')?>>
|
||||
None
|
||||
</option>
|
||||
</select>
|
||||
<label for="debug-loadpath">path: </label>
|
||||
<input type="text" class="regular-text code" name="loadpath" id="debug-loadpath" value="<?php $form->e('loadpath')?>" placeholder="" />
|
||||
<p class="description">
|
||||
See the WordPress documentation for correct usage of the path argument.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="debug-jspath">Script path</label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" class="regular-text code" name="jspath" id="debug-jspath" value="<?php $form->e('jspath')?>" placeholder="" />
|
||||
<p class="description">
|
||||
Simulate <a href="https://developer.wordpress.org/reference/functions/wp_set_script_translations/" tabindex="-1">wp_set_script_translations</a>
|
||||
with a relative script path, e.g. <code>blocks/example.js</code>.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
Options
|
||||
</th>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" name="unhook" value="1"<?php $form->unhook and print(' checked')?> />
|
||||
Unhook filters before test. This may help isolate translation from other plugins.
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="submit">
|
||||
<input type="submit" class="button-primary" value="Translate" />
|
||||
<a class="button button-link" href="?page=loco-debug&randomize">Lucky dip</a>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/* @var Loco_mvc_View $this */
|
||||
$this->extend('../layout');
|
||||
?>
|
||||
<style>
|
||||
code.po {
|
||||
font-weight: bold;
|
||||
}
|
||||
#loco-log textarea {
|
||||
width: 100%;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
|
||||
/* @var Loco_mvc_View $params */
|
||||
/* @var string $header */
|
||||
$params->has('header') and print $header;
|
||||
|
||||
|
||||
/* @var ArrayIterator|null $log */
|
||||
if( $params->has('log') ):?>
|
||||
<div class="panel" id="loco-log">
|
||||
<h3>
|
||||
Trace log:
|
||||
</h3>
|
||||
<p>
|
||||
If you're asking for help on the WordPress forum, please post the full text below.
|
||||
</p>
|
||||
<form action="#">
|
||||
<textarea spellcheck="false" class="code" name="l" rows="<?=$log->count()?>"><?php echo $params->escape( implode("\n",iterator_to_array($log) ) );?></textarea>
|
||||
</form>
|
||||
</div><?php
|
||||
endif;
|
||||
|
||||
|
||||
/* @var string $form */
|
||||
echo $form;
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/* @var Loco_mvc_View $this */
|
||||
|
||||
$this->extend('debug-form');
|
||||
$this->start('header');
|
||||
|
||||
/* @var Loco_mvc_ViewParams $result */
|
||||
if( $result->translated ):?>
|
||||
<div class="panel panel-success">
|
||||
<h3 class="has-icon">Translation result:</h3>
|
||||
<p><code class="po"><?php $result->e('msgstr')?></code></p>
|
||||
<p>
|
||||
This is the translation value returned from the
|
||||
<a href="<?php $result->e('calleeDoc')?>" target="_blank"><code><?php $result->e('callee')?></code></a> function.
|
||||
</p>
|
||||
</div><?php
|
||||
|
||||
else:?>
|
||||
<div class="panel panel-warning">
|
||||
<h3 class="has-icon">String found, but no translation returned</h3>
|
||||
<p>
|
||||
The <a href="<?php $result->e('calleeDoc')?>" target="_blank"><code><?php $result->e('callee')?></code></a> function
|
||||
returned the same value as the source string. Either the string isn't translated, or the required translation file wasn't loaded.
|
||||
</p>
|
||||
<p>
|
||||
See below for the exact string matches we found in your translation files.
|
||||
</p>
|
||||
</div><?php
|
||||
endif;
|
||||
|
||||
|
||||
/* @var Loco_mvc_ViewParams[] $matched */
|
||||
foreach( $result->matches as $g => $matched ):
|
||||
/* @var Loco_mvc_FileParams $group */
|
||||
$group = $result->grouped[$g];?>
|
||||
<div class="panel panel-info">
|
||||
<h3>
|
||||
<?php $group->e('type');?> translations:
|
||||
</h3><?php
|
||||
foreach( $matched as $file ):?>
|
||||
<p>
|
||||
<span class="icon icon-file"> </span>
|
||||
<code class="path"><?php $file->e('relpath') ?></code> → <code class="po"><?php $file->e('msgstr');?></code>
|
||||
</p><?php
|
||||
endforeach;
|
||||
if( $group->has('href') ):?>
|
||||
<p>
|
||||
<span class="icon icon-pencil"> </span>
|
||||
<a href="<?php $group->e('href')?>">Edit PO</a>
|
||||
</p><?php
|
||||
endif;?>
|
||||
</div><?php
|
||||
endforeach;
|
||||
Reference in New Issue
Block a user