From d5bd57b3b989eae9d6586e2c60c47f2e692406a2 Mon Sep 17 00:00:00 2001
From: Charles Whittington
Date: Mon, 16 Jun 2025 21:47:01 -0400
Subject: [PATCH 1/3] Add link function, adjust sprint translation
---
databags/translate.ini | 31 ++++++-------------
.../lektor_beeware_plugin.py | 23 +++++++++++---
templates/event.html | 5 +--
3 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/databags/translate.ini b/databags/translate.ini
index 855d782389..8164969b07 100644
--- a/databags/translate.ini
+++ b/databags/translate.ini
@@ -79,8 +79,7 @@ past_events = Past events
upcoming_events = Upcoming events
running_sprint = BeeWare will be running a sprint at
what_is_a_sprint = What is a Sprint?
-sprint_description = Code sprints are events held normally after a conference where attendees can use the conference venue to work in small groups on various projects. Learn more about how sprints work with the
-sprint_pycon_video = PyCon US 'What is a sprint?' video
+sprint_description = Code sprints are events held normally after a conference where attendees can use the conference venue to work in small groups on various projects. Learn more about how sprints work with the {{ pycon_link("PyCon US 'What is a sprint?' video") }}.
challenge_coin = Challenge Coin
date = Date
speakers = Speakers
@@ -209,9 +208,8 @@ past_events = الأحداث السابقة
upcoming_events = الأحداث القادمة
running_sprint = BeeWare سيقوم بتشغيل سبرينت في
what_is_a_sprint = ما هو سبرينت؟
-sprint_description = كود سبرينت هي أحداث تعقد عادة بعد مؤتمر حيث يمكن للحاضرين استخدام مكان المؤتمر للعمل في مجموعات صغيرة في مشاريع مختلفة. اعرف المزيد عن كيفية عمل سبرينت مع
-sprint_pycon_video = PyCon US 'ما هو سبرينت?' فيديو
-challenge_coin = عملة التحدي
+sprint_description = كود سبرينت هي أحداث تعقد عادة بعد مؤتمر حيث يمكن للحاضرين استخدام مكان المؤتمر للعمل في مجموعات صغيرة في مشاريع مختلفة. اعرف المزيد عن كيفية عمل سبرينت مع {{ pycon_link("PyCon US 'ما هو سبرينت?' فيديو") }}
+challenge_coin =
date = تاريخ
speakers = المتحدثون
sprinters = سبرينترز
@@ -321,8 +319,7 @@ past_events = Eventos anteriores
upcoming_events = Próximos eventos
running_sprint = BeeWare fará um sprint em
what_is_a_sprint = O que é um Sprint?
-sprint_description = Sprints de código são eventos, realizados normalmente após conferências, onde os participantes podem usar o local da conferência para trabalhar em grupos pequenos em vários projetos. Saiba mais como funcionam os sprints com o
-sprint_pycon_video = vídeo da PyCon US 'What is a sprint?'
+sprint_description = Sprints de código são eventos, realizados normalmente após conferências, onde os participantes podem usar o local da conferência para trabalhar em grupos pequenos em vários projetos. Saiba mais como funcionam os sprints com o {{ pycon_link("vídeo da PyCon US 'What is a sprint?'" }}.
challenge_coin = Challenge Coin
date = Data
speakers = Palestrantes
@@ -433,8 +430,7 @@ past_events = Past events
upcoming_events = Upcoming events
running_sprint = BeeWare will be running a sprint at
what_is_a_sprint = What is a Sprint?
-sprint_description = Code sprints are events held normally after a conference where attendees can use the conference venue to work in small groups on various projects. Learn more about how sprints work with the
-sprint_pycon_video = PyCon US 'What is a sprint?' video
+sprint_description = Code sprints are events held normally after a conference where attendees can use the conference venue to work in small groups on various projects. Learn more about how sprints work with the {{ pycon_link("PyCon US 'What is a sprint?' video") }}.
challenge_coin = Challenge Coin
date = Date
speakers = Speakers
@@ -545,8 +541,7 @@ past_events = Eventos pasados
upcoming_events = Eventos futuros
running_sprint = BeeWare va a realizar un sprint en
what_is_a_sprint = ¿Qué es un sprint?
-sprint_description = Los sprints de código son eventos que se llevan a cabo normalmente después de una conferencia donde los asistentes pueden usar el lugar de la conferencia para trabajar en grupos pequeños en varios proyectos. Para obtener más información sobre cómo funcionan los sprints mira
-sprint_pycon_video = el video de PyCon USA 'What is a sprint?'
+sprint_description = Los sprints de código son eventos que se llevan a cabo normalmente después de una conferencia donde los asistentes pueden usar el lugar de la conferencia para trabajar en grupos pequeños en varios proyectos. Para obtener más información sobre cómo funcionan los sprints mira {{ pycon_link("el video de PyCon USA 'What is a sprint?'" }}.
challenge_coin = Moneda de desafío
date = Fecha
speakers = Conferencistas
@@ -657,8 +652,7 @@ past_events = Evénements passés
upcoming_events = Evénements à venir
running_sprint = BeeWare will be running a sprint at
what_is_a_sprint = What is a Sprint?
-sprint_description = Code sprints are events held normally after a conference where attendees can use the conference venue to work in small groups on various projects. Learn more about how sprints work with the
-sprint_pycon_video = PyCon US 'What is a sprint?' video
+sprint_description = Code sprints are events held normally after a conference where attendees can use the conference venue to work in small groups on various projects. Learn more about how sprints work with the {{ pycon_link("PyCon US 'What is a sprint?' video") }}.
challenge_coin = Challenge Coin
date = Date
speakers = Speakers
@@ -769,8 +763,7 @@ past_events = Eventi passati
upcoming_events = Prossimi eventi
running_sprint = BeeWare eseguirà uno sprint a
what_is_a_sprint = Cos'è uno sprint?
-sprint_description = Gli sprint in codice sono eventi che si tengono normalmente dopo una conferenza, dove i partecipanti possono utilizzare la sede della conferenza per lavorare in piccoli gruppi su vari progetti. Per saperne di più su come funzionano gli sprint con il
-sprint_pycon_video = Video PyCon US 'Cos'è uno sprint?
+sprint_description = Gli sprint in codice sono eventi che si tengono normalmente dopo una conferenza, dove i partecipanti possono utilizzare la sede della conferenza per lavorare in piccoli gruppi su vari progetti. Per saperne di più su come funzionano gli sprint con il {{ pycon_link("Video PyCon US 'Cos'è uno sprint?" }}.
challenge_coin = Challenge coin (moneta sfida)
data = Data
speakers = Relatori
@@ -881,8 +874,7 @@ past_events = Poprzednie wydarzenia
upcoming_events = Nadchodzące wydarzenia
running_sprint = BeeWare poprowadzi sprint na
what_is_a_sprint = Co to jest sprint?
-sprint_description = Sprint to wydarzenie odbywające się zwykle po konferencji, na którym uczestnicy mogą popracować w małych grupach nad różnymi projektami. Dowiedz się więcej z
-sprint_pycon_video = nagrania z PyCon US "Co to jest sprint?"
+sprint_description = Sprint to wydarzenie odbywające się zwykle po konferencji, na którym uczestnicy mogą popracować w małych grupach nad różnymi projektami. Dowiedz się więcej z {{ pycon_link('nagrania z PyCon US "Co to jest sprint?"') }}.
challenge_coin = odznakę
date = Data
speakers = Prowadzący
@@ -1001,10 +993,7 @@ past_events = 过去的活动
upcoming_events = 即将到来的活动
running_sprint = BeeWare 将会举行一场冲刺
what_is_a_sprint = 什么是冲刺
-sprint_description = 代码冲刺是通常在会议结束后举行的活动,与会者可以使用会议场地分组处理各种项目。用
-sprint_pycon_video = PyCon US 什么是冲刺视频
-; chinese-specific
-post_sprint_pycon_video = 了解更多关于冲刺是如何工作的。
+sprint_description = 代码冲刺是通常在会议结束后举行的活动,与会者可以使用会议场地分组处理各种项目。用{{ pycon_link("PyCon US 什么是冲刺视频") }}了解更多关于冲刺是如何工作的。
challenge_coin = 挑战币
date = 日期
speakers = 演讲者
diff --git a/packages/lektor_beeware_plugin/lektor_beeware_plugin.py b/packages/lektor_beeware_plugin/lektor_beeware_plugin.py
index 81d5d40dcb..65823855a0 100644
--- a/packages/lektor_beeware_plugin/lektor_beeware_plugin.py
+++ b/packages/lektor_beeware_plugin/lektor_beeware_plugin.py
@@ -4,7 +4,8 @@
from datetime import date
from lektor.pluginsystem import Plugin
-from jinja2 import pass_context
+from jinja2 import pass_context, Template
+from markupsafe import Markup
@pass_context
@@ -12,13 +13,24 @@ def translate(context, string, bag_name="translate"):
# Make sure that any macros which need to call this are imported with context.
alt = context["this"].alt
bag = context["bag"]
+ result = ""
if trans := bag(f"{bag_name}.{alt}.{string}"):
- return trans
+ result = trans
- if en := bag(f"{bag_name}.en.{string}"):
- return en
+ if not result and (en := bag(f"{bag_name}.en.{string}")):
+ result = en
- return ""
+ template = Template(result)
+
+ # Wrapping it in Markup() marks it as safe, so it won't be escaped.
+ return Markup(template.render(context))
+
+
+def link_to(address):
+ def link_maker(text):
+ return f'{text}'
+
+ return link_maker
class BeeWarePlugin(Plugin):
@@ -27,4 +39,5 @@ class BeeWarePlugin(Plugin):
def on_setup_env(self, **extra):
self.env.jinja_env.globals["today"] = date.today()
+ self.env.jinja_env.globals["link_to"] = link_to
self.env.jinja_env.filters["trans"] = translate
diff --git a/templates/event.html b/templates/event.html
index a65208bc0e..5ede659930 100644
--- a/templates/event.html
+++ b/templates/event.html
@@ -19,6 +19,8 @@
}
%}
+{# Note: for some reason this has to be defined outside of the block it's needed in. #}
+{% set pycon_link = link_to("https://www.youtube.com/watch?v=hOtKgFaFcz0") %}
{% set member_slugs = this.speaker %}
{% set members = site.query("/about/team") %}
{% set speaker_names = {} %}
@@ -54,8 +56,7 @@ {{ this.title }} ({{ this.event_type|title }})
{{ "event_more_info"|trans }} {{ this.title }} {{ "website"|trans }}.
{{ "what_is_a_sprint"|trans }}
- {%- set post = "post_sprint_pycon_video"|trans %}
- {{ "sprint_description"|trans }} {{ "sprint_pycon_video"|trans }}{% if post %} {% endif %}{{ post }}.
+ {{ "sprint_description"|trans }}
{% endif %}
{{ this.description }}
{% endblock %}
From b1191c383b04b5f4204ddced0c60f8ef4ac7c91c Mon Sep 17 00:00:00 2001
From: Charles Whittington
Date: Mon, 16 Jun 2025 22:05:53 -0400
Subject: [PATCH 2/3] Oops, deleted a nearby string
---
databags/translate.ini | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/databags/translate.ini b/databags/translate.ini
index 8164969b07..88b0946034 100644
--- a/databags/translate.ini
+++ b/databags/translate.ini
@@ -209,7 +209,7 @@ upcoming_events = الأحداث القادمة
running_sprint = BeeWare سيقوم بتشغيل سبرينت في
what_is_a_sprint = ما هو سبرينت؟
sprint_description = كود سبرينت هي أحداث تعقد عادة بعد مؤتمر حيث يمكن للحاضرين استخدام مكان المؤتمر للعمل في مجموعات صغيرة في مشاريع مختلفة. اعرف المزيد عن كيفية عمل سبرينت مع {{ pycon_link("PyCon US 'ما هو سبرينت?' فيديو") }}
-challenge_coin =
+challenge_coin = عملة التحدي
date = تاريخ
speakers = المتحدثون
sprinters = سبرينترز
From 7e6f52f16a55f4f3fbf7167a968d4e31639f9ed6 Mon Sep 17 00:00:00 2001
From: Charles Whittington
Date: Mon, 16 Jun 2025 22:34:53 -0400
Subject: [PATCH 3/3] Fix syntax errors
---
databags/translate.ini | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/databags/translate.ini b/databags/translate.ini
index 88b0946034..55d259b951 100644
--- a/databags/translate.ini
+++ b/databags/translate.ini
@@ -319,7 +319,7 @@ past_events = Eventos anteriores
upcoming_events = Próximos eventos
running_sprint = BeeWare fará um sprint em
what_is_a_sprint = O que é um Sprint?
-sprint_description = Sprints de código são eventos, realizados normalmente após conferências, onde os participantes podem usar o local da conferência para trabalhar em grupos pequenos em vários projetos. Saiba mais como funcionam os sprints com o {{ pycon_link("vídeo da PyCon US 'What is a sprint?'" }}.
+sprint_description = Sprints de código são eventos, realizados normalmente após conferências, onde os participantes podem usar o local da conferência para trabalhar em grupos pequenos em vários projetos. Saiba mais como funcionam os sprints com o {{ pycon_link("vídeo da PyCon US 'What is a sprint?'") }}.
challenge_coin = Challenge Coin
date = Data
speakers = Palestrantes
@@ -541,7 +541,7 @@ past_events = Eventos pasados
upcoming_events = Eventos futuros
running_sprint = BeeWare va a realizar un sprint en
what_is_a_sprint = ¿Qué es un sprint?
-sprint_description = Los sprints de código son eventos que se llevan a cabo normalmente después de una conferencia donde los asistentes pueden usar el lugar de la conferencia para trabajar en grupos pequeños en varios proyectos. Para obtener más información sobre cómo funcionan los sprints mira {{ pycon_link("el video de PyCon USA 'What is a sprint?'" }}.
+sprint_description = Los sprints de código son eventos que se llevan a cabo normalmente después de una conferencia donde los asistentes pueden usar el lugar de la conferencia para trabajar en grupos pequeños en varios proyectos. Para obtener más información sobre cómo funcionan los sprints mira {{ pycon_link("el video de PyCon USA 'What is a sprint?'") }}.
challenge_coin = Moneda de desafío
date = Fecha
speakers = Conferencistas
@@ -763,7 +763,7 @@ past_events = Eventi passati
upcoming_events = Prossimi eventi
running_sprint = BeeWare eseguirà uno sprint a
what_is_a_sprint = Cos'è uno sprint?
-sprint_description = Gli sprint in codice sono eventi che si tengono normalmente dopo una conferenza, dove i partecipanti possono utilizzare la sede della conferenza per lavorare in piccoli gruppi su vari progetti. Per saperne di più su come funzionano gli sprint con il {{ pycon_link("Video PyCon US 'Cos'è uno sprint?" }}.
+sprint_description = Gli sprint in codice sono eventi che si tengono normalmente dopo una conferenza, dove i partecipanti possono utilizzare la sede della conferenza per lavorare in piccoli gruppi su vari progetti. Per saperne di più su come funzionano gli sprint con il {{ pycon_link("Video PyCon US 'Cos'è uno sprint?") }}.
challenge_coin = Challenge coin (moneta sfida)
data = Data
speakers = Relatori