Serve localized Google Play badges locally

Fixes #196

Badges downloaded from <https://play.google.com/intl/en_us/badges/> with
a bit of automation to get one per supported language.
This commit is contained in:
Kim Alvefur
2025-04-12 13:48:56 +02:00
parent 3f1ce7565b
commit 466e3e79b7
14 changed files with 30 additions and 20 deletions

View File

@@ -47,10 +47,20 @@ def apple_store_badge() -> str:
return url_for("static", filename="img/apple/en.svg") return url_for("static", filename="img/apple/en.svg")
def play_store_badge() -> str:
locale = selected_locale()
filename = "{}_badge_web_generic.png".format(locale)
static_path = pathlib.Path(__file__).parent / "static" / "img" / "google"
if (static_path / filename).exists():
return url_for("static", filename="img/google/{}".format(filename))
return url_for("static", filename="img/google/en_badge_web_generic.png")
@bp.context_processor @bp.context_processor
def context() -> typing.Dict[str, typing.Any]: def context() -> typing.Dict[str, typing.Any]:
return { return {
"apple_store_badge": apple_store_badge, "apple_store_badge": apple_store_badge,
"play_store_badge": play_store_badge,
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@@ -32,7 +32,7 @@
{%- endif -%} {%- endif -%}
<div class="install-buttons"> <div class="install-buttons">
<ul> <ul>
<li><a href="{{ play_store_url }}"><img alt='{% trans %}Get it on Google Play{% endtrans %}' src='https://play.google.com/intl/en_us/badges/static/images/badges/en_badge_web_generic.png' class="play"/></a></li> <li><a href="{{ play_store_url }}"><img alt='{% trans %}Get it on Google Play{% endtrans %}' src='{{ play_store_badge() }}' class="play"/></a></li>
{%- if apple_store_url -%} {%- if apple_store_url -%}
<li><a href="{{ apple_store_url }}" class="popover" data-popover-id="apple-popover"><img alt='{% trans %}Download on the App Store{% endtrans %}' src="{{ apple_store_badge() }}" class="apple"></a></li> <li><a href="{{ apple_store_url }}" class="popover" data-popover-id="apple-popover"><img alt='{% trans %}Download on the App Store{% endtrans %}' src="{{ apple_store_badge() }}" class="apple"></a></li>
{%- endif -%} {%- endif -%}

View File

@@ -1,21 +1,21 @@
# Translations template for PROJECT. # Translations template for PROJECT.
# Copyright (C) 2024 ORGANIZATION # Copyright (C) 2025 ORGANIZATION
# This file is distributed under the same license as the PROJECT project. # This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2024. # FIRST AUTHOR <EMAIL@ADDRESS>, 2025.
# #
#, fuzzy #, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PROJECT VERSION\n" "Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-08-11 16:36+0200\n" "POT-Creation-Date: 2025-04-12 20:21+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n" "Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.16.0\n" "Generated-By: Babel 2.17.0\n"
#: snikket_web/admin.py:69 snikket_web/templates/admin_delete_user.html:10 #: snikket_web/admin.py:69 snikket_web/templates/admin_delete_user.html:10
#: snikket_web/templates/admin_edit_circle.html:73 #: snikket_web/templates/admin_edit_circle.html:73
@@ -270,7 +270,7 @@ msgstr ""
msgid "Yesterday" msgid "Yesterday"
msgstr "" msgstr ""
#: snikket_web/infra.py:105 #: snikket_web/infra.py:104
#, python-format #, python-format
msgid "%(time)s ago" msgid "%(time)s ago"
msgstr "" msgstr ""
@@ -281,59 +281,59 @@ msgid ""
"contact your Snikket operator." "contact your Snikket operator."
msgstr "" msgstr ""
#: snikket_web/invite.py:114 #: snikket_web/invite.py:124
msgid "Username" msgid "Username"
msgstr "" msgstr ""
#: snikket_web/invite.py:118 snikket_web/invite.py:190 snikket_web/main.py:43 #: snikket_web/invite.py:128 snikket_web/invite.py:200 snikket_web/main.py:43
msgid "Password" msgid "Password"
msgstr "" msgstr ""
#: snikket_web/invite.py:126 snikket_web/invite.py:198 #: snikket_web/invite.py:136 snikket_web/invite.py:208
msgid "Confirm password" msgid "Confirm password"
msgstr "" msgstr ""
#: snikket_web/invite.py:130 snikket_web/invite.py:202 #: snikket_web/invite.py:140 snikket_web/invite.py:212
msgid "The passwords must match." msgid "The passwords must match."
msgstr "" msgstr ""
#: snikket_web/invite.py:135 #: snikket_web/invite.py:145
msgid "Create account" msgid "Create account"
msgstr "" msgstr ""
#: snikket_web/invite.py:162 #: snikket_web/invite.py:172
msgid "That username is already taken." msgid "That username is already taken."
msgstr "" msgstr ""
#: snikket_web/invite.py:166 snikket_web/invite.py:235 #: snikket_web/invite.py:176 snikket_web/invite.py:245
msgid "Registration was declined for unknown reasons." msgid "Registration was declined for unknown reasons."
msgstr "" msgstr ""
#: snikket_web/invite.py:170 #: snikket_web/invite.py:180
msgid "The username is not valid." msgid "The username is not valid."
msgstr "" msgstr ""
#: snikket_web/invite.py:207 snikket_web/templates/user_home.html:37 #: snikket_web/invite.py:217 snikket_web/templates/user_home.html:37
#: snikket_web/templates/user_passwd.html:29 #: snikket_web/templates/user_passwd.html:29
msgid "Change password" msgid "Change password"
msgstr "" msgstr ""
#: snikket_web/invite.py:254 #: snikket_web/invite.py:264
msgid "Account data file" msgid "Account data file"
msgstr "" msgstr ""
#: snikket_web/invite.py:258 #: snikket_web/invite.py:268
msgid "Import data" msgid "Import data"
msgstr "" msgstr ""
#: snikket_web/invite.py:279 #: snikket_web/invite.py:289
#, python-format #, python-format
msgid "" msgid ""
"The account data you tried to import is in an unknown format. Please " "The account data you tried to import is in an unknown format. Please "
"upload an XML file in XEP-0227 format (provided format: %(mimetype)s)." "upload an XML file in XEP-0227 format (provided format: %(mimetype)s)."
msgstr "" msgstr ""
#: snikket_web/invite.py:299 snikket_web/templates/unauth.html:18 #: snikket_web/invite.py:309 snikket_web/templates/unauth.html:18
#: snikket_web/user.py:192 #: snikket_web/user.py:192
msgid "Error" msgid "Error"
msgstr "" msgstr ""
@@ -414,7 +414,7 @@ msgstr ""
msgid "Password changed" msgid "Password changed"
msgstr "" msgstr ""
#: snikket_web/user.py:137 #: snikket_web/user.py:138
msgid "" msgid ""
"The chosen avatar is too big. To be able to upload larger avatars, please" "The chosen avatar is too big. To be able to upload larger avatars, please"
" use the app." " use the app."