{# @var craft \craft\web\twig\variables\CraftVariable #}
{#
/**
 * Translate plugin for Craft CMS 5.x
 *
 * @link      https://enupal.com
 * @copyright Copyright (c) 2018 Enupal
 */
#}
{% extends "enupal-translate/_layouts/settings" %}
{% import "_includes/forms" as forms %}

{% set settings = craft.enupaltranslate.getSettings() %}
{% set fullPageForm = true %}
{% set saveShortcutRedirect = 'enupal-translate/settings/general' %}
{% set twigSearchMethods = craft.enupaltranslate.getTwigSearchMethods() %}

{% set saveButton %}
    <div class="buttons">
        <input class="btn submit" type="submit" value="{{ 'Save'|t('app') }}">
    </div>
{% endset %}

{% set content %}

    <input type="hidden" name="action" value="enupal-translate/settings/save-settings">

    <div id="settings-cp">

        {% namespace 'settings' %}

        {{ forms.textField({
            label: "Plugin Name"|t,
            id: 'pluginNameOverride',
            name: 'pluginNameOverride',
            instructions: "Intuitive, human-readable plugin name for the end user."|t('enupal-translate'),
            value: settings.pluginNameOverride,
            placeholder: "Enupal Translate"|t('enupal-translate'),
            autofocus: true,
            first: true
        }) }}

        {{ forms.selectField({
            label: "Twig search method"|t('enupal-translate'),
            id: 'twigRegexMethod',
            name: 'twigRegexMethod',
            instructions: "Enupal Translate uses regex to search the translatable string in your templates. Choose the method of your preference, you can change it whenever you want."|t('enupal-translate'),
            options: twigSearchMethods,
            value: settings.twigRegexMethod
        }) }}

        <hr>

        {{ forms.textField({
            label: "Queue threshold"|t('enupal-translate'),
            id: 'staticQueueThreshold',
            name: 'staticQueueThreshold',
            type: 'number',
            min: 0,
            instructions: "Bulk static translations larger than this run in the queue instead of the browser request. Set to 0 to always run inline."|t('enupal-translate'),
            value: settings.staticQueueThreshold
        }) }}

        {{ forms.lightswitchField({
            label: "Track usage metrics"|t('enupal-translate'),
            id: 'enableMetrics',
            name: 'enableMetrics',
            instructions: "Record translation counts and token usage so they show up on the dashboard."|t('enupal-translate'),
            on: settings.enableMetrics
        }) }}

        {% endnamespace %}
    </div>

{% endset %}
