#976 Return "Continue on send". Allow continuing the first chat message. Add debug function for i18n.

This commit is contained in:
Cohee
2023-08-24 15:13:04 +03:00
parent 3e25c3f51c
commit f5fd15ffd2
6 changed files with 79 additions and 2 deletions

View File

@ -3,6 +3,55 @@ import { waitUntilCondition } from "./utils.js";
const storageKey = "language";
export const localeData = await fetch("i18n.json").then(response => response.json());
function getMissingTranslations() {
const missingData = [];
for (const language of localeData.lang) {
$(document).find("[data-i18n]").each(function () {
const keys = $(this).data("i18n").split(';'); // Multi-key entries are ; delimited
for (const key of keys) {
const attributeMatch = key.match(/\[(\S+)\](.+)/); // [attribute]key
if (attributeMatch) { // attribute-tagged key
const localizedValue = localeData?.[language]?.[attributeMatch[2]];
if (!localizedValue) {
missingData.push({ key, language, value: $(this).attr(attributeMatch[1]) });
}
} else { // No attribute tag, treat as 'text'
const localizedValue = localeData?.[language]?.[key];
if (!localizedValue) {
missingData.push({ key, language, value: $(this).text().trim() });
}
}
}
});
}
// Remove duplicates
const uniqueMissingData = [];
for (const { key, language, value } of missingData) {
if (!uniqueMissingData.some(x => x.key === key && x.language === language && x.value === value)) {
uniqueMissingData.push({ key, language, value });
}
}
// Sort by language, then key
uniqueMissingData.sort((a, b) => a.language.localeCompare(b.language) || a.key.localeCompare(b.key));
// Map to { language: { key: value } }
const missingDataMap = {};
for (const { key, language, value } of uniqueMissingData) {
if (!missingDataMap[language]) {
missingDataMap[language] = {};
}
missingDataMap[language][key] = value;
}
console.table(uniqueMissingData);
console.log(missingDataMap);
}
window["getMissingTranslations"] = getMissingTranslations;
export function applyLocale(root = document) {
const overrideLanguage = localStorage.getItem("language");
var language = overrideLanguage || navigator.language || navigator.userLanguage;

View File

@ -152,6 +152,7 @@ let power_user = {
prefer_character_prompt: true,
prefer_character_jailbreak: true,
quick_continue: false,
continue_on_send: false,
trim_spaces: true,
relaxed_api_urls: false,
@ -708,6 +709,7 @@ function loadPowerUserSettings(settings, data) {
$('#relaxed_api_urls').prop("checked", power_user.relaxed_api_urls);
$('#trim_spaces').prop("checked", power_user.trim_spaces);
$('#continue_on_send').prop("checked", power_user.continue_on_send);
$('#quick_continue').prop("checked", power_user.quick_continue);
$('#mes_continue').css('display', power_user.quick_continue ? '' : 'none');
$('#auto_swipe').prop("checked", power_user.auto_swipe);
@ -1968,6 +1970,12 @@ $(document).ready(() => {
saveSettingsDebounced();
});
$("#continue_on_send").on("input", function () {
const value = !!$(this).prop('checked');
power_user.continue_on_send = value;
saveSettingsDebounced();
});
$("#quick_continue").on("input", function () {
const value = !!$(this).prop('checked');
power_user.quick_continue = value;