summaryrefslogtreecommitdiffhomepage
path: root/templates/language.templ
blob: ba8db78e4eafa8a5898240449c34ce4451d6b8e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package templates

import (
	"strings"

	"git.thomasvoss.com/euro-cash.eu/i18n"
)

templ Language() {
	{{ p := ctx.Value("printer").(i18n.Printer) }}
	<header>
		@navbar()
		<h1>{ p.T("Select Your Language") }</h1>
	</header>
	<main>
		<p>
			{ p.T("Select your preferred language to use on the site.") }
		</p>
		<p>
			If you are an American user, it’s suggested that you select
			American English instead of British English. This will ensure that
			dates will be formatted with the month before the day. 
		</p>
		<hr/>
		<h2>{ p.T("Eurozone Languages") }</h2>
		@languageGrid(true)
		<h2>{ p.T("Other Languages") }</h2>
		@languageGrid(false)
	</main>
}

templ languageGrid(eurozone bool) {
	<form action="/language" method="POST">
		<div class="lang-grid">
			for _, loc := range i18n.Locales {
				if loc.Eurozone == eurozone {
					<button
						type="submit"
						name="locale"
						value={ loc.Code }
						disabled?={ !loc.Enabled }
					>
						<span
							lang={ loc.Code }
							data-code={ strings.ToUpper(loc.Language()) }
						>
							{ loc.Name }
						</span>
					</button>
				}
			}
		</div>
	</form>
}