add_tags_force_lang option added. fixes #210
This commit is contained in:
parent
1803020a6c
commit
7b433c91df
6 changed files with 48 additions and 12 deletions
|
|
@ -819,7 +819,7 @@
|
||||||
"message": "Save",
|
"message": "Save",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"addtags_info_limit_num": {
|
"addtags_info_additional_statements": {
|
||||||
"message": "This statement will be added at the end of the prompt:",
|
"message": "This statement will be added at the end of the prompt:",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
|
|
@ -882,5 +882,17 @@
|
||||||
"OpenAIComp_force_model_ask": {
|
"OpenAIComp_force_model_ask": {
|
||||||
"message": "Insert here the model name you want to use.",
|
"message": "Insert here the model name you want to use.",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
},
|
||||||
|
"prefs_OptionText_add_tags_force_lang": {
|
||||||
|
"message": "Force language",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"prefs_OptionText_add_tags_force_lang_Info": {
|
||||||
|
"message": "If checked, the tags language will be forced to match the language defined on the add-on options page, if specified.",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"prompt_add_tags_force_lang": {
|
||||||
|
"message": "The tags must be written in ",
|
||||||
|
"description": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -182,7 +182,7 @@ export class mzta_Menus {
|
||||||
}
|
}
|
||||||
// console.log(">>>>>>>>>> finalSubs: " + JSON.stringify(finalSubs));
|
// console.log(">>>>>>>>>> finalSubs: " + JSON.stringify(finalSubs));
|
||||||
let prefs_ph = await browser.storage.sync.get({placeholders_use_default_value: false});
|
let prefs_ph = await browser.storage.sync.get({placeholders_use_default_value: false});
|
||||||
fullPrompt = placeholdersUtils.replacePlaceholders(curr_prompt.text, finalSubs, prefs_ph.placeholders_use_default_value, true) + (String(curr_prompt.need_signature) == "1" ? " " + await this.getDefaultSignature():"") + " " + chatgpt_lang;
|
fullPrompt = (placeholdersUtils.replacePlaceholders(curr_prompt.text, finalSubs, prefs_ph.placeholders_use_default_value, true) + (String(curr_prompt.need_signature) == "1" ? " " + await this.getDefaultSignature():"") + " " + chatgpt_lang).trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(curr_prompt.id){
|
switch(curr_prompt.id){
|
||||||
|
|
@ -208,7 +208,7 @@ export class mzta_Menus {
|
||||||
switch(curr_prompt.id){
|
switch(curr_prompt.id){
|
||||||
case 'prompt_add_tags': // Add tags to the email
|
case 'prompt_add_tags': // Add tags to the email
|
||||||
let mail_tags = '';
|
let mail_tags = '';
|
||||||
let prefs_at = await browser.storage.sync.get({add_tags_maxnum: 3, connection_type: ''});
|
let prefs_at = await browser.storage.sync.get({add_tags_maxnum: 3, connection_type: '', add_tags_force_lang: true, default_chatgpt_lang: ''});
|
||||||
if((prefs_at.connection_type === '')||(prefs_at.connection_type === null)||(prefs_at.connection_type === undefined)||(prefs_at.connection_type === 'chatgpt_web')){
|
if((prefs_at.connection_type === '')||(prefs_at.connection_type === null)||(prefs_at.connection_type === undefined)||(prefs_at.connection_type === 'chatgpt_web')){
|
||||||
console.error("[ThunderAI | AddTags] Invalid connection type: " + prefs_at.connection_type);
|
console.error("[ThunderAI | AddTags] Invalid connection type: " + prefs_at.connection_type);
|
||||||
return {ok:'0'};
|
return {ok:'0'};
|
||||||
|
|
@ -217,6 +217,9 @@ export class mzta_Menus {
|
||||||
if(add_tags_maxnum > 0){
|
if(add_tags_maxnum > 0){
|
||||||
fullPrompt += " " + browser.i18n.getMessage("prompt_add_tags_maxnum") + " " + add_tags_maxnum +".";
|
fullPrompt += " " + browser.i18n.getMessage("prompt_add_tags_maxnum") + " " + add_tags_maxnum +".";
|
||||||
}
|
}
|
||||||
|
if(prefs_at.add_tags_force_lang && prefs_at.default_chatgpt_lang !== ''){
|
||||||
|
fullPrompt += " " + browser.i18n.getMessage("prompt_add_tags_force_lang") + " " + prefs_at.default_chatgpt_lang + ".";
|
||||||
|
}
|
||||||
this.logger.log("fullPrompt: " + fullPrompt);
|
this.logger.log("fullPrompt: " + fullPrompt);
|
||||||
// TODO: use the current API, abort if using chatgpt web
|
// TODO: use the current API, abort if using chatgpt web
|
||||||
// COMMENTED TO DO TESTS
|
// COMMENTED TO DO TESTS
|
||||||
|
|
|
||||||
|
|
@ -41,4 +41,5 @@ export const prefs_default = {
|
||||||
add_tags_maxnum: 3,
|
add_tags_maxnum: 3,
|
||||||
add_tags_hide_exclusions: false,
|
add_tags_hide_exclusions: false,
|
||||||
add_tags_first_uppercase: true,
|
add_tags_first_uppercase: true,
|
||||||
|
add_tags_force_lang: true,
|
||||||
}
|
}
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
#addtags_info_limit_num{
|
#addtags_info_additional_statements{
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,15 @@
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="add_tags_tr">
|
||||||
|
<td><span>__MSG_prefs_OptionText_add_tags_force_lang__</span></td>
|
||||||
|
<td>
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" id="add_tags_force_lang" name="add_tags_force_lang" class="option-input" />
|
||||||
|
__MSG_prefs_OptionText_add_tags_force_lang_Info__
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div id="addtags_prompt_container">
|
<div id="addtags_prompt_container">
|
||||||
<span class="section_title">__MSG_AddTags_prompt_text_title__</span><span id="addtags_prompt_unsaved" class="unsaved hidden"> __MSG_customPrompts_unsaved_changes__</span>
|
<span class="section_title">__MSG_AddTags_prompt_text_title__</span><span id="addtags_prompt_unsaved" class="unsaved hidden"> __MSG_customPrompts_unsaved_changes__</span>
|
||||||
|
|
@ -50,7 +59,7 @@
|
||||||
<textarea id="addtags_prompt_text" rows="15"></textarea>
|
<textarea id="addtags_prompt_text" rows="15"></textarea>
|
||||||
<ul class="autocomplete-list hidden"></ul>
|
<ul class="autocomplete-list hidden"></ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="addtags_info_limit_num"></div>
|
<div id="addtags_info_additional_statements"></div>
|
||||||
<div class="btn_div"><button id="btn_reset_prompt" disabled>__MSG_reset_default__</button><button id="btn_save_prompt" disabled>__MSG_save__</button></div>
|
<div class="btn_div"><button id="btn_reset_prompt" disabled>__MSG_reset_default__</button><button id="btn_save_prompt" disabled>__MSG_save__</button></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="addtags_excl_list_container">
|
<div id="addtags_excl_list_container">
|
||||||
|
|
|
||||||
|
|
@ -74,9 +74,10 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
addtags_textarea.value = addtags_prompt.text;
|
addtags_textarea.value = addtags_prompt.text;
|
||||||
addtags_reset_btn.disabled = (addtags_textarea.value === browser.i18n.getMessage('prompt_add_tags_full_text'));
|
addtags_reset_btn.disabled = (addtags_textarea.value === browser.i18n.getMessage('prompt_add_tags_full_text'));
|
||||||
|
|
||||||
document.getElementById('add_tags_maxnum').addEventListener('change', updateMaxTagsNumDesc);
|
document.getElementById('add_tags_maxnum').addEventListener('change', updateAdditionalPromptStatements);
|
||||||
|
document.getElementById('add_tags_force_lang').addEventListener('change', updateAdditionalPromptStatements);
|
||||||
|
|
||||||
updateMaxTagsNumDesc();
|
updateAdditionalPromptStatements();
|
||||||
|
|
||||||
autocompleteSuggestions = (await getPlaceholders(true)).filter(p => !(p.id === 'selected_text' || p.id === 'additional_text')).map(p => ({command: '{%'+p.id+'%}', type: p.type}));
|
autocompleteSuggestions = (await getPlaceholders(true)).filter(p => !(p.id === 'selected_text' || p.id === 'additional_text')).map(p => ({command: '{%'+p.id+'%}', type: p.type}));
|
||||||
textareaAutocomplete(addtags_textarea, autocompleteSuggestions, 1); // type_value = 1, only when reading an email
|
textareaAutocomplete(addtags_textarea, autocompleteSuggestions, 1); // type_value = 1, only when reading an email
|
||||||
|
|
@ -110,11 +111,21 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
async function updateMaxTagsNumDesc(){
|
async function updateAdditionalPromptStatements(){
|
||||||
let prefs_maxt = await browser.storage.sync.get({add_tags_maxnum: 3});
|
let prefs_ = await browser.storage.sync.get({add_tags_maxnum: 3, add_tags_force_lang: true, default_chatgpt_lang: ''});
|
||||||
let el_tag_limit = document.getElementById('addtags_info_limit_num');
|
let el_tag_limit = document.getElementById('addtags_info_additional_statements');
|
||||||
if(prefs_maxt.add_tags_maxnum > 0){
|
if((prefs_.add_tags_maxnum > 0)||(prefs_.add_tags_force_lang && prefs_.default_chatgpt_lang !== '')){
|
||||||
el_tag_limit.textContent = browser.i18n.getMessage("addtags_info_limit_num") + " \"" + browser.i18n.getMessage("prompt_add_tags_maxnum") + " " + prefs_maxt.add_tags_maxnum +"\".";
|
el_tag_limit.textContent = browser.i18n.getMessage("addtags_info_additional_statements") + " \""
|
||||||
|
if(prefs_.add_tags_maxnum > 0){
|
||||||
|
el_tag_limit.textContent += browser.i18n.getMessage("prompt_add_tags_maxnum") + " " + prefs_.add_tags_maxnum +"."
|
||||||
|
}
|
||||||
|
if(prefs_.add_tags_force_lang && prefs_.default_chatgpt_lang !== ''){
|
||||||
|
if(prefs_.add_tags_maxnum > 0){
|
||||||
|
el_tag_limit.textContent += " "
|
||||||
|
}
|
||||||
|
el_tag_limit.textContent += browser.i18n.getMessage("prompt_add_tags_force_lang") + " " + prefs_.default_chatgpt_lang + "."
|
||||||
|
}
|
||||||
|
el_tag_limit.textContent += "\".";
|
||||||
el_tag_limit.style.display = 'block';
|
el_tag_limit.style.display = 'block';
|
||||||
}else{
|
}else{
|
||||||
el_tag_limit.style.display = 'none';
|
el_tag_limit.style.display = 'none';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue