mirror of
https://github.com/Darkatse/TauriTavern.git
synced 2026-10-19 15:45:12 +00:00
chore (i18n): Update i18n strings related to "Attach to existing message".
This commit is contained in:
parent
890c64655c
commit
9cf35523e5
5 changed files with 106 additions and 19 deletions
|
|
@ -7188,7 +7188,7 @@
|
|||
<select id="completion_prompt_manager_popup_entry_form_injection_position" class="text_pole" name="injection_position">
|
||||
<option data-i18n="prompt_manager_relative" value="0">Relative</option>
|
||||
<option data-i18n="prompt_manager_in_chat" value="1">In-chat</option>
|
||||
<option data-i18n="prompt_manager_attach_existing" value="2">Attach to existing message</option>
|
||||
<option data-i18n="Attach to existing message" value="2">Attach to existing message</option>
|
||||
</select>
|
||||
<div class="text_muted" data-i18n="Relative (to other prompts in prompt manager), In-chat @ Depth, or attached to an existing message.">Relative (to other prompts in prompt manager), In-chat @ Depth, or attached to an existing message.</div>
|
||||
</div>
|
||||
|
|
@ -7211,29 +7211,29 @@
|
|||
<div id="completion_prompt_manager_attach_block" class="flex-container gap10px" style="display: none; margin-top: 10px;">
|
||||
<div class="completion_prompt_manager_popup_entry_form_control flex1">
|
||||
<label for="completion_prompt_manager_popup_entry_form_attach_role">
|
||||
<span data-i18n="prompt_manager_attach_role">Attach to Role</span>
|
||||
<span data-i18n="Attach to Role">Attach to Role</span>
|
||||
</label>
|
||||
<select id="completion_prompt_manager_popup_entry_form_attach_role" class="text_pole" name="attach_role">
|
||||
<option value="user">User</option>
|
||||
<option value="assistant">Assistant</option>
|
||||
<option value="system">System</option>
|
||||
<option data-i18n="User" value="user">User</option>
|
||||
<option data-i18n="AI Assistant" value="assistant">AI Assistant</option>
|
||||
<option data-i18n="System" value="system">System</option>
|
||||
</select>
|
||||
<div class="text_muted" data-i18n="Select the role of the message you want to target.">Select the role of the message you want to target.</div>
|
||||
</div>
|
||||
<div class="completion_prompt_manager_popup_entry_form_control flex1">
|
||||
<label for="completion_prompt_manager_popup_entry_form_attach_index">
|
||||
<span data-i18n="prompt_manager_attach_index">Message Index</span>
|
||||
<span data-i18n="Message Index">Message Index</span>
|
||||
</label>
|
||||
<input id="completion_prompt_manager_popup_entry_form_attach_index" class="text_pole" type="number" name="attach_index" value="1" />
|
||||
<div class="text_muted" data-i18n="Positive: count from start (1 = first). Negative: count from end (-1 = last). 0 defaults to 1. Only counts messages of selected role.">Positive: count from start (1 = first). Negative: count from end (-1 = last). 0 defaults to 1. Only counts messages of selected role.</div>
|
||||
</div>
|
||||
<div class="completion_prompt_manager_popup_entry_form_control flex1">
|
||||
<label for="completion_prompt_manager_popup_entry_form_attach_side">
|
||||
<span data-i18n="prompt_manager_attach_side">Attach Side</span>
|
||||
<span data-i18n="Attach Side">Attach Side</span>
|
||||
</label>
|
||||
<select id="completion_prompt_manager_popup_entry_form_attach_side" class="text_pole" name="attach_side">
|
||||
<option value="end">Append (End)</option>
|
||||
<option value="start">Prepend (Start)</option>
|
||||
<option data-i18n="Append" value="end">Append</option>
|
||||
<option data-i18n="Prepend" value="start">Prepend</option>
|
||||
</select>
|
||||
<div class="text_muted" data-i18n="Prepend to the start or append to the end of the message content.">Prepend to the start or append to the end of the message content.</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1343,14 +1343,16 @@
|
|||
"prompt_manager_position": "位置",
|
||||
"prompt_manager_relative": "相对",
|
||||
"prompt_manager_in_chat": "聊天中",
|
||||
"prompt_manager_attach_existing": "附着到已有消息",
|
||||
"Relative (to other prompts in prompt manager), In-chat @ Depth, or attached to an existing message.": "相对(相对于提示管理器中的其他提示)、在聊天中@深度,或者附着到已有的聊天消息上。",
|
||||
"prompt_manager_attach_role": "附着目标角色",
|
||||
"Attach to existing message": "附着到已有消息",
|
||||
"Relative (to other prompts in prompt manager), In-chat @ Depth, or attached to an existing message.": "相对(相对于提示管理器中的其他提示)、在聊天中 @ 深度,或者附着到已有的聊天消息上。",
|
||||
"Attach to Role": "附着目标角色",
|
||||
"Select the role of the message you want to target.": "选择你想要附着的目标消息角色。",
|
||||
"prompt_manager_attach_index": "消息顺序编号",
|
||||
"Positive: count from start (1 = first). Negative: count from end (-1 = last). 0 defaults to 1. Only counts messages of selected role.": "正数从前往后数(1=第一条),负数从后往前数(-1=最后一条)。0会按1处理。只计算符合所选角色的消息。",
|
||||
"prompt_manager_attach_side": "附着拼接位置",
|
||||
"Prepend to the start or append to the end of the message content.": "拼接到消息内容的开头 (Prepend) 或结尾 (Append)。",
|
||||
"Message Index": "消息顺序编号",
|
||||
"Positive: count from start (1 = first). Negative: count from end (-1 = last). 0 defaults to 1. Only counts messages of selected role.": "正数从前往后数(1 = 第一条),负数从后往前数(-1 = 最后一条)。0 会按 1 处理。只计算符合所选角色的消息。",
|
||||
"Attach Side": "附着拼接位置",
|
||||
"Append": "追加",
|
||||
"Prepend": "前置",
|
||||
"Prepend to the start or append to the end of the message content.": "拼接到消息内容的开头或结尾。",
|
||||
"prompt_manager_depth": "深度",
|
||||
"0 = after the last message, 1 = before the last message, etc.": "“0”为在最后一条消息之后,“1”为在最后一条消息之前,等等。",
|
||||
"prompt_manager_order": "排序",
|
||||
|
|
|
|||
|
|
@ -1019,6 +1019,16 @@
|
|||
"prompt_manager_position": "位置",
|
||||
"Next to other prompts (relative) or in-chat (absolute).": "與其他提示詞相鄰(相對位置)或在聊天中(絕對位置)。",
|
||||
"prompt_manager_relative": "相對位置",
|
||||
"Attach to existing message": "附著到既有訊息",
|
||||
"Relative (to other prompts in prompt manager), In-chat @ Depth, or attached to an existing message.": "相對(相對於提示詞管理器中的其他提示詞)、聊天中 @ 深度,或附著到既有聊天訊息。",
|
||||
"Attach to Role": "附著目標角色",
|
||||
"Select the role of the message you want to target.": "選擇要附著的目標訊息角色。",
|
||||
"Message Index": "訊息順序編號",
|
||||
"Positive: count from start (1 = first). Negative: count from end (-1 = last). 0 defaults to 1. Only counts messages of selected role.": "正數從前往後數(1 = 第一則),負數從後往前數(-1 = 最後一則)。0 會按 1 處理。只計算所選角色的訊息。",
|
||||
"Attach Side": "附著拼接位置",
|
||||
"Append": "追加",
|
||||
"Prepend": "前置",
|
||||
"Prepend to the start or append to the end of the message content.": "拼接到訊息內容的開頭或結尾。",
|
||||
"prompt_manager_depth": "深度",
|
||||
"0 = after the last message, 1 = before the last message, etc.": "0 = 在最後一則訊息之後,1 = 在最後一則訊息之前,以此類推。",
|
||||
"Prompt": "提示詞",
|
||||
|
|
@ -1704,7 +1714,7 @@
|
|||
"Prefer Character Card Instructions": "角色卡聊天歷史後指示優先",
|
||||
"Prioritize": "優先處理",
|
||||
"Prompt Content": "提示詞內容",
|
||||
"prompt_manager_in_chat": "聊天中的提示詞管理",
|
||||
"prompt_manager_in_chat": "聊天中",
|
||||
"prompt_post_processing_none": "無",
|
||||
"Purge Vectors": "清除向量",
|
||||
"Put images with expressions there. File names should follow the pattern:": "將表情立繪放置於此,檔案名稱應遵循以下格式:",
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { debounce, waitUntilCondition, escapeHtml, uuidv4 } from './utils.js';
|
|||
import { debounce_timeout } from './constants.js';
|
||||
import { renderTemplateAsync } from './templates.js';
|
||||
import { Popup } from './popup.js';
|
||||
import { t } from './i18n.js';
|
||||
import { t, translate } from './i18n.js';
|
||||
import { isMobile } from './RossAscends-mods.js';
|
||||
import { INJECTION_POSITION, getPromptInjectionPosition } from './prompt-injections.js';
|
||||
|
||||
|
|
@ -1759,6 +1759,9 @@ class PromptManager {
|
|||
}
|
||||
|
||||
const encodedName = escapeHtml(prompt.name);
|
||||
const attachSideText = prompt.attach_side === 'start'
|
||||
? translate('Prepend')
|
||||
: translate('Append');
|
||||
const injectionPosition = getPromptInjectionPosition(prompt);
|
||||
const isMarkerPrompt = prompt.marker && injectionPosition === INJECTION_POSITION.RELATIVE;
|
||||
const isSystemPrompt = !prompt.marker && prompt.system_prompt && injectionPosition === INJECTION_POSITION.RELATIVE && !prompt.forbid_overrides;
|
||||
|
|
@ -1792,7 +1795,7 @@ class PromptManager {
|
|||
${roleIcon ? `<span data-role="${escapeHtml(prompt.role)}" class="fa-xs fa-solid ${roleIcon}" title="${roleTitle}"></span>` : ''}
|
||||
${isInjectionPrompt ? `<small class="prompt-manager-injection-depth">@ ${escapeHtml(prompt.injection_depth.toString())}</small>` : ''}
|
||||
${isAttachedPrompt
|
||||
? `<small class="prompt-manager-injection-depth">${escapeHtml(prompt.attach_side === 'start' ? 'Prepend' : 'Append')} to ${escapeHtml(prompt.attach_role)} ${escapeHtml(String(prompt.attach_index))}</small>`
|
||||
? `<small class="prompt-manager-injection-depth">${escapeHtml(attachSideText)} to ${escapeHtml(prompt.attach_role)} ${escapeHtml(String(prompt.attach_index))}</small>`
|
||||
: ''}
|
||||
${isOverriddenPrompt ? '<small class="fa-solid fa-address-card prompt-manager-overridden" title="Pulled from a character card"></small>' : ''}
|
||||
</span>
|
||||
|
|
|
|||
72
tests/prompt-manager-i18n-contract.test.mjs
Normal file
72
tests/prompt-manager-i18n-contract.test.mjs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readdir, readFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const LOCALES_DIR = path.join(REPO_ROOT, 'src', 'locales');
|
||||
|
||||
const ATTACH_EXISTING_ENGLISH_I18N_KEYS = [
|
||||
'Attach to existing message',
|
||||
'Relative (to other prompts in prompt manager), In-chat @ Depth, or attached to an existing message.',
|
||||
'Attach to Role',
|
||||
'Select the role of the message you want to target.',
|
||||
'Message Index',
|
||||
'Positive: count from start (1 = first). Negative: count from end (-1 = last). 0 defaults to 1. Only counts messages of selected role.',
|
||||
'Attach Side',
|
||||
'Append',
|
||||
'Prepend',
|
||||
'Prepend to the start or append to the end of the message content.',
|
||||
];
|
||||
|
||||
const REMOVED_PROMPT_MANAGER_ATTACH_KEYS = [
|
||||
'prompt_manager_attach_existing',
|
||||
'prompt_manager_position_help',
|
||||
'prompt_manager_attach_role',
|
||||
'prompt_manager_attach_role_help',
|
||||
'prompt_manager_attach_index',
|
||||
'prompt_manager_attach_index_help',
|
||||
'prompt_manager_attach_side',
|
||||
'prompt_manager_attach_append',
|
||||
'prompt_manager_attach_prepend',
|
||||
'prompt_manager_attach_side_help',
|
||||
];
|
||||
|
||||
test('prompt manager attach-existing form uses English text i18n keys for new strings', async () => {
|
||||
const html = await readFile(path.join(REPO_ROOT, 'src', 'index.html'), 'utf8');
|
||||
|
||||
assert.match(html, /data-i18n="Attach to existing message"/);
|
||||
assert.match(html, /data-i18n="Relative \(to other prompts in prompt manager\), In-chat @ Depth, or attached to an existing message\."/);
|
||||
assert.match(html, /<option data-i18n="User" value="user">User<\/option>/);
|
||||
assert.match(html, /<option data-i18n="AI Assistant" value="assistant">AI Assistant<\/option>/);
|
||||
assert.match(html, /<option data-i18n="System" value="system">System<\/option>/);
|
||||
assert.match(html, /<option data-i18n="Append" value="end">Append<\/option>/);
|
||||
assert.match(html, /<option data-i18n="Prepend" value="start">Prepend<\/option>/);
|
||||
|
||||
for (const key of REMOVED_PROMPT_MANAGER_ATTACH_KEYS) {
|
||||
assert.doesNotMatch(html, new RegExp(`data-i18n="${key}"`));
|
||||
}
|
||||
});
|
||||
|
||||
test('prompt manager attach-existing translations are only required for Chinese locales', async () => {
|
||||
for (const fileName of ['zh-cn.json', 'zh-tw.json']) {
|
||||
const locale = JSON.parse(await readFile(path.join(LOCALES_DIR, fileName), 'utf8'));
|
||||
const missingKeys = ATTACH_EXISTING_ENGLISH_I18N_KEYS.filter(key => !Object.hasOwn(locale, key));
|
||||
|
||||
assert.deepEqual(missingKeys, [], `${fileName} is missing attach-existing i18n keys`);
|
||||
}
|
||||
});
|
||||
|
||||
test('prompt manager attach-existing does not add new stable keys to locale files', async () => {
|
||||
const localeFiles = (await readdir(LOCALES_DIR))
|
||||
.filter(fileName => fileName.endsWith('.json') && fileName !== 'lang.json')
|
||||
.sort();
|
||||
|
||||
for (const fileName of localeFiles) {
|
||||
const locale = JSON.parse(await readFile(path.join(LOCALES_DIR, fileName), 'utf8'));
|
||||
const stableKeys = REMOVED_PROMPT_MANAGER_ATTACH_KEYS.filter(key => Object.hasOwn(locale, key));
|
||||
|
||||
assert.deepEqual(stableKeys, [], `${fileName} should use English text keys for attach-existing i18n`);
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue