Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 9 additions & 33 deletions databags/translate.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = خريطة الموقع
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = 網站地圖
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 上翻译
Comment thread
freakboy3742 marked this conversation as resolved.
Outdated

; Footer
sitemap = 站点地图
Expand Down
24 changes: 20 additions & 4 deletions packages/lektor_beeware_plugin/lektor_beeware_plugin.py
Original file line number Diff line number Diff line change
@@ -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"):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup!

# 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
2 changes: 1 addition & 1 deletion packages/lektor_beeware_plugin/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
4 changes: 2 additions & 2 deletions templates/404.html
Original file line number Diff line number Diff line change
@@ -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 %}
Expand Down
18 changes: 6 additions & 12 deletions templates/blog-post.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
{% 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 %}
<div class="banner">
<div class="container">
<p>{{ breadcrumbs(this) }}</p>
<h1>{{ this.title }}</h1>
<p>{{ t_posted_by }}
<p>{{ "posted_by"|trans }}
{% if this.mastodon_handle %}
<a href="https://{{ this.mastodon_handle.split('@')[2] }}/@{{ this.mastodon_handle.split('@')[1] }}">{{ this.author or this.mastodon_handle }}</a>
{% elif this.twitter_handle %}
<a href="https://twitter.com/{{ this.twitter_handle }}">{{ this.author or this.twitter_handle }}</a>
{% else %}
{{ this.author }}
{% endif %}
{{ t_on }} {{ this.pub_date.strftime('%Y/%m/%d')}}
{{ "on"|trans }} {{ this.pub_date.strftime('%Y/%m/%d')}}
</p>
</div>
</div>
Expand All @@ -37,12 +31,12 @@ <h1>{{ this.title }}</h1>
<div class="col-sm-12 col-md-4 gutter">
<dl>
{% if this.has_prev() %}
<dt>{{ t_next_entry }}</dt>
<dt>{{ "next_entry"|trans }}</dt>
<dd><a href="{{ this.get_siblings().prev_page|url(alt=this.alt) }}">{{ this.get_siblings().prev_page.title }}</a></dd>
{% endif %}

{% if this.has_next() %}
<dt>{{ t_previous_entry }}</dt>
<dt>{{ "previous_entry"|trans }}</dt>
<dd><a href="{{ this.get_siblings().next_page|url(alt=this.alt) }}">{{ this.get_siblings().next_page.title }}</a></dd>
{% endif %}
</dl>
Expand Down
6 changes: 3 additions & 3 deletions templates/blog.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "page.html" %}
{% from "macros/blog.html" import render_blog_post %}
{% from "macros/pagination.html" import render_pagination %}
{% from "macros/breadcrumbs.html" import breadcrumbs %}
{% from "macros/blog.html" import render_blog_post with context %}
{% from "macros/pagination.html" import render_pagination with context %}
{% from "macros/breadcrumbs.html" import breadcrumbs with context %}

{% block title %}{{ this.title }}{% endblock %}
{% block extra_head %}
Expand Down
2 changes: 1 addition & 1 deletion templates/community.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "page.html" %}
{% from "macros/breadcrumbs.html" import breadcrumbs %}
{% from "macros/breadcrumbs.html" import breadcrumbs with context %}
{% block title %}{{ this.title }}{% endblock %}
{% block gutter %}

Expand Down
54 changes: 19 additions & 35 deletions templates/event.html
Original file line number Diff line number Diff line change
@@ -1,37 +1,20 @@
{% extends "page.html" %}
{% from "macros/breadcrumbs.html" import breadcrumbs %}
{% from "macros/translation.html" import transbag %}
{% from "macros/join_and.html" import join_and %}

{% set t_running_sprint = transbag('translate', this.alt, 'running_sprint') %}
{% set t_what_is_a_sprint = transbag('translate', this.alt, 'what_is_a_sprint') %}
{% set t_challenge_coin = transbag('translate', this.alt, 'challenge_coin') %}
{% set t_sprint_description = transbag('translate', this.alt, 'sprint_description') %}
{% set t_sprint_video = transbag('translate', this.alt, 'sprint_pycon_video') %}
{% set t_post_sprint_pycon_video = transbag('translate', this.alt, 'post_sprint_pycon_video') %}
{% set t_date = transbag('translate', this.alt, 'date') %}
{% set t_speakers = transbag('translate', this.alt, 'speakers') %}
{% set t_sprinters = transbag('translate', this.alt, 'sprinters') %}
{% set t_and = transbag('translate', this.alt, 'and') %}
{% set t_event_more_info = transbag('translate', this.alt, 'event_more_info') %}
{% set t_website = transbag('translate', this.alt, 'website') %}

{% set t_sprint_helping = transbag('translate', this.alt, 'sprint_helping') %}
{% set t_sprint_helping_plural = transbag('translate', this.alt, 'sprint_helping_plural') %}
{% from "macros/breadcrumbs.html" import breadcrumbs with context %}
{% from "macros/join_and.html" import join_and with context %}

{%
set event_type_verbs = {
"talk": {
"before": transbag('translate', this.alt, 'speaking_before_title'),
"after": transbag('translate', this.alt, 'speaking_after_title'),
"before": "speaking_before_title"|trans,
"after": "speaking_after_title"|trans,
},
"keynote": {
"before": transbag('translate', this.alt, 'keynoting_before_title'),
"after": transbag('translate', this.alt, 'keynoting_after_title'),
"before": "keynoting_before_title"|trans,
"after": "keynoting_after_title"|trans,
},
"tutorial": {
"before": transbag('translate', this.alt, 'tutorial_before_title'),
"after": transbag('translate', this.alt, 'tutorial_after_title'),
"before": "tutorial_before_title"|trans,
"after": "tutorial_after_title"|trans,
},
}
%}
Expand All @@ -47,7 +30,7 @@
)
%}
{% endfor %}
{% set t_speakers_list = join_and(speaker_names.values()|list, t_and) %}
{% set speakers_list = join_and(speaker_names.values()|list) %}

{% block title %}{{ this.title }}{% endblock %}

Expand All @@ -63,29 +46,30 @@ <h1>{{ this.title }} ({{ this.event_type|title }})</h1>

{% block main %}
{% if this.event_type in event_type_verbs %}
<p>{{ t_speakers_list }} {{ event_type_verbs[this.event_type]["before"] }} {{ this.title }} {{ event_type_verbs[this.event_type]["after"] }} "<a href="{{ this.url }}">{{ this.talk_title }}</a>".</p>
<p>{{ speakers_list }} {{ event_type_verbs[this.event_type]["before"] }} {{ this.title }} {{ event_type_verbs[this.event_type]["after"] }} "<a href="{{ this.url }}">{{ this.talk_title }}</a>".</p>
{% elif this.event_type == "sprint" %}
<p>{{ t_running_sprint }} {{ this.title }}.</p>
<p>{{ "running_sprint"|trans }} {{ this.title }}.</p>
<p>
{{ t_speakers_list }} {% if this.speaker|length > 1 %}{{ t_sprint_helping_plural }}{% else %}{{ t_sprint_helping }}{% endif %} <a href="{{ '/contributing/challenge-coins/'|url(alt=this.alt) }}">{{ t_challenge_coin }}</a>.
{{ speakers_list }} {% if this.speaker|length > 1 %}{{ "sprint_helping_plural"|trans }}{% else %}{{ "sprint_helping"|trans }}{% endif %} <a href="{{ '/contributing/challenge-coins/'|url(alt=this.alt) }}">{{ "challenge_coin"|trans }}</a>.
</p>
<p>{{ t_event_more_info }} <a href="{{ this.url }}">{{ this.title }} {{ t_website }}</a>.</p>
<h3>{{ t_what_is_a_sprint }}</h3>
<p>{{ t_sprint_description }} <a href="https://www.youtube.com/watch?v=hOtKgFaFcz0">{{ t_sprint_video }}</a> {{ t_post_sprint_pycon_video }} </p>
<p>{{ "event_more_info"|trans }} <a href="{{ this.url }}">{{ this.title }} {{ "website"|trans }}</a>.</p>
<h3>{{ "what_is_a_sprint"|trans }}</h3>
{%- set post = "post_sprint_pycon_video"|trans %}
<p>{{ "sprint_description"|trans }} <a href="https://www.youtube.com/watch?v=hOtKgFaFcz0">{{ "sprint_pycon_video"|trans }}</a>{% if post %} {% endif %}{{ post }}.</p>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chinese etc probably needs a full width period — might be worth adding a punctuation filter in plugin.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't thought about that. If we ever add Japanese, I know it has its own period, and some languages don't use them at all. We should probably move the period into the translated string (here and elsewhere).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really, it would be ideal if the template could define any necessary links, and the translations could freely place them as needed within one larger string... 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weblate can't see changes made via PR to translation .lr files, can it? It would be really useful for batch updates...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HalfWhitt yes it can with some delay it’d be safe to lock it for a few hours to eliminate conflicts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I read it wrong, thought you meant translation .po files, .lr files Weblate probably doesn't even support

{% endif %}
<p><em>{{ this.description }}</em></p>
{% endblock %}

{% block gutter %}
<div class="col-sm-12 col-md-4 gutter">
<dl>
<dt>{{ t_date }}:</dt>
<dt>{{ "date"|trans }}:</dt>
<dd>{{ this.date|datetimeformat("MMMM d, YYYY", locale=this.alt)|title }}{% if this.end_date %} - {{this.end_date|datetimeformat("MMMM d, YYYY", locale=this.alt)|title}}{% endif %}</dd>

{% if this.event_type == "sprint" %}
<dt>{{ t_sprinters }}:</dt>
<dt>{{ "sprinters"|trans }}:</dt>
{% elif this.event_type == "talk" %}
<dt>{{ t_speakers }}:</dt>
<dt>{{ "speakers"|trans }}:</dt>
{% endif %}
<dd>
<ul>
Expand Down
10 changes: 3 additions & 7 deletions templates/events.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{% extends "page.html" %}
{% from "macros/breadcrumbs.html" import breadcrumbs %}
{% from "macros/translation.html" import transbag %}

{% set t_past_events = transbag('translate', this.alt, 'past_events') %}
{% set t_upcoming_events = transbag('translate', this.alt, 'upcoming_events') %}
{% from "macros/breadcrumbs.html" import breadcrumbs with context %}

{% block title %}{{ this.title }}{% endblock %}

Expand Down Expand Up @@ -38,10 +34,10 @@ <h1>{{ this.title }}</h1>
and use Javascript (which will be evaluated at the time of viewing) to
move upcoming events into the upcoming list. #}

<h2>{{ t_upcoming_events }}</h2>
<h2>{{ "upcoming_events"|trans }}</h2>
<div id="upcoming-events"></div>

<h2>{{ t_past_events }}</h2>
<h2>{{ "past_events"|trans }}</h2>
<div id="past-events">
{% for child in this.children %}
<p data-date="{{ child.date }}" data-end-date="{{ child.end_date or child.date }}">
Expand Down
15 changes: 0 additions & 15 deletions templates/home.html
Original file line number Diff line number Diff line change
@@ -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 %}
Expand Down
8 changes: 4 additions & 4 deletions templates/home_sidebar.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{{ this.gutter_top }}

<h3>{{ t_gold_member }} {{ t_member|capitalize }}</h3>
<h3>{{ "gold"|trans("labels") }} {{ "member"|trans|capitalize }}</h3>
{% for member in gold_members %}
<p><a href="{{ '/community/members'|url(alt=this.alt) }}"><img class="img-fluid" src="/community/members/anaconda/anaconda-small.png"></a></p>
{% endfor %}

<hr/>

<h3><a href="{{ '/news/buzz/'|url(alt=this.alt) }}">{{ t_latest_news }}</a></h3>
<h3><a href="{{ '/news/buzz/'|url(alt=this.alt) }}">{{ "latest_news"|trans }}</a></h3>
<p><a href="{{ blog|url(alt=this.alt) }}">{{ blog.pub_date.strftime("%d %b")}}: {{ blog.title }}</a></p>

<hr/>

{% if events %}
<h3>{{ t_meet_team }}</h3>
<h3>{{ "meet_team"|trans }}</h3>

{% for event in events %}
<div class="upcoming event" data-date="{{ event.date }}" data-end-date="{{ event.end_date or event.date }}">
Expand All @@ -30,7 +30,7 @@ <h5><a href="{{ event|url(alt=this.alt) }}">{{ event.title }}</a></h5>

<hr/>
{% endif %}
<h2><a href="{{ '/project'|url(alt=this.alt) }}">{{ t_projects }}</a></h2>
<h2><a href="{{ '/project'|url(alt=this.alt) }}">{{ "projects"|trans }}</a></h2>
{% for project in project_types %}
{% if not project.project_page_description %}
<div>
Expand Down
Loading