Skip to content

Commit 1550981

Browse files
committed
translation prompts toggle (Issue #2)
Added option in settings to disable default translation prompts
1 parent 0e82772 commit 1550981

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/models/SettingsModel.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ class SettingsModel extends Model
3232
*/
3333
public int $maxTokens = 256;
3434

35+
/**
36+
* @var bool
37+
*/
38+
public bool $showTranslationPrompts = true;
39+
3540
/**
3641
* @return string
3742
*/

src/templates/form.twig

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
{% set currentLang = "" %}
2222

23+
{% set displayTranslationPrompts = craft.app.getPlugins.getPlugin('chatgpt-integration').settings.showTranslationPrompts %}
24+
2325
{% if craft.app.getPlugins.getPlugin('chatgpt-integration').settings.usePageLang %}
2426
{% for site in craft.app.sites.getAllSites() %}
2527
{% if site.handle == craft.app.request.getQueryParam('site') %}
@@ -40,9 +42,16 @@
4042
<ul class="padded">
4143
{% for item in prompts %}
4244
<li><a href="javascript:void(0)" class="doAi" type="button" role="button" data-hash="{{ hash }}" data-prompt="{{ currentLang }} {{ item.promptTemplate }}: " aria-label="{{ item.label }}">{{ item.label }}</a></li>
45+
{% else %}
46+
{% if displayTranslationPrompts == false %}
47+
<li style="padding: 1em 0"><p>{{ 'No prompts found'|t('chatgpt-integration') }}</p></li>
48+
{% endif %}
4349
{% endfor %}
4450
</ul>
45-
<hr>
51+
{% if displayTranslationPrompts %}
52+
{% if prompts|length %}
53+
<hr>
54+
{% endif %}
4655
<ul class="padded">
4756
{% if craft.app.sites.getAllSites()|length > 1 %}
4857
{% for site in craft.app.sites.getAllSites () %}
@@ -60,6 +69,7 @@
6069
<a href="#" class="open-modal">{{ 'Senden'|t('chatgpt-integration') }}</a>
6170
</li>
6271
</ul>#}
72+
{% endif %}
6373
</div>
6474
</div>
6575
{% endif %}

src/templates/settings/general.twig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828
instructions: 'Always use current page language for query results.'|t('chatgpt-integration'),
2929
}) }}
3030

31+
{{ forms.lightSwitchField({
32+
label: 'Display default translation prompts.'|t('chatgpt-integration'),
33+
name: 'showTranslationPrompts',
34+
value: settings.showTranslationPrompts,
35+
on: settings.showTranslationPrompts,
36+
instructions: 'Provide default translation prompts based on the configured languages of your setup.'
37+
}) }}
38+
3139
{{ forms.autosuggestField({
3240
label: 'API: Access Token'|t('chatgpt-integration'),
3341
name: 'accessToken',

0 commit comments

Comments
 (0)