Endpoints for monitoring translation completeness across your site.
GET /langforge/v1/translation-status
Overview of translation completeness per language for a given post type. Useful for building translation dashboards.
Permission:edit_posts
Request:
bash
curl -s "https://example.com/wp-json/langforge/v1/translation-status?post_type=page"
-u "admin:XXXX XXXX XXXX XXXX XXXX XXXX"| Parameter | Type | Default | Description |
|---|---|---|---|
post_type | string | post | WordPress post type slug |
json
{
"ru": {
"name": "Русский",
"total": 25,
"translated": 25,
"percentage": 100
},
"en": {
"name": "English",
"total": 25,
"translated": 18,
"percentage": 72
},
"de": {
"name": "Deutsch",
"total": 25,
"translated": 5,
"percentage": 20
}
}php
// In a custom admin dashboard widget
add_action('wp_dashboard_setup', function () {
wp_add_dashboard_widget('lf_translation_status', 'Translation Status', function () {
$response = wp_remote_get(
rest_url('langforge/v1/translation-status?post_type=post'),
['headers' => ['X-WP-Nonce' => wp_create_nonce('wp_rest')]]
);
if (is_wp_error($response)) return;
$data = json_decode(wp_remote_retrieve_body($response), true);
echo '<table class="widefat">';
echo '<thead><tr><th>Language</th><th>Translated</th><th>%</th></tr></thead>';
echo '<tbody>';
foreach ($data as $code => $info) {
$color = $info['percentage'] === 100 ? 'green' : ($info['percentage'] > 50 ? 'orange' : 'red');
echo '<tr>';
echo '<td>' . esc_html($info['name']) . '</td>';
echo '<td>' . $info['translated'] . '/' . $info['total'] . '</td>';
echo '<td style="color:' . $color . '">' . $info['percentage'] . '%</td>';
echo '</tr>';
}
echo '</tbody></table>';
});
});—