# ai-builder/2.7.10/admin/pages/translation-settings.php

AI Builder – Generate pages, blocks, images &amp; translate with AI, version 2.7.10. 135 lines.

- Page: https://pluginprobe.com/plugins/ai-builder/2.7.10/code/admin/pages/translation-settings.php
- Raw: https://pluginprobe.com/plugins/ai-builder/2.7.10/raw/admin/pages/translation-settings.php
- Modified: 2025-11-30T10:52:12+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/ai-builder/2.7.10/code/admin/pages/translation-settings.php#L10-L20`.

```php
<?php
if (!defined('ABSPATH'))
    exit;

$translation_settings = AIBUI_Translation_Settings::get_settings();
$supported_languages = AIBUI_Translation_Handler::get_supported_languages();

$header_link = admin_url('site-editor.php?p=%2Fpattern&postType=wp_template_part&categoryId=header');
$footer_link = admin_url('site-editor.php?p=%2Fpattern&postType=wp_template_part&categoryId=footer');
?>
<div class="wrap ai-builder-settings">
    <h1><?php esc_html_e('AI Builder – Translation Settings', 'ai-builder'); ?></h1>

    <?php if (isset($_GET['translation_saved'])) : ?>
        <div class="notice notice-success is-dismissible">
            <p><?php esc_html_e('Translation settings saved.', 'ai-builder'); ?></p>
        </div>
    <?php endif; ?>

    <p><?php esc_html_e('Configure the global behavior of language switching and learn how to translate your headers and footers.', 'ai-builder'); ?></p>

    <div class="aibui-settings-grid">
        <div class="aibui-card aibui-card--highlight">
            <h2><?php esc_html_e('Translate your headers & footers', 'ai-builder'); ?></h2>
            <p><?php esc_html_e('Template parts follow the same language as your pages. Follow these steps to translate them:', 'ai-builder'); ?></p>
            <ol>
                <li><?php esc_html_e('Open the Site Editor and select the template part (header or footer).', 'ai-builder'); ?></li>
                <li><?php esc_html_e('In the editing canvas, click the floating “Translate with AI” button located in the bottom-right corner.', 'ai-builder'); ?></li>
                <li><?php esc_html_e('Publish the translated template part. AI Builder will automatically serve it when visitors switch languages.', 'ai-builder'); ?></li>
            </ol>
            <p>
                <a href="<?php echo esc_url($header_link); ?>" class="button button-primary"><?php esc_html_e('Open header in Site Editor', 'ai-builder'); ?></a>
                <a href="<?php echo esc_url($footer_link); ?>" class="button"><?php esc_html_e('Open footer in Site Editor', 'ai-builder'); ?></a>
            </p>
            <p><?php esc_html_e('Once translations exist, insert the “Language Switcher” block in your templates to let visitors change the language.', 'ai-builder'); ?></p>
        </div>

        <form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" class="aibui-card aibui-translation-settings-form">
        <input type="hidden" name="action" value="aibui_save_translation_settings">
        <?php wp_nonce_field('aibui_save_translation_settings'); ?>

        <table class="form-table" role="presentation">
            <tbody>
                <tr>
                    <th scope="row"><?php esc_html_e('Language switcher', 'ai-builder'); ?></th>
                    <td>
                        <label>
                            <input type="checkbox" name="enable_switcher" <?php checked($translation_settings['enable_switcher']); ?> />
                            <?php esc_html_e('Enable the Language Switcher block for visitors', 'ai-builder'); ?>
                        </label>
                        <p class="description">
                            <?php esc_html_e('When enabled, you can insert the “Language Switcher” block into your site header or anywhere else on your pages and patterns. Visitors can then pick a language and only translated content will be shown.', 'ai-builder'); ?>
                        </p>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><label for="aibui-default-lang"><?php esc_html_e('Default site language', 'ai-builder'); ?></label></th>
                    <td>
                        <select name="default_lang" id="aibui-default-lang">
                            <?php foreach ($supported_languages as $code => $label) : ?>
                                <option value="<?php echo esc_attr($code); ?>" <?php selected($translation_settings['default_lang'], $code); ?>>
                                    <?php echo esc_html($label); ?>
                                </option>
                            <?php endforeach; ?>
                        </select>
                        <p class="description">
                            <?php esc_html_e('Pages and template parts created without translation will belong to this language.', 'ai-builder'); ?>
                        </p>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><?php esc_html_e('Available languages', 'ai-builder'); ?></th>
                    <td>
                        <fieldset class="aibui-available-langs-grid">
                            <?php foreach ($supported_languages as $code => $label) : ?>
                                <label>
                                    <input type="checkbox" name="available_langs[]" value="<?php echo esc_attr($code); ?>" <?php checked(in_array($code, $translation_settings['available_langs'], true)); ?> />
                                    <?php echo esc_html($label); ?>
                                </label>
                            <?php endforeach; ?>
                        </fieldset>
                        <p class="description">
                            <?php esc_html_e('Choose the languages exposed to visitors via the selector. The default language is always enforced.', 'ai-builder'); ?>
                        </p>
                    </td>
                </tr>
            </tbody>
            </table>

            <p class="submit">
                <button type="submit" class="button button-primary"><?php esc_html_e('Save Translation Settings', 'ai-builder'); ?></button>
            </p>
        </form>
    </div>
</div>

<style>
    .aibui-settings-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: 24px;
        margin-top: 24px;
    }
    .aibui-card {
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 14px;
        padding: 24px;
        box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
    }
    .aibui-card--highlight {
        background: linear-gradient(135deg, #f6f8ff, #eef2ff);
    }
    .aibui-card ol {
        margin-left: 20px;
    }
    .aibui-card .button {
        margin-right: 8px;
        margin-top: 8px;
    }
    .aibui-available-langs-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px 16px;
        max-width: 480px;
    }
    .aibui-available-langs-grid label {
        display: flex;
        align-items: center;
        gap: 6px;
        margin: 0;
    }
</style>


```
