diff --git a/public/docs.html b/public/docs.html
index d7affbc4..93fe85f9 100644
--- a/public/docs.html
+++ b/public/docs.html
@@ -495,12 +495,25 @@
Framework Documentation
Technical specifications, guides, and reference materials
-
+
+
+
+
+
+
+
+
diff --git a/public/js/docs-app.js b/public/js/docs-app.js
index 91489280..0411a0d8 100644
--- a/public/js/docs-app.js
+++ b/public/js/docs-app.js
@@ -8,14 +8,28 @@ if (typeof DocumentCards !== 'undefined') {
documentCards = new DocumentCards('document-content');
}
-// Detect language from i18n system
+// Detect language from URL, localStorage, or i18n system
function detectLanguage() {
+ // Priority 1: URL parameter
+ const urlParams = new URLSearchParams(window.location.search);
+ const urlLang = urlParams.get('lang');
+ if (urlLang) {
+ return urlLang;
+ }
+
+ // Priority 2: localStorage
+ const storedLang = localStorage.getItem('tractatus_language');
+ if (storedLang) {
+ return storedLang;
+ }
+
+ // Priority 3: i18n system
if (window.I18n && window.I18n.currentLang) {
return window.I18n.currentLang;
}
- // Fallback: Check URL parameter
- const urlParams = new URLSearchParams(window.location.search);
- return urlParams.get('lang') || 'en';
+
+ // Default: English
+ return 'en';
}
// Update URL with language parameter
@@ -627,6 +641,40 @@ function closeToCModal() {
// Initialize
loadDocuments();
+// Initialize language selector
+(function initLanguageSelector() {
+ const selector = document.getElementById('language-selector');
+ if (!selector) return;
+
+ // Set initial value from current language
+ const initialLang = detectLanguage();
+ selector.value = initialLang;
+ currentLanguage = initialLang;
+
+ // Handle language change
+ selector.addEventListener('change', (e) => {
+ const newLang = e.target.value;
+
+ // Save to localStorage
+ localStorage.setItem('tractatus_language', newLang);
+
+ // Update current language
+ currentLanguage = newLang;
+
+ // Reload current document in new language
+ if (currentDocument) {
+ loadDocument(currentDocument.slug, newLang);
+ } else {
+ // If no document loaded yet, just update URL
+ const urlParams = new URLSearchParams(window.location.search);
+ const currentDoc = urlParams.get('doc');
+ if (currentDoc) {
+ loadDocument(currentDoc, newLang);
+ }
+ }
+ });
+})();
+
// Add ESC key listener for closing modal
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {