Support Log in

18. Translation Status API

Developer Guide
Prefer video? Watch the Lang Forge tutorials 9 short guides covering every feature Watch

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"
Parameters:
ParameterTypeDefaultDescription
post_typestringpostWordPress post type slug
Response (200):
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
    }
}
Example: Build a translation dashboard widget
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>';
    });
});

Forge AI Assistant Online

Hi! I'm the Lang Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs