refactor: use bag() instead of localize()

This commit is contained in:
relikd
2022-12-22 01:20:01 +01:00
parent a6926958aa
commit f7be319a9c
5 changed files with 28 additions and 20 deletions

View File

@@ -24,7 +24,7 @@
{%- elif this.group_key == 'time' -%}
{{ attrib | durationCluster(this.xdata, this.alt) }}
{%- elif this.group_key == 'difficulty' -%}
{{ localize(this.alt, 'difficulty', attrib) }}
{{ bag('i18n+' + this.alt, 'difficulty', attrib) }}
{%- else -%}
{{ attrib }}
{%- endif -%}</dt>

View File

@@ -15,10 +15,15 @@
<a id="logo" href="{{ site.get('/', this.alt)|url }}">recipe lekture</a>
<nav>
<ul>
{%- set allRecipes = site.get('recipes', this.alt) %}
<li><a {% if this == allRecipes %}class="active"{% endif %} href="{{ allRecipes|url }}">{{ localize(this.alt, 'title.all_recipes') }}</a></li>
{%- for navpage in site.query('/groupby', this.alt) %}
<li><a {% if this.is_child_of(navpage) %}class="active"{% endif %} href="{{ navpage|url }}">{{ navpage.name }}</a></li>
{%- set allRecipes = site.get('/recipes', this.alt) %}
<li><a {% if this == allRecipes -%}
class="active"
{%- endif %} href="{{ allRecipes|url }}">{{ bag('i18n+' + this.alt, 'title.all_recipes') }}</a></li>
{%- for groupby in site.query('/groupby', this.alt) %}
<li><a {% if this.url_path.startswith(groupby.url_path) -%}
class="active"
{%- endif %} href="{{ groupby|url }}">{{ groupby.name }}</a></li>
{%- endfor %}
</ul>
</nav>
@@ -38,7 +43,9 @@
<table width="100%">{#--#}
<td>Build with <a href="https://www.getlektor.com/">Lektor</a>, template by <a href="https://github.com/relikd/lektor-recipes">relikd</a>.</td>{#--#}
<td class="buttons xlarge">
<a href="/static/pdf-{{ this.alt }}.pdf" download="recipes-{{ this.alt }}.pdf" title="{{ localize(this.alt, 'other', 'get_pdf') }}"><img class="h1em" alt="(PDF)" height="20" src="{{ '/img/icon-pdf.svg'|url }}"></a>
<a href="/static/pdf-{{ this.alt }}.pdf" download="recipes-{{ this.alt }}.pdf" title="{{ bag('i18n+' + this.alt, 'other.get_pdf') }}">{#--#}
<img class="h1em" alt="(PDF)" height="20" src="{{ '/img/icon-pdf.svg'|url }}">{#--#}
</a>
{%- set url_without_alt = ('.'|url(absolute=True))[4:] -%}
{%- if this.alt == 'de' -%}
<a href="/en/{{url_without_alt}}" title="zur englischen Seite wechseln">🇺🇸</a>

View File

@@ -24,18 +24,15 @@
<div id="rating" class="xlarge">{{ this.rating|rating }}</div>
<div class="difficulty {{this.difficulty}}">
<div></div><div></div><div></div>
{%- if this.difficulty %}
<span>{{ localize(this.alt, 'difficulty', this.difficulty) }}</span>
{%- else %}
<span class="small">{{ localize(this.alt, 'difficulty._unset') }}</span>
{%- endif %}
<span {% if not this.difficulty %}class="small"{%- endif %}>{{
bag('i18n+' + this.alt, 'difficulty', this.difficulty or '_unset') }}</span>
</div>
<div>{{ localize(this.alt, 'duration.label') }}: {{ this.time|duration(this.alt) if this.time else '—' }}</div>
<div>{{ localize(this.alt, 'yield.label') }}: {{ this.yield or '—' }}</div>
<div>{{ bag('i18n+' + this.alt, 'duration.label') }}: {{ this.time|duration(this.alt) if this.time else '—' }}</div>
<div>{{ bag('i18n+' + this.alt, 'yield.label') }}: {{ this.yield or '—' }}</div>
</section>
<section id="ingredients">
<h2>{{ localize(this.alt, 'title.ingredients') }}:</h2>
<h2>{{ bag('i18n+' + this.alt, 'title.ingredients') }}:</h2>
<ul class="no-bullets li-lg-space">
{%- for ing in this|enumIngredients(this.alt) %}
{%- if ing['group'] %}
@@ -46,7 +43,7 @@
{%- if ing['measure'] %}{{ ing['measure'] }} {% endif -%}
<span class="light-red">{{ ing['name'] }}</span>
{%- if ing['note'] -%}
<span class="small italic">{{ ', ' ~ ing['note'] | replaceAtRefURLs(label=localize(this.alt, 'ingredients.recipeLink')) }}</span>
<span class="small italic">{{ ', ' ~ ing['note'] | replaceAtRefURLs(label=bag('i18n+' + this.alt, 'ingredients.recipeLink')) }}</span>
{%- endif -%}
</li>
{%- endif %}
@@ -55,8 +52,8 @@
</section>
<section id="directions">
<h2>{{ localize(this.alt, 'title.directions') }}:</h2>
{% if site.get('settings', alt=this.alt)['replace_temp'] -%}
<h2>{{ bag('i18n+' + this.alt, 'title.directions') }}:</h2>
{% if site.get('/settings', alt=this.alt)['replace_temp'] -%}
{{ this.directions.html|replace('°C', '℃')|replace('°F', '℉') }}
{% else -%}
{{ this.directions }}

View File

@@ -1,9 +1,13 @@
{% extends "layout.html" %}
{% from "macros/recipes.html" import render_recipe_list %}
{% from "macros/pagination.html" import render_pagination_all %}
{% block title %}{{ localize(this.alt, 'title.recipes') }}{% endblock %}
{% block title %}{{ bag('i18n+' + this.alt, 'title.recipes') }}{% endblock %}
{% block body %}
<h1>{{ localize(this.alt, 'title.recipes') }} <a href="/static/pdf-{{ this.alt }}.pdf" download="recipes-{{ this.alt }}.pdf" title="{{ localize(this.alt, 'other', 'get_pdf') }}"><img class="h1em" alt="(PDF)" height="20pt" src="{{ '/img/icon-pdf.svg'|url }}"></a></h1>
<h1>{{
bag('i18n+' + this.alt, 'title.recipes')
}} <a href="/static/pdf-{{ this.alt }}.pdf" download="recipes-{{ this.alt }}.pdf" title="{{
bag('i18n+' + this.alt, 'other.get_pdf')
}}"><img class="h1em" alt="(PDF)" height="20pt" src="{{ '/img/icon-pdf.svg'|url }}"></a></h1>
{{ render_recipe_list(this.pagination.items) }}
{{ render_pagination_all(this.pagination) }}
{% endblock %}

View File

@@ -1,7 +1,7 @@
{% extends "layout.html" %}
{% from "macros/recipes.html" import render_recipe_list %}
{% block body %}
<h1>{{ localize(this.alt, 'title.latest') }}</h1>
<h1>{{ bag('i18n+' + this.alt, 'title.latest') }}</h1>
<div class="latest">
{{ render_recipe_list(site.query('recipes', this.alt).order_by('-date', 'name'), limit=6) }}
</div>