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

@ -2,22 +2,22 @@
{% block content %}
<div class="section">
<h2>Non-Loanable Devices Inventory</h2>
<p>These devices are tracked in inventory but cannot be loaned to users.</p>
<a href="/add_non_loanable_device" class="btn">Add Non-Loanable Device</a>
<h2>{{ _('Non-Loanable Devices Inventory') }}</h2>
<p>{{ _('These devices are tracked in inventory but cannot be loaned to users.') }}</p>
<a href="/add_non_loanable_device" class="btn">{{ _('Add Non-Loanable Device') }}</a>
{% if devices %}
<div class="table-container">
<table>
<thead>
<tr>
<th>Type</th>
<th>Brand</th>
<th>Model</th>
<th>Serial Number</th>
<th>Location</th>
<th>Status</th>
<th>Actions</th>
<th>{{ _('Type') }}</th>
<th>{{ _('Brand') }}</th>
<th>{{ _('Model') }}</th>
<th>{{ _('Serial Number') }}</th>
<th>{{ _('Location') }}</th>
<th>{{ _('Status') }}</th>
<th>{{ _('Actions') }}</th>
</tr>
</thead>
<tbody>
@ -30,8 +30,8 @@
<td>{{ device.location or '-' }}</td>
<td>{{ device.status }}</td>
<td>
<a href="/edit_non_loanable_device/{{ device.id }}" class="btn">Edit</a>
<a href="/delete_non_loanable_device/{{ device.id }}" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete this device?')">Delete</a>
<a href="/edit_non_loanable_device/{{ device.id }}" class="btn">{{ _('Edit') }}</a>
<a href="/delete_non_loanable_device/{{ device.id }}" class="btn btn-danger" onclick="return confirm('{{ _("Are you sure you want to delete this device?") }}')">{{ _('Delete') }}</a>
</td>
</tr>
{% endfor %}
@ -39,7 +39,7 @@
</table>
</div>
{% else %}
<p>No non-loanable devices registered.</p>
<p>{{ _('No non-loanable devices registered.') }}</p>
{% endif %}
</div>
{% endblock %}