refactor: scope i18n state

This commit is contained in:
mARTin-B78 2026-09-04 13:40:07 +02:00
parent ee4208ec51
commit 417d7215d2
5 changed files with 27 additions and 9 deletions

View File

@ -8,6 +8,8 @@ Follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) · versioned wi
## [Unreleased] ## [Unreleased]
### Changed ### Changed
- **i18n namespace migration.** Language dictionaries and mutable language state now use a private scope with compatibility
exports and a `window.TTVC.i18n` API.
- **Audiobook-cast namespace migration.** Cast serialization, page stamping, and speaker normalization now use a private - **Audiobook-cast namespace migration.** Cast serialization, page stamping, and speaker normalization now use a private
scope with compatibility exports and the existing `window.TTVC.audiobook.cast` API. scope with compatibility exports and the existing `window.TTVC.audiobook.cast` API.
- **SillyTavern namespace migration.** Character-card parsing, import, and export helpers now use a private scope with - **SillyTavern namespace migration.** Character-card parsing, import, and export helpers now use a private scope with

View File

@ -1 +1 @@
1.24.95 1.24.96

View File

@ -83,6 +83,7 @@ Done incrementally as global-scope ordered files (no ES-module change needed)
- ✅ Seed-finder generation and caching helpers use a private scope with compatibility exports and a namespace API. - ✅ Seed-finder generation and caching helpers use a private scope with compatibility exports and a namespace API.
- ✅ Audiobook cast serialization and speaker normalization use a private scope with the existing cast namespace API. - ✅ Audiobook cast serialization and speaker normalization use a private scope with the existing cast namespace API.
- ✅ SillyTavern character-card import/export helpers use a private scope with a namespace API. - ✅ SillyTavern character-card import/export helpers use a private scope with a namespace API.
- ✅ i18n dictionaries and language state use a private scope with compatibility exports and a namespace API.
- ✅ `static/css/resource-diagnostics.css` — isolated Performance/resource diagnostic panel styles. - ✅ `static/css/resource-diagnostics.css` — isolated Performance/resource diagnostic panel styles.
- ✅ `static/css/background-jobs.css` — isolated background-job history and retry-panel styles. - ✅ `static/css/background-jobs.css` — isolated background-job history and retry-panel styles.
- ✅ `static/css/voice-design.css` — isolated Voice Design form, samples, and preview-match styles. - ✅ `static/css/voice-design.css` — isolated Voice Design form, samples, and preview-match styles.

View File

@ -10,7 +10,7 @@
<meta name="format-detection" content="telephone=no"> <meta name="format-detection" content="telephone=no">
<meta name="color-scheme" content="light dark"> <meta name="color-scheme" content="light dark">
<meta name="theme-color" content="#2563EB"> <meta name="theme-color" content="#2563EB">
<meta name="app-version" content="1.24.95"> <meta name="app-version" content="1.24.96">
<link rel="manifest" href="/manifest.webmanifest"> <link rel="manifest" href="/manifest.webmanifest">
<link rel="icon" href="/static/icon.svg" type="image/svg+xml"> <link rel="icon" href="/static/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/static/icon.svg"> <link rel="apple-touch-icon" href="/static/icon.svg">
@ -27,12 +27,12 @@
<!-- ── Core styles (local — no CDN dependency for first paint) ────────── --> <!-- ── Core styles (local — no CDN dependency for first paint) ────────── -->
<link rel="stylesheet" href="/static/vendor/mdi/materialdesignicons.min.css"> <link rel="stylesheet" href="/static/vendor/mdi/materialdesignicons.min.css">
<link rel="stylesheet" href="/static/style.css?v=1.24.95"> <link rel="stylesheet" href="/static/style.css?v=1.24.96">
<link rel="stylesheet" href="/static/css/resource-diagnostics.css?v=1.24.95"> <link rel="stylesheet" href="/static/css/resource-diagnostics.css?v=1.24.96">
<link rel="stylesheet" href="/static/css/background-jobs.css?v=1.24.95"> <link rel="stylesheet" href="/static/css/background-jobs.css?v=1.24.96">
<link rel="stylesheet" href="/static/css/voice-design.css?v=1.24.95"> <link rel="stylesheet" href="/static/css/voice-design.css?v=1.24.96">
<link rel="stylesheet" href="/static/css/rehearser.css?v=1.24.95"> <link rel="stylesheet" href="/static/css/rehearser.css?v=1.24.96">
<link rel="stylesheet" href="/static/css/audiobook.css?v=1.24.95"> <link rel="stylesheet" href="/static/css/audiobook.css?v=1.24.96">
<!-- ── Flag icons — non-blocking (loaded async, icons appear after JS) ── --> <!-- ── Flag icons — non-blocking (loaded async, icons appear after JS) ── -->
@ -397,7 +397,7 @@ window.toggleNavTree = function(treeId, chevronId) {
</script> </script>
<!-- loader.js: fetches sections → loads JS modules → removes skeleton --> <!-- loader.js: fetches sections → loads JS modules → removes skeleton -->
<script src="/static/loader.js?v=1.24.95"></script> <script src="/static/loader.js?v=1.24.96"></script>
</body> </body>
</html> </html>

View File

@ -8,6 +8,8 @@
// window.t('English') for JS-generated strings. Dynamic lists can be translated by // window.t('English') for JS-generated strings. Dynamic lists can be translated by
// calling window.applyI18n(container) after rendering. // calling window.applyI18n(container) after rendering.
(function (root) {
const I18N_LANGS = { const I18N_LANGS = {
en: 'English', de: 'Deutsch', fr: 'Français', es: 'Español', en: 'English', de: 'Deutsch', fr: 'Français', es: 'Español',
it: 'Italiano', pt: 'Português', nl: 'Nederlands', pl: 'Polski', it: 'Italiano', pt: 'Português', nl: 'Nederlands', pl: 'Polski',
@ -481,3 +483,16 @@ window.populateLangSelect = function () {
// Back-compat: loader.js calls initLangPicker() once at startup. The picker now // Back-compat: loader.js calls initLangPicker() once at startup. The picker now
// lives in Settings → General, so this just tries to populate it. // lives in Settings → General, so this just tries to populate it.
window.initLangPicker = function () { window.populateLangSelect(); }; window.initLangPicker = function () { window.populateLangSelect(); };
Object.assign(root, { I18N_LANGS, I18N_DICT });
root.TTVC = root.TTVC || {};
root.TTVC.i18n = root.TTVC.i18n || {};
Object.assign(root.TTVC.i18n, {
languages: I18N_LANGS,
dictionary: I18N_DICT,
get language() { return _appLang; },
translate: root.t,
apply: root.applyI18n,
set: root.setAppLang,
});
})(window);