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

View File

@@ -15,10 +15,15 @@
<a id="logo" href="{{ site.get('/', this.alt)|url }}">recipe lekture</a> <a id="logo" href="{{ site.get('/', this.alt)|url }}">recipe lekture</a>
<nav> <nav>
<ul> <ul>
{%- set allRecipes = site.get('recipes', this.alt) %} {%- 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> <li><a {% if this == allRecipes -%}
{%- for navpage in site.query('/groupby', this.alt) %} class="active"
<li><a {% if this.is_child_of(navpage) %}class="active"{% endif %} href="{{ navpage|url }}">{{ navpage.name }}</a></li> {%- 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 %} {%- endfor %}
</ul> </ul>
</nav> </nav>
@@ -38,7 +43,9 @@
<table width="100%">{#--#} <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>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"> <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:] -%} {%- set url_without_alt = ('.'|url(absolute=True))[4:] -%}
{%- if this.alt == 'de' -%} {%- if this.alt == 'de' -%}
<a href="/en/{{url_without_alt}}" title="zur englischen Seite wechseln">🇺🇸</a> <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 id="rating" class="xlarge">{{ this.rating|rating }}</div>
<div class="difficulty {{this.difficulty}}"> <div class="difficulty {{this.difficulty}}">
<div></div><div></div><div></div> <div></div><div></div><div></div>
{%- if this.difficulty %} <span {% if not this.difficulty %}class="small"{%- endif %}>{{
<span>{{ localize(this.alt, 'difficulty', this.difficulty) }}</span> bag('i18n+' + this.alt, 'difficulty', this.difficulty or '_unset') }}</span>
{%- else %}
<span class="small">{{ localize(this.alt, 'difficulty._unset') }}</span>
{%- endif %}
</div> </div>
<div>{{ localize(this.alt, 'duration.label') }}: {{ this.time|duration(this.alt) if this.time else '—' }}</div> <div>{{ bag('i18n+' + 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, 'yield.label') }}: {{ this.yield or '—' }}</div>
</section> </section>
<section id="ingredients"> <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"> <ul class="no-bullets li-lg-space">
{%- for ing in this|enumIngredients(this.alt) %} {%- for ing in this|enumIngredients(this.alt) %}
{%- if ing['group'] %} {%- if ing['group'] %}
@@ -46,7 +43,7 @@
{%- if ing['measure'] %}{{ ing['measure'] }} {% endif -%} {%- if ing['measure'] %}{{ ing['measure'] }} {% endif -%}
<span class="light-red">{{ ing['name'] }}</span> <span class="light-red">{{ ing['name'] }}</span>
{%- if ing['note'] -%} {%- 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 -%} {%- endif -%}
</li> </li>
{%- endif %} {%- endif %}
@@ -55,8 +52,8 @@
</section> </section>
<section id="directions"> <section id="directions">
<h2>{{ localize(this.alt, 'title.directions') }}:</h2> <h2>{{ bag('i18n+' + this.alt, 'title.directions') }}:</h2>
{% if site.get('settings', alt=this.alt)['replace_temp'] -%} {% if site.get('/settings', alt=this.alt)['replace_temp'] -%}
{{ this.directions.html|replace('°C', '℃')|replace('°F', '℉') }} {{ this.directions.html|replace('°C', '℃')|replace('°F', '℉') }}
{% else -%} {% else -%}
{{ this.directions }} {{ this.directions }}

View File

@@ -1,9 +1,13 @@
{% extends "layout.html" %} {% extends "layout.html" %}
{% from "macros/recipes.html" import render_recipe_list %} {% from "macros/recipes.html" import render_recipe_list %}
{% from "macros/pagination.html" import render_pagination_all %} {% 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 %} {% 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_recipe_list(this.pagination.items) }}
{{ render_pagination_all(this.pagination) }} {{ render_pagination_all(this.pagination) }}
{% endblock %} {% endblock %}

View File

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