diff --git a/databags/translate.ini b/databags/translate.ini index 3fcabeeef1..855d782389 100644 --- a/databags/translate.ini +++ b/databags/translate.ini @@ -12,7 +12,7 @@ previous = Previous next = Next ; Incomplete -incomplete_text = This page's contents is incomplete. You can help by +incomplete_text = This page's contents are incomplete. You can help by incomplete_link = expanding it incomplete_after_link_text = . incomplete_space_before_link = true @@ -132,10 +132,7 @@ polish = Polski ; Breadcrumbs home = الرئيسية edit_on_github = عدِّل على GitHub -create_on_github = ترجم على GitHub -translation_out_of_date = ترجمة هذا المحتوى تحتاج إلى تحديث -see_original_content = تحقق مما تم تحديثُه في المحتوى الأصلى -update_translation = قم بتحديث الترجمة على Github +edit_translation = الترجمة على Weblate ; Footer sitemap = خريطة الموقع @@ -247,10 +244,7 @@ missing_translations = الصفحات التالية تفتقد إلى التر ; Breadcrumbs home = Início edit_on_github = Editar no GitHub -create_on_github = Traduzir no GitHub -translation_out_of_date = Esta tradução está desatualizada! -see_original_content = Veja o que mudou na versão original -update_translation = Atualizar tradução no Github +edit_translation = Traduzir no Weblate ; Footer sitemap = Mapa do site @@ -362,10 +356,7 @@ missing_translations = As páginas a seguir não possuem tradução ; Breadcrumbs home = 主頁 edit_on_github = 在 GitHub 上編輯 -create_on_github = 在 GitHub 上翻譯 -translation_out_of_date = 這個頁面的翻譯可能已經過時! -see_original_content = 看看原來的內容有什麼變化 -update_translation = 在 Github 上更新翻譯 +edit_translation = 在 Weblate 上翻譯 ; Footer sitemap = 網站地圖 @@ -477,10 +468,7 @@ missing_translations = The following pages are missing a translation ; Breadcrumbs home = Inicio edit_on_github = Editar en GitHub -create_on_github = Traducir en GitHub -translation_out_of_date = El contenido y/o traducción de esta página puede estar desactualizado! -see_original_content = Ver que ha cambiado -update_translation = Actualizar el contenido en Github +edit_translation = Traducir en Weblate ; Footer sitemap = Mapa del Sitio @@ -592,10 +580,7 @@ outdated_translations = Las siguientes páginas pueden contener traducciones des ; Breadcrumbs home = Accueil edit_on_github = Editer sur GitHub -create_on_github = Traduire sur GitHub -translation_out_of_date = Cette traduction du contenu original est obsolète! -see_original_content = Voir les modifications du contenu original -update_translation = Mettre à jour la traduction sur Github +edit_translation = Traduire sur Weblate ; Footer sitemap = Plan du site @@ -707,10 +692,7 @@ missing_translations = Les pages suivantes n'ont pas de traduction ; Breadcrumbs home = Home edit_on_github = Modifica su GitHub -create_on_github = Tradurre su GitHub -translation_out_of_date = Questa traduzione del contenuto originale non è aggiornata! -see_original_content = Vedi cosa è cambiato nel contenuto originale -update_translation = Aggiorna la traduzione su Github +edit_translation = Traduci su Weblate ; Footer sitemap = Mappa del sito @@ -822,10 +804,7 @@ missing_translations = Alle seguenti pagine manca una traduzione ; Breadcrumbs home = Strona główna edit_on_github = Edytuj na GitHubie -create_on_github = Tłumacz na GitHubie -translation_out_of_date = To tłumaczenie jest nieaktualne! -see_original_content = Zobacz co zmieniło się na oryginalnej stronie -update_translation = Zaktualizuj tłumaczenie na Githubie +edit_translation = Tłumacz na Weblate ; Footer sitemap = Mapa strony @@ -937,10 +916,7 @@ missing_translations = Na tych stronach brakuje tłumaczenia ; Breadcrumbs home = 首页 edit_on_github = 在GitHub上编辑 -create_on_github = 在GitHub上翻译 -translation_out_of_date = 这份原始内容的翻译已经过时了! -see_original_content = 查看原始内容的变化 -update_translation = 在Github上更新翻译 +edit_translation = 在Weblate上翻译 ; Footer sitemap = 站点地图 diff --git a/packages/lektor_beeware_plugin/lektor_beeware_plugin.py b/packages/lektor_beeware_plugin/lektor_beeware_plugin.py index eb21b00875..81d5d40dcb 100644 --- a/packages/lektor_beeware_plugin/lektor_beeware_plugin.py +++ b/packages/lektor_beeware_plugin/lektor_beeware_plugin.py @@ -1,14 +1,30 @@ # -*- coding: utf-8 -*- -"""This is a custom local plugin to add extra functionality to BeeWare site.""" +"""This is a custom local plugin to add extra functionality to the BeeWare site.""" from datetime import date from lektor.pluginsystem import Plugin +from jinja2 import pass_context + + +@pass_context +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"] + if trans := bag(f"{bag_name}.{alt}.{string}"): + return trans + + if en := bag(f"{bag_name}.en.{string}"): + return en + + return "" class BeeWarePlugin(Plugin): - name = 'BeeWare Custom Lektor Plugin' - description = 'This is a custom local plugin to add extra functionality.' + name = "BeeWare Custom Lektor Plugin" + description = "This is a custom local plugin to add extra functionality." def on_setup_env(self, **extra): - self.env.jinja_env.globals['today'] = date.today() + self.env.jinja_env.globals["today"] = date.today() + self.env.jinja_env.filters["trans"] = translate diff --git a/packages/lektor_beeware_plugin/pyproject.toml b/packages/lektor_beeware_plugin/pyproject.toml index 1ba263af6e..bbf8ef3314 100644 --- a/packages/lektor_beeware_plugin/pyproject.toml +++ b/packages/lektor_beeware_plugin/pyproject.toml @@ -13,7 +13,7 @@ description = "" license = "MIT" requires-python = ">= 3.9" authors = [ - {name="Gonzalo Peña-Castellanos", email="goanpeca@gmail.com"}, + {name="Charles Whittington", email="charleswhitt@gmail.com"}, ] maintainers = [ {name="BeeWare Team", email="team@beeware.org"}, diff --git a/templates/404.html b/templates/404.html index 86ebccdbb5..885c129214 100644 --- a/templates/404.html +++ b/templates/404.html @@ -1,6 +1,6 @@ {% extends "layout.html" %} -{% from "macros/breadcrumbs.html" import breadcrumbs %} -{% from "macros/incomplete.html" import incomplete %} +{% from "macros/breadcrumbs.html" import breadcrumbs with context %} +{% from "macros/incomplete.html" import incomplete with context %} {% block title %}Page not found{% endblock %} {% block preamble %} diff --git a/templates/blog-post.html b/templates/blog-post.html index bbcecca3dc..208246fd03 100644 --- a/templates/blog-post.html +++ b/templates/blog-post.html @@ -1,12 +1,6 @@ {% extends "layout.html" %} -{% from "macros/blog.html" import render_blog_post %} -{% from "macros/breadcrumbs.html" import breadcrumbs %} -{% from "macros/translation.html" import transbag %} - -{% set t_on = transbag('translate', this.alt, 'on') %} -{% set t_posted_by = transbag('translate', this.alt, 'posted_by') %} -{% set t_next_entry = transbag('translate', this.alt, 'next_entry') %} -{% set t_previous_entry = transbag('translate', this.alt, 'previous_entry') %} +{% from "macros/blog.html" import render_blog_post with context %} +{% from "macros/breadcrumbs.html" import breadcrumbs with context %} {% block title %}{{ this.title }}{% endblock %} {% block preamble %} @@ -14,7 +8,7 @@
{{ breadcrumbs(this) }}
{{ t_posted_by }} +
{{ "posted_by"|trans }} {% if this.mastodon_handle %} {{ this.author or this.mastodon_handle }} {% elif this.twitter_handle %} @@ -22,7 +16,7 @@
{{ t_speakers_list }} {{ event_type_verbs[this.event_type]["before"] }} {{ this.title }} {{ event_type_verbs[this.event_type]["after"] }} "{{ this.talk_title }}".
+{{ speakers_list }} {{ event_type_verbs[this.event_type]["before"] }} {{ this.title }} {{ event_type_verbs[this.event_type]["after"] }} "{{ this.talk_title }}".
{% elif this.event_type == "sprint" %} -{{ t_running_sprint }} {{ this.title }}.
+{{ "running_sprint"|trans }} {{ this.title }}.
- {{ t_speakers_list }} {% if this.speaker|length > 1 %}{{ t_sprint_helping_plural }}{% else %}{{ t_sprint_helping }}{% endif %} {{ t_challenge_coin }}. + {{ speakers_list }} {% if this.speaker|length > 1 %}{{ "sprint_helping_plural"|trans }}{% else %}{{ "sprint_helping"|trans }}{% endif %} {{ "challenge_coin"|trans }}.
-{{ t_event_more_info }} {{ this.title }} {{ t_website }}.
-{{ t_sprint_description }} {{ t_sprint_video }} {{ t_post_sprint_pycon_video }}
+{{ "event_more_info"|trans }} {{ this.title }} {{ "website"|trans }}.
+{{ "sprint_description"|trans }} {{ "sprint_pycon_video"|trans }}{% if post %} {% endif %}{{ post }}.
{% endif %}{{ this.description }}
{% endblock %} @@ -79,13 +63,13 @@diff --git a/templates/home.html b/templates/home.html index 15301d565b..eff0091864 100644 --- a/templates/home.html +++ b/templates/home.html @@ -1,19 +1,4 @@ {% extends "layout.html" %} -{% from "macros/translation.html" import transbag %} - -{% set t_projects = transbag('translate', this.alt, 'projects') %} -{% set t_latest_news = transbag('translate', this.alt, 'latest_news') %} -{% set t_previous = transbag('translate', this.alt, 'previous') %} -{% set t_next = transbag('translate', this.alt, 'next') %} -{% set t_meet_team = transbag('translate', this.alt, 'meet_team') %} -{% set t_keynoting = transbag('translate', this.alt, 'keynoting') %} -{% set t_speaking = transbag('translate', this.alt, 'speaking') %} -{% set t_tutorial = transbag('translate', this.alt, 'tutorial') %} -{% set t_come_see_us = transbag('translate', this.alt, 'come_see_us') %} -{% set t_sprinting = transbag('translate', this.alt, 'sprinting') %} -{% set t_member = transbag('translate', this.alt, 'member')|trim %} - -{% set t_gold_member = transbag('labels', this.alt, 'gold') %} {% block title %}{{ this.title }}{% endblock %} {% block preamble %} diff --git a/templates/home_sidebar.html b/templates/home_sidebar.html index 4dcdf0172b..6eb8d44cc9 100644 --- a/templates/home_sidebar.html +++ b/templates/home_sidebar.html @@ -1,19 +1,19 @@ {{ this.gutter_top }} -
{{ blog.pub_date.strftime("%d %b")}}: {{ blog.title }}
- {{ t_by }}{% if t_space_after_by != 'false' %} {% endif %}{{ article.author }}; - {{ t_published }} {{ article.pub_date.strftime('%-d %B %Y') }} + {{ "by"|trans }}{% if "space_after_by"|trans != 'false' %} {% endif %}{{ article.author }}; + {{ "published"|trans }} {{ article.pub_date.strftime('%-d %B %Y') }}
{{ article.description }}
-- {{ t_text }}{% if space_before_link == 'true' %} {% endif %}{{ t_link }}{% if space_after_link == 'true' %} {% endif %}{{ t_after }} + {{ "incomplete_text"|trans }}{% if "incomplete_space_before_link"|trans == "true" %} {% endif %} + + {{ "incomplete_link"|trans }} + {% if "incomplete_space_after_link"|trans == "true" %} {% endif %}{{ "incomplete_after_link_text"|trans }}
{% endif %} {% endmacro %} diff --git a/templates/macros/join_and.html b/templates/macros/join_and.html index 1f28e582f1..3a67474c91 100644 --- a/templates/macros/join_and.html +++ b/templates/macros/join_and.html @@ -1,4 +1,4 @@ -{% macro join_and(items, join_word="and") %}{% +{% macro join_and(items, join_word="and") %}{% set join_word = join_word|trans %}{% if items|length == 1 %}{{ items[0] diff --git a/templates/macros/member-badge.html b/templates/macros/member-badge.html index b771f74f5c..3000a3e30c 100644 --- a/templates/macros/member-badge.html +++ b/templates/macros/member-badge.html @@ -1,8 +1,4 @@ -{% from "macros/translation.html" import transbag %} - {% macro member_badge(member) %} - {% set t_superpower = transbag('translate', member.alt, 'superpower')|trim %} -
{{ member.github_handle }}
{% if member.mastodon_handle %}
@@ -18,9 +14,10 @@
{% if member.superpower %}
- {{ t_by }}{% if t_space_after_by != 'false' %} {% endif %}{{ episode.author }}; - {{ t_published }} {{ episode.pub_date.strftime('%-d %B %Y') }} + {{ "by"|trans }}{% if "space_after_by"|trans != 'false' %} {% endif %}{{ episode.author }}; + {{ "published"|trans }} {{ episode.pub_date.strftime('%-d %B %Y') }}
{{ episode.description }}
-- {{ t_by }}{% if t_space_after_by != 'false' %} {% endif %}{{ video.author }}; - {{ t_published }} {{ video.pub_date.strftime('%-d %B %Y') }} + {{ "by"|trans }}{% if "space_after_by"|trans != 'false' %} {% endif %}{{ video.author }}; + {{ "published"|trans }} {{ video.pub_date.strftime('%-d %B %Y') }}
{{ video.description }}
{% if video.event_url %} -{{ t_as_seen_at }} {{ video.event_name }}
+{{ "as_seen_at"|trans }} {{ video.event_name }}
{% else %} -{{ t_as_seen_at }} {{ video.event_name }}
+{{ "as_seen_at"|trans }} {{ video.event_name }}
{% endif %} {% endmacro %} diff --git a/templates/member.html b/templates/member.html index a2dc1d7585..5a0bdc043e 100644 --- a/templates/member.html +++ b/templates/member.html @@ -1,10 +1,6 @@ {% extends "layout.html" %} -{% from "macros/breadcrumbs.html" import breadcrumbs %} -{% from "macros/membership.html" import membership_level %} -{% from "macros/translation.html" import transbag %} - -{% set t_thanks_before_name = transbag('translate', this.alt, 'thanks_before_name') %} -{% set t_thanks_after_name = transbag('translate', this.alt, 'thanks_after_name') %} +{% from "macros/breadcrumbs.html" import breadcrumbs with context %} +{% from "macros/membership.html" import membership_level with context %} {% block title %}{{ this.name or '' }}{% endblock %} {% block preamble %} @@ -25,5 +21,5 @@{{ t_thanks_before_name }} {{ this.name or '' }} {{ t_thanks_after_name }}
+{{ "thanks_before_name"|trans }} {{ this.name or '' }} {{ "thanks_after_name"|trans }}
{% endblock %} diff --git a/templates/members.html b/templates/members.html index fa6f7ed358..17b90d073e 100644 --- a/templates/members.html +++ b/templates/members.html @@ -1,5 +1,5 @@ {% extends "layout.html" %} -{% from "macros/breadcrumbs.html" import breadcrumbs %} +{% from "macros/breadcrumbs.html" import breadcrumbs with context %} {% block title %}{{ this.title }}{% endblock %} {% block preamble %}{{ t_as_seen_at }} {{ this.event_name }}
+{{ "as_seen_at"|trans }} {{ this.event_name }}
{% else %} -{{ t_as_seen_at }} {{ this.event_name }}
+{{ "as_seen_at"|trans }} {{ this.event_name }}
{% endif %}