Make all labels translatable

This commit is contained in:
Maël Brunet 2021-06-06 10:27:24 +02:00
parent e71b7b6e89
commit 6921c5d93d
6 changed files with 17 additions and 7 deletions

View file

@ -4,5 +4,7 @@
"author": "John Doe", "author": "John Doe",
"primaryColor": "#ffdb70", "primaryColor": "#ffdb70",
"secondaryColor": "#32816e", "secondaryColor": "#32816e",
"searchLabel": "Find recipes by name or ingredients" "searchLabel": "Find recipes by name or ingredients",
"servingsLabel": "servings",
"ingredientsLabel": "Ingredients"
} }

View file

@ -1,9 +1,9 @@
<nav> <nav>
<ul class="c-tags"> <ul class="c-tags">
{% if page.fileSlug == "recipes" %} {% if page.fileSlug == "recipes" %}
<li class="c-tags__tag c-tag__tag--selected">All recipes</li> <li class="c-tags__tag c-tag__tag--selected">{{ title }}{{ allRecipesLabel }}</li>
{% else %} {% else %}
<li><a class="c-tags__tag" href="/recipes">All recipes</a></li> <li><a class="c-tags__tag" href="/recipes">{{ title }}{{ allRecipesLabel }}</a></li>
{% endif %} {% endif %}
{% for tagItem in collections.tagList %} {% for tagItem in collections.tagList %}
{% if selectedTag == tagItem %} {% if selectedTag == tagItem %}

View file

@ -30,13 +30,13 @@
+ +
<span class="u-sr-only">Add 1 serving</span> <span class="u-sr-only">Add 1 serving</span>
</button> </button>
<span> servings</span> <span>{{ site.servingsLabel }}</span>
</p> </p>
{% endif %} {% endif %}
</div> </div>
{% endif %} {% endif %}
<h3>Ingredients</h3> <h3>{{ site.ingredientsLabel }}</h3>
<template x-if="currentServings"> <template x-if="currentServings">
<ul class="c-recipe__ingredients-list"> <ul class="c-recipe__ingredients-list">
<template x-for="(ingredient, index) in ingredients" :key="index"> <template x-for="(ingredient, index) in ingredients" :key="index">

View file

@ -4,7 +4,7 @@
<main> <main>
<section> <section>
<div class="l-container"> <div class="l-container">
<h1>{{ selectedTag }}{{ " " if selectedTag }}{{title}}</h1> <h1>{{ selectedTag }}{{ title }}</h1>
{% if not selectedTag %} {% if not selectedTag %}
{% include 'components/taglist.njk' %} {% include 'components/taglist.njk' %}

View file

@ -41,7 +41,9 @@ collections:
- {label: "Author", name: "author", widget: "string"} - {label: "Author", name: "author", widget: "string"}
- {label: "Primary color", name: "primaryColor", widget: "color", hint: "make sure to choose a color that is light enough to display as a background behind dark text"} - {label: "Primary color", name: "primaryColor", widget: "color", hint: "make sure to choose a color that is light enough to display as a background behind dark text"}
- {label: "Secondary color", name: "secondaryColor", widget: "color", hint: "used for links and focus styles"} - {label: "Secondary color", name: "secondaryColor", widget: "color", hint: "used for links and focus styles"}
- {label: "Search label", name: "searchLabel", widget: "string"} - {label: "Search (label)", name: "searchLabel", widget: "string"}
- {label: "Servings (label)", name: "servingsLabel", widget: "string"}
- {label: "Ingredients (label)", name: "ingredientsLabel", widget: "string"}
- name: "nav" - name: "nav"
label: "Navigation" label: "Navigation"
delete: false delete: false
@ -70,6 +72,11 @@ collections:
file: "src/recipes.md" file: "src/recipes.md"
fields: fields:
- {label: "Title", name: "title", widget: "string"} - {label: "Title", name: "title", widget: "string"}
- name: "tags"
label: "Tags pages"
file: "src/tag.md"
fields:
- {label: "All recipes (label)", name: "allRecipesLabel", widget: "string"}
- name: "about" - name: "about"
label: "About page" label: "About page"
file: "src/about.md" file: "src/about.md"

View file

@ -5,6 +5,7 @@ pagination:
alias: selectedTag alias: selectedTag
permalink: /tags/{{ selectedTag | noEmoji | slug }}/ permalink: /tags/{{ selectedTag | noEmoji | slug }}/
layout: layouts/recipes-list.njk layout: layouts/recipes-list.njk
allRecipesLabel: All recipes
eleventyComputed: eleventyComputed:
metaTitle: "{{ selectedTag | noEmoji }}" metaTitle: "{{ selectedTag | noEmoji }}"
--- ---