6 Commits

Author SHA1 Message Date
Sweetbread 36734e5f90 l10n: change default section to "common" 2025-08-09 23:52:07 +03:00
Sweetbread d840b3cc7a fixup! l10n: add sections 2025-08-09 23:35:52 +03:00
Sweetbread 100b96aea3 l10n: add de, fr and ja 2025-08-09 23:24:03 +03:00
Sweetbread 7ece57fcea l10n: fix en 2025-08-09 22:52:24 +03:00
Sweetbread 0fa100b0b7 l10n: add sections 2025-08-09 22:48:38 +03:00
Sweetbread 2d86e95796 l10n: add en and ru translation 2025-08-09 02:28:03 +03:00
11 changed files with 191 additions and 15 deletions
+55 -1
View File
@@ -1,8 +1,62 @@
from os import system as console
from flask import Flask, render_template
from configparser import ConfigParser
from flask import (
Flask,
g,
request,
render_template,
)
translations_cache = {}
def load_translations(lang):
if lang not in translations_cache:
translations_cache[lang] = {}
try:
config = ConfigParser()
config.read(f'translations/{lang}.ini')
for section in config.sections():
translations_cache[lang][section] = dict(config.items(section))
except:
pass
return translations_cache[lang]
def get_locale():
return request.accept_languages.best_match(('en', 'ru', 'de', 'fr', 'ja'), 'en')
app = Flask(__name__)
@app.before_request
def before_request():
g.locale = get_locale()
g.translations = load_translations(g.locale)
@app.context_processor
def inject_translations():
def translate(text, **kwargs):
if ":" in text:
section, key = text.split(":", 1)
else:
section, key = "common", text
template = g.translations \
.get(section, {}) \
.get(key, f"${section}: {key}$")
try:
return template.format(**kwargs)
except:
return template
return {'_': translate}
if app.debug:
console("sass static/style/main.scss static/style/main.css")
+1
View File
@@ -1,2 +1,3 @@
Flask==3.1.1
Flask-Babel
gunicorn
+2 -2
View File
@@ -1,5 +1,5 @@
<footer>
<div>codrs.ru &#169; 2025</div>
<div><a href="https://g.codrs.ru/Sweetbread/codrs.ru">Исходники сайта</a></div>
<div>Для связи: <a href="mailto:admin@codrs.ru">admin@codrs.ru</a></div>
<div><a href="https://g.codrs.ru/Sweetbread/codrs.ru">{{ _('site source') }}</a></div>
<div>{{ _('contact us') }}: <a href="mailto:admin@codrs.ru">admin@codrs.ru</a></div>
</footer>
+2 -2
View File
@@ -1,8 +1,8 @@
<header>
<div class="header-links">
{%- for (l, t) in (
('us', 'О нас'),
('host', 'О хосте')
('us', _('about us')),
('host', _('about host'))
) %}
{%- if url_for(l) == request.path %}
<strong>{{ t }}</strong>
+4 -4
View File
@@ -1,15 +1,15 @@
{% extends 'base.tmpl' %}
{% block title %}О хосте{% endblock %}
{% block title %}{{ _('about host') }}{% endblock %}
{% block content %}
<a href="https://play2go.cloud/" target="_blank" class="block">
<strong>Хостер</strong>: play2go
<p>Неплохой, недорогой. В прошлом были проблемы с сетью</p>
<strong>{{ _("host:hoster") }}</strong>: play2go
<p>{{ _('host:hoster_descr') }}</p>
</a>
<div class="block">
<strong>Характеристики</strong>:
<strong>{{ _("host:specifications") }}</strong>:
<ul>
<li>CPU: Ryzen i9</li>
<li>RAM: 16 GiB</li>
+12 -6
View File
@@ -11,20 +11,20 @@
<img src="/static/icon/service/sharkey.webp" class="icon"/>
<strong>Sharkey</strong>
</div>
<p>Федеративная микроблогинговая система поверх протокола ActivityPub</p>
<p>{{ _('index.descr:sharkey') }}</p>
</a>
<a href="https://g.codrs.ru" target="_blank" class="block">
<div class="header">
<img src="/static/icon/service/gitea.webp" class="icon"/>
<strong>Gitea</strong>
</div>
<p>Selfhosted хранилище git-репозиториев со свободным исходным кодом</p>
<p>{{ _('index.descr:gitea') }}</p>
</a>
<div class="block">
<p><a href="https://m.codrs.ru" target="_blank"><strong>Matrix</strong></a> &mdash; федеративный мессанджер</p>
<p><a href="https://c.codrs.ru" target="_blank"><strong>Copyparty</strong></a> &mdash; облачное хранилище файлов</p>
<p><a href="https://s.codrs.ru" target="_blank"><strong>4get</strong></a> &mdash; прокси-поисковик</p>
<p><a href="https://m.codrs.ru" target="_blank"><strong>Matrix</strong></a> &mdash; {{ _('index.descr:matrix') }}</p>
<p><a href="https://c.codrs.ru" target="_blank"><strong>Copyparty</strong></a> &mdash; {{ _('index.descr:copyparty') }}</p>
<p><a href="https://s.codrs.ru" target="_blank"><strong>4get</strong></a> &mdash; {{ _('index.descr:4get') }}</p>
</div>
<div class="block">
@@ -43,6 +43,12 @@
</div>
<div class="block">
Ещё у нас есть <a href="https://bug.codrs.ru" target="_blank"><strong>GlitchTip</strong></a> и <a href="https://dav.codrs.ru" target="_blank"><strong>Baikal</strong></a> для участников нашей группы!
{{
_('index:bottom_text',
glitchtip='<a href="https://bug.codrs.ru" target="_blank"><strong>GlitchTip</strong></a>',
baikal='<a href="https://dav.codrs.ru" target="_blank"><strong>Baikal</strong></a>',
freshrss='<a href="https://rss.codrs.ru" target="_blank"><strong>FreshRSS</strong></a>',
) | safe
}}
</div>
{% endblock %}
+23
View File
@@ -0,0 +1,23 @@
[common]
site source = Website-Quellcode
contact us = Kontakt
about us = Über uns
about host = Über Server
[index]
bottom_text = Außerdem bieten wir {glitchtip}, {baikal} und {freshrss} für Mitglieder unserer Gruppe an!
[index.descr]
sharkey = Föderierter Microblogging-Dienst auf Basis des ActivityPub-Protokolls
gitea = Open-Source, selbst gehosteter Git-Repository-Hoster
matrix = Föderierter Messenger
copyparty = Cloud-Dateispeicher
4get = Proxy-Suchmaschine
[host]
hoster = Hosting-Anbieter
specifications = Spezifikationen
hoster_descr = Nicht schlecht, nicht teuer. In der Vergangenheit gab es Netzwerkprobleme.
+23
View File
@@ -0,0 +1,23 @@
[common]
site source = Site source
contact us = Contact us
about us = About us
about host = About host
[index]
bottom_text = We also have {glitchtip}, {baikal} and {freshrss} for members of our squad!
[index.descr]
sharkey = ActivityPub-based federated microblogging service
gitea = Opensource selfhosted Git repository hosting
matrix = federated instant messenger
copyparty = cloud file storage
4get = proxy search engine
[host]
hoster = Hosting Provider
specifications = Specifications
hoster_descr = Not bad, not expensive. There were network issues in the past
+23
View File
@@ -0,0 +1,23 @@
[common]
site source = Code source du site
contact us = Contacte-nous
about us = À propos de nous
about host = À propos de serveur
[index]
bottom_text = On a aussi {glitchtip}, {baikal} et {freshrss} pour les membres du groupe !
[index.descr]
sharkey = Service de microblogging fédéré avec ActivityPub
gitea = Hébergement de dépôts Git open source en auto-hébergé
matrix = Messagerie fédérée
copyparty = Stockage de fichiers en cloud
4get = Moteur de recherche proxy
[host]
hoster = Hébergeur
specifications = Spécifications
hoster_descr = Pas mal, pas cher. Y'a eu des soucis réseau avant.
+23
View File
@@ -0,0 +1,23 @@
[common]
site source = サイトのソースコード
contact us = 問い合わせ
about us = 私たちについて
about host = サーバーについて
[index]
bottom_text = メンバーには {glitchtip}、{baikal}、{freshrss} も使えるよ!
[index.descr]
sharkey = ActivityPubを使った連合型マイクロブログ
gitea = オープンソースのセルフホスティングGitリポジトリ
matrix = 連合型メッセンジャー
copyparty = クラウドファイルストレージ
4get = プロキシ検索エンジン
[host]
hoster = ホスティングプロバイダー
specifications = サーバーのスペック
hoster_descr = 悪くないし安い。前にネットワークの不具合があったんだ。
+23
View File
@@ -0,0 +1,23 @@
[common]
site source = Исходники сайта
contact us = Для связи
about us = О нас
about host = О хосте
[index]
bottom_text = Ещё у нас есть {glitchtip}, {baikal} и {freshrss} для участников нашей группы!
[index.descr]
sharkey = Федеративная микроблогинговая система поверх протокола ActivityPub
gitea = Selfhosted хранилище Git-репозиториев со свободным исходным кодом
matrix = федеративный мессенджер
copyparty = облачное хранилище файлов
4get = прокси-поисковик
[host]
hoster = Хостер
specifications = Характеристики
hoster_descr = Неплохой, недорогой. В прошлом были проблемы с сетью