fix(i18n): enable translations in all templates and implement cookie-based language persistence

- Add _() translation function to add_tablet.html, add_user.html, loan_tablet.html
- Add _() translation function to add_non_loanable_device.html, edit_non_loanable_device.html
- Add _() translation function to history.html, non_loanable_devices.html, project_management.html
- Update app.py to use cookie-based language persistence with 1-year expiry
- Add /set_language endpoint to handle language switching with cookie + session
- Update language switcher in base.html to use new endpoint
- Set Spanish (es) as default language for internal app
- Import make_response and session from Flask
This commit is contained in:
ijuanes 2026-06-20 13:14:41 +01:00
parent 8c1d12a5c4
commit 2248237c79
10 changed files with 133 additions and 107 deletions

View file

@ -1,25 +1,25 @@
{% extends "base.html" %}
{% block content %}
<h2>Project Management - Development Notes</h2>
<h2>{{ _('Project Management - Development Notes') }}</h2>
<div class="project-management-container">
<div class="editor-section">
<div class="editor-controls">
<button onclick="saveNotes()" class="btn">Save Notes</button>
<button onclick="loadNotes()" class="btn">Reload</button>
<button onclick="saveNotes()" class="btn">{{ _('Save Notes') }}</button>
<button onclick="loadNotes()" class="btn">{{ _('Reload') }}</button>
<span id="status" style="margin-left: 15px; font-style: italic;"></span>
</div>
<div class="editor-row">
<div class="editor-col">
<h3>Editor</h3>
<h3>{{ _('Editor') }}</h3>
<textarea id="markdown-editor" class="markdown-editor"
placeholder="Write your markdown notes here..."></textarea>
placeholder="{{ _('Write your markdown notes here...') }}"></textarea>
</div>
<div class="editor-col">
<h3>Preview</h3>
<h3>{{ _('Preview') }}</h3>
<div id="markdown-preview" class="markdown-preview"></div>
</div>
</div>
@ -54,13 +54,13 @@
.then(content => {
document.getElementById('markdown-editor').value = content;
document.getElementById('markdown-preview').innerHTML = marked.parse(content);
document.getElementById('status').textContent = 'Loaded successfully';
document.getElementById('status').textContent = '{{ _("Loaded successfully") }}';
setTimeout(() => {
document.getElementById('status').textContent = '';
}, 2000);
})
.catch(error => {
document.getElementById('status').textContent = 'Using default content';
document.getElementById('status').textContent = '{{ _("Using default content") }}';
setTimeout(() => {
document.getElementById('status').textContent = '';
}, 2000);
@ -80,10 +80,10 @@
})
.then(response => {
if (response.ok) {
statusEl.textContent = 'Saved successfully!';
statusEl.textContent = '{{ _("Saved successfully!") }}';
statusEl.style.color = '#4CAF50';
} else {
statusEl.textContent = 'Error saving';
statusEl.textContent = '{{ _("Error saving") }}';
statusEl.style.color = '#f44336';
}
setTimeout(() => {
@ -92,7 +92,7 @@
}, 2000);
})
.catch(error => {
statusEl.textContent = 'Error: ' + error.message;
statusEl.textContent = '{{ _("Error") }}: ' + error.message;
statusEl.style.color = '#f44336';
setTimeout(() => {
statusEl.textContent = '';