Skip to content

Add translation filter#667

Merged
freakboy3742 merged 3 commits intolektorfrom
translation_filter
Jun 16, 2025
Merged

Add translation filter#667
freakboy3742 merged 3 commits intolektorfrom
translation_filter

Conversation

@HalfWhitt
Copy link
Copy Markdown
Member

@HalfWhitt HalfWhitt commented Jun 16, 2025

Updates translate.ini to finish up #663, and adds a translation filter to cut down on boilerplate.

For the most part, the only changes to the actual generated HTML are in the whitespace, but I also fixed a few small things like a missing period after the sprint video link, links to podcast episodes, and subject-verb agreement in the incomplete page notice.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@freakboy3742 freakboy3742 mentioned this pull request Jun 16, 2025
4 tasks
@freakboy3742 freakboy3742 added the preview Approved for an automated preview label Jun 16, 2025
@github-actions
Copy link
Copy Markdown
Contributor

Visit the preview URL for this PR (updated for commit f538fb4):

https://beeware-org--pr667-translation-filter-7777u20d.web.app

(expires Mon, 23 Jun 2025 06:50:50 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: b0da44bc067e7d9a4255c77cb2c5fce572218cec

Copy link
Copy Markdown
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

This is an amazing cleanup - and at gives us a non-trivial reason for keeping the beeware plugin around. Nice work!

Comment thread databags/translate.ini Outdated


@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!

@freakboy3742 freakboy3742 merged commit f969d5e into lektor Jun 16, 2025
@freakboy3742 freakboy3742 deleted the translation_filter branch June 16, 2025 07:18
Copy link
Copy Markdown
Contributor

@johnzhou721 johnzhou721 left a comment

Choose a reason for hiding this comment

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

Some notes mostly about Chinese.

Comment thread databags/translate.ini
home = 首页
edit_on_github = 在GitHub上编辑
edit_translation = 在 Weblate 上翻译
edit_translation = 在Weblate上翻译
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.

FYI this is to stay consistent with GitHub message but wouldn’t hurt if we added white spaces (and may look better but a little too long…)

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 imagine we'll all defer to your judgment on that, either way!

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.

I honestly have no idea… in regular text it’s probably better to have spaces but will it appear too loose on the top?

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.

No space is better when rendered.

Comment thread templates/event.html
<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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Approved for an automated preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants