Adds a full translation layer (English + European Portuguese) using
BurntSushi/toml with go:embed. Locale detection reads the lang cookie,
falls back to Accept-Language, then defaults to "en". A language switcher
in the nav writes the cookie and redirects back. All 20 personal finance
templates now use {{.T.Get "key"}} for every UI string.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
72 lines
2.6 KiB
HTML
72 lines
2.6 KiB
HTML
{{define "content"}}
|
|
{{$d := .}}
|
|
<h1 style="margin-bottom:24px;">{{$d.T.Get "accounts.title"}}</h1>
|
|
|
|
<div class="card animate-on-scroll">
|
|
<h2 style="margin-bottom:16px;">{{$d.T.Get "accounts.add_title"}}</h2>
|
|
<form method="POST" class="flex flex-wrap" style="gap:10px; align-items:flex-end;">
|
|
<div class="form-group" style="margin-bottom:0; flex:1; min-width:180px;">
|
|
<label>{{$d.T.Get "accounts.label_name"}}</label>
|
|
<input type="text" name="name" placeholder="{{$d.T.Get "accounts.placeholder_name"}}" required>
|
|
</div>
|
|
<div class="form-group" style="margin-bottom:0; min-width:160px;">
|
|
<label>{{$d.T.Get "accounts.label_type"}}</label>
|
|
<select name="type">
|
|
<option value="checking">{{$d.T.Get "accounts.type_checking"}}</option>
|
|
<option value="savings">{{$d.T.Get "accounts.type_savings"}}</option>
|
|
<option value="credit">{{$d.T.Get "accounts.type_credit"}}</option>
|
|
<option value="securities">{{$d.T.Get "accounts.type_securities"}}</option>
|
|
</select>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">{{$d.T.Get "accounts.btn_add"}}</button>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="card animate-on-scroll">
|
|
<div class="table-wrap">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>{{$d.T.Get "accounts.col_name"}}</th>
|
|
<th>{{$d.T.Get "accounts.col_type"}}</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{range $d.Accounts}}
|
|
<tr id="acct-row-{{.ID}}">
|
|
<td style="font-weight:500;">{{.Name}}</td>
|
|
<td>
|
|
{{$icon := "🏦"}}
|
|
{{if eq .Type "savings"}}{{$icon = "🏧"}}{{end}}
|
|
{{if eq .Type "credit"}}{{$icon = "💳"}}{{end}}
|
|
{{if eq .Type "securities"}}{{$icon = "📈"}}{{end}}
|
|
<span class="badge" style="background:var(--bg3); color:var(--text2); border:1px solid var(--border2);">
|
|
{{$icon}} {{.Type}}
|
|
</span>
|
|
</td>
|
|
<td class="text-right">
|
|
<button class="btn btn-danger btn-sm" onclick="delAccount('{{.ID}}')">{{$d.T.Get "accounts.btn_delete"}}</button>
|
|
</td>
|
|
</tr>
|
|
{{else}}
|
|
<tr>
|
|
<td colspan="3" class="text-center text-muted" style="padding:36px;">{{$d.T.Get "accounts.empty_msg"}}</td>
|
|
</tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const CONFIRM_DELETE = {{$d.T.Get "accounts.confirm_delete" | printf "%q"}};
|
|
function delAccount(id) {
|
|
if (!confirm(CONFIRM_DELETE)) return;
|
|
fetch('/accounts/' + id, {method: 'DELETE'}).then(r => {
|
|
if (r.ok) document.getElementById('acct-row-' + id).remove();
|
|
});
|
|
}
|
|
</script>
|
|
{{end}}
|