tractatus/public/js/components/footer.js
TheFlow 31ed5b8a77 feat(i18n): add footer and privacy page translations (en/de/fr)
SUMMARY:
Implemented complete internationalization for footer component and
privacy page across English, German, and French languages.

CHANGES:

1. Privacy Page Translations (3 files):
   - Created locales/en/privacy.json (baseline)
   - Created locales/de/privacy.json (German - Datenschutzerklärung)
   - Created locales/fr/privacy.json (French - Politique de confidentialité)
   - All 11 sections + Te Tiriti fully translated

2. Footer i18n Enhancement:
   - Rewrote footer.js with data-i18n attributes
   - Added languageChanged event listener for dynamic updates
   - Expanded homepage.json footer translations (en/de/fr)
   - Footer now auto-translates with language selection

3. Privacy Page Integration:
   - Added data-page="privacy" attribute to HTML
   - Added data-i18n to all content sections (header + 11 sections)
   - Integrated with existing language-selector.js component
   - Updated i18n-simple.js pageMap to recognize privacy page

4. Bug Fix:
   - Fixed SessionStart hook error in .claude/settings.local.json
   - Changed from $CLAUDE_PROJECT_DIR to absolute path
   - Hook now runs successfully at session start

BENEFITS:
- Better UX for international users (German, French speakers)
- Legal compliance (privacy policy in native languages)
- Consistent language experience across entire site
- Leverages existing language persistence (localStorage)

INTEGRATION:
- Works with existing language-selector.js (flag icons: 🇬🇧 🇩🇪 🇫🇷)
- Language preference persists across all pages
- Zero duplication - integrates with existing i18n system

WCAG COMPLIANCE:
✓ Maintains semantic HTML structure
✓ Preserves WCAG AA contrast ratios
✓ All links remain accessible and distinguishable
✓ German and French translations maintain accessibility standards

FRAMEWORK COMPLIANCE:
✓ Zero CSP violations - uses data-i18n attributes only
✓ No inline scripts or styles
✓ Follows existing Tractatus i18n patterns

🤖 Generated with Claude Code (https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-19 14:44:14 +13:00

155 lines
6.8 KiB
JavaScript

/**
* Footer Component - i18n-enabled
* Shared footer for all Tractatus pages with language persistence
*/
(function() {
'use strict';
class TractatusFooter {
constructor() {
this.init();
}
init() {
// Wait for I18n to be ready before rendering
if (window.I18n && window.I18n.translations && Object.keys(window.I18n.translations).length > 0) {
this.render();
this.attachEventListeners();
} else {
// If I18n not ready, wait for it
const checkI18n = setInterval(() => {
if (window.I18n && window.I18n.translations && Object.keys(window.I18n.translations).length > 0) {
clearInterval(checkI18n);
this.render();
this.attachEventListeners();
}
}, 100);
// Fallback timeout - render without i18n after 2 seconds
setTimeout(() => {
clearInterval(checkI18n);
if (!document.querySelector('footer[role="contentinfo"]')) {
this.render();
this.attachEventListeners();
}
}, 2000);
}
}
render() {
const currentYear = new Date().getFullYear();
// Create footer HTML with data-i18n attributes
const footerHTML = `
<footer class="bg-gray-900 text-gray-300 mt-16" role="contentinfo">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
<!-- Main Footer Content -->
<div class="grid grid-cols-1 md:grid-cols-4 gap-8 mb-8">
<!-- About -->
<div>
<h3 class="text-white font-semibold mb-4" data-i18n="footer.about_heading">Tractatus Framework</h3>
<p class="text-sm text-gray-400" data-i18n="footer.about_text">
Architectural constraints for AI safety that preserve human agency through structural, not aspirational, guarantees.
</p>
</div>
<!-- Documentation -->
<div>
<h3 class="text-white font-semibold mb-4" data-i18n="footer.documentation_heading">Documentation</h3>
<ul class="space-y-2 text-sm">
<li><a href="/docs.html" class="hover:text-white transition" data-i18n="footer.documentation_links.framework_docs">Framework Docs</a></li>
<li><a href="/about.html" class="hover:text-white transition" data-i18n="footer.documentation_links.about">About</a></li>
<li><a href="/about/values.html" class="hover:text-white transition" data-i18n="footer.documentation_links.core_values">Core Values</a></li>
<li><a href="/demos/27027-demo.html" class="hover:text-white transition" data-i18n="footer.documentation_links.interactive_demo">Interactive Demo</a></li>
</ul>
</div>
<!-- Support -->
<div>
<h3 class="text-white font-semibold mb-4" data-i18n="footer.support_heading">Support</h3>
<ul class="space-y-2 text-sm">
<li><a href="/koha.html" class="hover:text-white transition" data-i18n="footer.support_links.koha">Support (Koha)</a></li>
<li><a href="/koha/transparency.html" class="hover:text-white transition" data-i18n="footer.support_links.transparency">Transparency</a></li>
<li><a href="/media-inquiry.html" class="hover:text-white transition" data-i18n="footer.support_links.media_inquiries">Media Inquiries</a></li>
<li><a href="/case-submission.html" class="hover:text-white transition" data-i18n="footer.support_links.submit_case">Submit Case Study</a></li>
</ul>
</div>
<!-- Legal & Contact -->
<div>
<h3 class="text-white font-semibold mb-4" data-i18n="footer.legal_heading">Legal</h3>
<ul class="space-y-2 text-sm">
<li><a href="/privacy.html" class="hover:text-white transition" data-i18n="footer.legal_links.privacy">Privacy Policy</a></li>
<li><a href="mailto:hello@agenticgovernance.digital" class="hover:text-white transition" data-i18n="footer.legal_links.contact">Contact Us</a></li>
<li><a href="https://github.com/AgenticGovernance/tractatus-framework" class="hover:text-white transition" target="_blank" rel="noopener">GitHub</a></li>
</ul>
</div>
</div>
<!-- Divider -->
<div class="border-t border-gray-800 pt-8">
<!-- Te Tiriti Acknowledgement -->
<div class="mb-6">
<p class="text-sm text-gray-400">
<strong class="text-gray-300" data-i18n="footer.te_tiriti_label">Te Tiriti o Waitangi:</strong>
<span data-i18n="footer.te_tiriti_text">We acknowledge Te Tiriti o Waitangi and our commitment to partnership, protection, and participation. This project respects Māori data sovereignty (rangatiratanga) and collective guardianship (kaitiakitanga).</span>
</p>
</div>
<!-- Bottom Row -->
<div class="flex flex-col md:flex-row justify-between items-center gap-4 text-sm">
<p class="text-gray-400">
© ${currentYear} <span data-i18n="footer.copyright">John G Stroh. Licensed under</span> <a href="https://www.apache.org/licenses/LICENSE-2.0" class="text-blue-400 hover:text-blue-300 transition" target="_blank" rel="noopener"><span data-i18n="footer.license">Apache 2.0</span></a>.
</p>
<p class="text-gray-400" data-i18n="footer.location">
Made in Aotearoa New Zealand 🇳🇿
</p>
</div>
</div>
</div>
</footer>
`;
// Insert footer at end of body
const existingFooter = document.querySelector('footer[role="contentinfo"]');
if (existingFooter) {
existingFooter.outerHTML = footerHTML;
} else if (document.body) {
document.body.insertAdjacentHTML('beforeend', footerHTML);
} else {
// If body not ready, wait for DOM
document.addEventListener('DOMContentLoaded', () => {
document.body.insertAdjacentHTML('beforeend', footerHTML);
});
}
// Apply translations if I18n is available
if (window.I18n && window.I18n.applyTranslations) {
window.I18n.applyTranslations();
}
}
attachEventListeners() {
// Listen for language changes and re-render footer
window.addEventListener('languageChanged', (event) => {
console.log('[Footer] Language changed to:', event.detail.language);
this.render();
});
}
}
// Auto-initialize when DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => new TractatusFooter());
} else {
new TractatusFooter();
}
})();