mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Work on tl
This commit is contained in:
@@ -291,7 +291,7 @@ async function onDeleteBackgroundClick(e) {
|
||||
const bgToDelete = $(this).closest('.bg_example');
|
||||
const url = bgToDelete.data('url');
|
||||
const isCustom = bgToDelete.attr('custom') === 'true';
|
||||
const confirm = await callPopup('<h3>Delete the background?</h3>', 'confirm');
|
||||
const confirm = await callPopup('<h3>' + t`Delete the background?` + '</h3>', 'confirm');
|
||||
const bg = bgToDelete.attr('bgfile');
|
||||
|
||||
if (confirm) {
|
||||
|
@@ -13,6 +13,7 @@ import {
|
||||
getBase64Async,
|
||||
resetScrollHeight,
|
||||
initScrollHeight,
|
||||
localizePagination
|
||||
} from './utils.js';
|
||||
import { RA_CountCharTokens, humanizedDateTime, dragElement, favsToHotswap, getMessageTimeStamp } from './RossAscends-mods.js';
|
||||
import { power_user, loadMovingUIState, sortEntitiesList } from './power-user.js';
|
||||
@@ -1394,6 +1395,7 @@ function printGroupCandidates() {
|
||||
for (const i of data) {
|
||||
$('#rm_group_add_members').append(getGroupCharacterBlock(i.item));
|
||||
}
|
||||
localizePagination($('#rm_group_add_members_pagination'));
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -1401,6 +1403,7 @@ function printGroupCandidates() {
|
||||
function printGroupMembers() {
|
||||
const storageKey = 'GroupMembers_PerPage';
|
||||
$('.rm_group_members_pagination').each(function () {
|
||||
let that = this;
|
||||
$(this).pagination({
|
||||
dataSource: getGroupCharacters({ doFilter: false, onlyMembers: true }),
|
||||
pageRange: 1,
|
||||
@@ -1421,6 +1424,7 @@ function printGroupMembers() {
|
||||
for (const i of data) {
|
||||
$('.rm_group_members').append(getGroupCharacterBlock(i.item));
|
||||
}
|
||||
localizePagination($(that));
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -1804,7 +1808,7 @@ async function createGroup() {
|
||||
const memberNames = characters.filter(x => members.includes(x.avatar)).map(x => x.name).join(', ');
|
||||
|
||||
if (!name) {
|
||||
name = `Group: ${memberNames}`;
|
||||
name = t`Group:` + ` ${memberNames}`;
|
||||
}
|
||||
|
||||
const avatar_url = $('#group_avatar_preview img').attr('src');
|
||||
|
@@ -394,7 +394,7 @@ function getHordeModelTemplate(option) {
|
||||
`));
|
||||
}
|
||||
|
||||
jQuery(function () {
|
||||
export function initHorde () {
|
||||
$('#horde_model').on('mousedown change', async function (e) {
|
||||
console.log('Horde model change', e);
|
||||
horde_settings.models = $('#horde_model').val();
|
||||
@@ -441,7 +441,7 @@ jQuery(function () {
|
||||
if (!isMobile()) {
|
||||
$('#horde_model').select2({
|
||||
width: '100%',
|
||||
placeholder: 'Select Horde models',
|
||||
placeholder: t`Select Horde models`,
|
||||
allowClear: true,
|
||||
closeOnSelect: false,
|
||||
templateSelection: function (data) {
|
||||
@@ -451,5 +451,5 @@ jQuery(function () {
|
||||
templateResult: getHordeModelTemplate,
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
@@ -3851,7 +3851,7 @@ function createLogitBiasListItem(entry) {
|
||||
}
|
||||
|
||||
async function createNewLogitBiasPreset() {
|
||||
const name = await callPopup('Preset name:', 'input');
|
||||
const name = await callPopup(t`Preset name:`, 'input');
|
||||
|
||||
if (!name) {
|
||||
return;
|
||||
|
@@ -22,12 +22,12 @@ import {
|
||||
} from '../script.js';
|
||||
import { persona_description_positions, power_user } from './power-user.js';
|
||||
import { getTokenCountAsync } from './tokenizers.js';
|
||||
import { PAGINATION_TEMPLATE, clearInfoBlock, debounce, delay, download, ensureImageFormatSupported, flashHighlight, getBase64Async, getCharIndex, isFalseBoolean, isTrueBoolean, onlyUnique, parseJsonFile, setInfoBlock } from './utils.js';
|
||||
import { PAGINATION_TEMPLATE, clearInfoBlock, debounce, delay, download, ensureImageFormatSupported, flashHighlight, getBase64Async, getCharIndex, isFalseBoolean, isTrueBoolean, onlyUnique, parseJsonFile, setInfoBlock, localizePagination } from './utils.js';
|
||||
import { debounce_timeout } from './constants.js';
|
||||
import { FILTER_TYPES, FilterHelper } from './filters.js';
|
||||
import { groups, selected_group } from './group-chats.js';
|
||||
import { POPUP_TYPE, Popup, callGenericPopup } from './popup.js';
|
||||
import { t } from './i18n.js';
|
||||
import { t, translate } from './i18n.js';
|
||||
import { openWorldInfoEditor, world_names } from './world-info.js';
|
||||
import { renderTemplateAsync } from './templates.js';
|
||||
import { saveMetadataDebounced } from './extensions.js';
|
||||
@@ -263,6 +263,7 @@ export async function getUserAvatars(doRender = true, openPageAt = '') {
|
||||
prevText: '<',
|
||||
nextText: '>',
|
||||
formatNavigator: PAGINATION_TEMPLATE,
|
||||
afterRender: function(a) {console.log(a)},
|
||||
showNavigator: true,
|
||||
callback: function (data) {
|
||||
$(listId).empty();
|
||||
@@ -270,6 +271,7 @@ export async function getUserAvatars(doRender = true, openPageAt = '') {
|
||||
$(listId).append(getUserAvatarBlock(item));
|
||||
}
|
||||
updatePersonaUIStates();
|
||||
localizePagination($('#persona_pagination_container'));
|
||||
},
|
||||
afterSizeSelectorChange: function (e) {
|
||||
accountStorage.setItem(storageKey, e.target.value);
|
||||
|
@@ -27,7 +27,7 @@ import { debounce_timeout } from './constants.js';
|
||||
import { INTERACTABLE_CONTROL_CLASS } from './keyboard.js';
|
||||
import { commonEnumProviders } from './slash-commands/SlashCommandCommonEnumsProvider.js';
|
||||
import { renderTemplateAsync } from './templates.js';
|
||||
import { t } from './i18n.js';
|
||||
import { t, translate } from './i18n.js';
|
||||
|
||||
export {
|
||||
TAG_FOLDER_TYPES,
|
||||
@@ -1057,7 +1057,7 @@ function appendTagToList(listElement, tag, { removable = false, isFilter = false
|
||||
tagElement.attr('title', tag.title);
|
||||
}
|
||||
if (tag.icon) {
|
||||
tagElement.find('.tag_name').text('').attr('title', `${tag.name} ${tag.title || ''}`.trim()).addClass(tag.icon);
|
||||
tagElement.find('.tag_name').text('').attr('title', `${translate(tag.name)} ${tag.title || ''}`.trim()).addClass(tag.icon);
|
||||
tagElement.addClass('actionable');
|
||||
}
|
||||
|
||||
@@ -1644,6 +1644,7 @@ function updateDrawTagFolder(element, tag) {
|
||||
|
||||
// Draw/update css attributes for this class
|
||||
folderElement.attr('title', tagFolder.tooltip);
|
||||
folderElement.attr('data-i18n', '[title]' + tagFolder.tooltip);
|
||||
const indicator = folderElement.find('.tag_folder_indicator');
|
||||
indicator.text(tagFolder.icon);
|
||||
indicator.css('color', tagFolder.color);
|
||||
@@ -1656,9 +1657,9 @@ async function onTagDeleteClick() {
|
||||
const otherTags = sortTags(tags.filter(x => x.id !== id).map(x => ({ id: x.id, name: x.name })));
|
||||
|
||||
const popupContent = $(`
|
||||
<h3>Delete Tag</h3>
|
||||
<div>Do you want to delete the tag <div id="tag_to_delete" class="tags_inline inline-flex margin-r2"></div>?</div>
|
||||
<div class="m-t-2 marginBot5">If you want to merge all references to this tag into another tag, select it below:</div>
|
||||
<h3>` + t`Delete Tag` + `</h3>
|
||||
<div>` + t`Do you want to delete the tag` + ` <div id="tag_to_delete" class="tags_inline inline-flex margin-r2"></div>?</div>
|
||||
<div class="m-t-2 marginBot5">` + t`If you want to merge all references to this tag into another tag, select it below:` + `</div>
|
||||
<select id="merge_tag_select">
|
||||
<option value="">--- None ---</option>
|
||||
${otherTags.map(x => `<option value="${x.id}">${x.name}</option>`).join('')}
|
||||
|
@@ -5,8 +5,9 @@ import { textgenerationwebui_settings as textgen_settings, textgen_types } from
|
||||
import { tokenizers } from './tokenizers.js';
|
||||
import { renderTemplateAsync } from './templates.js';
|
||||
import { POPUP_TYPE, callGenericPopup } from './popup.js';
|
||||
import { t } from './i18n.js';
|
||||
import { t, translate } from './i18n.js';
|
||||
import { accountStorage } from './util/AccountStorage.js';
|
||||
import { localizePagination } from './utils.js';
|
||||
|
||||
let mancerModels = [];
|
||||
let togetherModels = [];
|
||||
@@ -368,7 +369,16 @@ export async function loadFeatherlessModels(data) {
|
||||
prevText: '<',
|
||||
nextText: '>',
|
||||
formatNavigator: function (currentPage, totalPage) {
|
||||
return (currentPage - 1) * perPage + 1 + ' - ' + currentPage * perPage + ' of ' + totalPage * perPage;
|
||||
let translated_of;
|
||||
try {
|
||||
translated_of = translate('pagination_of');
|
||||
if (translated_of == 'pagination_of') {
|
||||
translated_of = 'of';
|
||||
}
|
||||
} catch (e) {
|
||||
translated_of = 'of';
|
||||
}
|
||||
return (currentPage - 1) * perPage + 1 + ' - ' + currentPage * perPage + ` ${translated_of} ` + totalPage * perPage;
|
||||
},
|
||||
showNavigator: true,
|
||||
callback: function (modelsOnPage, pagination) {
|
||||
@@ -391,15 +401,15 @@ export async function loadFeatherlessModels(data) {
|
||||
|
||||
const modelClassDiv = document.createElement('div');
|
||||
modelClassDiv.classList.add('model-class');
|
||||
modelClassDiv.textContent = `Class: ${model.model_class || 'N/A'}`;
|
||||
modelClassDiv.textContent = t`Class` + `: ${model.model_class || 'N/A'}`;
|
||||
|
||||
const contextLengthDiv = document.createElement('div');
|
||||
contextLengthDiv.classList.add('model-context-length');
|
||||
contextLengthDiv.textContent = `Context Length: ${model.context_length}`;
|
||||
contextLengthDiv.textContent = t`Context Length` + `: ${model.context_length}`;
|
||||
|
||||
const dateAddedDiv = document.createElement('div');
|
||||
dateAddedDiv.classList.add('model-date-added');
|
||||
dateAddedDiv.textContent = `Added On: ${new Date(model.created * 1000).toLocaleDateString()}`;
|
||||
dateAddedDiv.textContent = t`Added On` + `: ${new Date(model.created * 1000).toLocaleDateString()}`;
|
||||
|
||||
detailsContainer.appendChild(modelClassDiv);
|
||||
detailsContainer.appendChild(contextLengthDiv);
|
||||
@@ -423,6 +433,7 @@ export async function loadFeatherlessModels(data) {
|
||||
|
||||
// Update the current page value whenever the page changes
|
||||
featherlessCurrentPage = pagination.pageNumber;
|
||||
localizePagination(paginationContainer);
|
||||
},
|
||||
afterSizeSelectorChange: function (e) {
|
||||
const newPerPage = e.target.value;
|
||||
|
@@ -14,13 +14,39 @@ import { Popup, POPUP_RESULT, POPUP_TYPE } from './popup.js';
|
||||
import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js';
|
||||
import { getTagsList } from './tags.js';
|
||||
import { groups, selected_group } from './group-chats.js';
|
||||
import { getCurrentLocale, t } from './i18n.js';
|
||||
import { getCurrentLocale, t, translate } from './i18n.js';
|
||||
|
||||
/**
|
||||
* Pagination status string template.
|
||||
* @type {string}
|
||||
* Function returning pagination status string template.
|
||||
* @type {function}
|
||||
*/
|
||||
export const PAGINATION_TEMPLATE = '<%= rangeStart %>-<%= rangeEnd %> of <%= totalNumber %>';
|
||||
export const PAGINATION_TEMPLATE = function() {
|
||||
let translated_of;
|
||||
try {
|
||||
translated_of = translate('pagination_of');
|
||||
if (translated_of == 'pagination_of') {
|
||||
translated_of = 'of';
|
||||
}
|
||||
} catch (e) {
|
||||
translated_of = 'of';
|
||||
}
|
||||
return `<%= rangeStart %>-<%= rangeEnd %> ${translated_of} <%= totalNumber %>`
|
||||
};
|
||||
|
||||
export const localizePagination = function(container) {
|
||||
let options = container.find('option');
|
||||
for (let option of options) {
|
||||
option = $(option);
|
||||
try {
|
||||
option.text(option.text().replace('/ page', translate('/ page')));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
container.find("[title='Next page']").attr('title', translate('Next page'));
|
||||
container.find("[title='Previous page']").attr('title', translate('Previous page'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigation options for pagination.
|
||||
|
@@ -2658,7 +2658,7 @@ export async function getWorldEntry(name, data, entry) {
|
||||
if (!isMobile()) {
|
||||
$(characterFilter).select2({
|
||||
width: '100%',
|
||||
placeholder: 'Tie this entry to specific characters or characters with specific tags',
|
||||
placeholder: t`Tie this entry to specific characters or characters with specific tags`,
|
||||
allowClear: true,
|
||||
closeOnSelect: false,
|
||||
});
|
||||
@@ -3258,7 +3258,7 @@ export async function getWorldEntry(name, data, entry) {
|
||||
|
||||
// Create wrapper div
|
||||
const wrapper = document.createElement('div');
|
||||
wrapper.textContent = t`Move "${sourceName}" to:`;
|
||||
wrapper.textContent = t`Move '${sourceName}' to:`;
|
||||
|
||||
// Create container and append elements
|
||||
const container = document.createElement('div');
|
||||
|
Reference in New Issue
Block a user