2023-02-04 10:32:39 +00:00
|
|
|
{{ define "title" -}}
|
|
|
|
{{( pgettext "Products" "title" )}}
|
|
|
|
{{- end }}
|
|
|
|
|
2023-03-20 12:09:52 +00:00
|
|
|
{{ define "breadcrumbs" -}}
|
|
|
|
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.productsIndexPage*/ -}}
|
2023-02-04 10:32:39 +00:00
|
|
|
<nav>
|
|
|
|
<p>
|
|
|
|
<a href="{{ companyURI "/" }}">{{( pgettext "Home" "title" )}}</a> /
|
|
|
|
<a>{{( pgettext "Products" "title" )}}</a>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<a class="primary button"
|
|
|
|
href="{{ companyURI "/products/new" }}">{{( pgettext "New product" "action" )}}</a>
|
|
|
|
</p>
|
|
|
|
</nav>
|
2023-03-20 12:09:52 +00:00
|
|
|
{{- end }}
|
2023-02-04 10:32:39 +00:00
|
|
|
|
2023-03-20 12:09:52 +00:00
|
|
|
{{ define "content" }}
|
2023-02-04 10:32:39 +00:00
|
|
|
{{- /*gotype: dev.tandem.ws/tandem/numerus/pkg.productsIndexPage*/ -}}
|
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>{{( pgettext "All" "product" )}}</th>
|
|
|
|
<th>{{( pgettext "Name" "title" )}}</th>
|
|
|
|
<th>{{( pgettext "Price" "title" )}}</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{{ with .Products }}
|
|
|
|
{{- range $product := . }}
|
|
|
|
<tr>
|
|
|
|
<td></td>
|
|
|
|
<td><a href="{{ companyURI "/products/"}}{{ .Slug }}">{{ .Name }}</a></td>
|
Add currency_pattern to language relation
The design calls for rendering all amounts with their currency symbol,
but golang.org/x/text’s currency package always render the symbol in
front, which is wrong in Catalan and Spanish, and a lot of other
languages.
Consulting the Internet, the most popular package for that is
accounting[0], which is almost as useless because they confuse locale
with the currency’s country of origin’s “usual locale” (e.g., en-US for
USD), which is also wrong: in Catalan i need to write USD prices as
"1.234,56 $" regardless of what Americans do.
With accounting i have the recourse of initializing the struct that
holds all the “locale” information, which is also wrong because i have
to define the decimal and thousands separators, something that depends
only on the locale, next to the currency’s precision, that is
locale-independent. But, since all CLDR data from golang.org/x/text
is inside an internal package, i can not access it and would need to
define all that information myself, which defeats the purpose of using
an external package.
Since for now i only need the format pattern for currency, i just saved
it into the database of available languages, that i do not expect to
grow too much.
[0]: https://github.com/leekchan/accounting
2023-02-23 11:12:33 +00:00
|
|
|
<td class="numeric">{{ .Price | formatPrice }}</td>
|
2023-02-04 10:32:39 +00:00
|
|
|
</tr>
|
|
|
|
{{- end }}
|
|
|
|
{{ else }}
|
|
|
|
<tr>
|
|
|
|
<td colspan="4">{{( gettext "No products added yet." )}}</td>
|
|
|
|
</tr>
|
|
|
|
{{ end }}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
{{- end }}
|