l10n: add en, de, ja and fr

This commit is contained in:
2025-08-09 02:28:03 +03:00
committed by Sweetbread
parent e6ba705862
commit 4622e730c1
15 changed files with 219 additions and 17 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'locale/{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")
+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 = Неплохой, недорогой. В прошлом были проблемы с сетью
Binary file not shown.
+16
View File
@@ -0,0 +1,16 @@
M+ FONTS Copyright (C) 2002-2013 M+ FONTS PROJECT
-
LICENSE_E
These fonts are free software.
Unlimited permission is granted to use, copy, and distribute them, with
or without modification, either commercially or noncommercially.
THESE FONTS ARE PROVIDED "AS IS" WITHOUT WARRANTY.
http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/
Binary file not shown.
+2 -1
View File
@@ -1,2 +1,3 @@
Monocraft: https://idreesinc.itch.io/monocraft
Pixeloid: https://ggbot.itch.io/pixeloid-font
Pixeloid: https://ggbot.itch.io/pixeloid-font
PixelM+: https://itouhiro.hatenablog.com/entry/20130602/font
+11 -1
View File
@@ -34,7 +34,7 @@ body {
display: flex;
flex-direction: column;
background-color: $base;
font-family: Pixeloid;
font-family: Pixeloid, PixelMPlus;
color: $text;
width: 100%;
height: 100%;
@@ -166,3 +166,13 @@ footer {
url("/static/font/Pixeloid/otf/Sans-Bold.otf") format("opentype");
font-weight: bold;
}
@font-face {
font-family: PixelMPlus;
src: url("/static/font/PixelMPlus/Regular.ttf");
}
@font-face {
font-family: PixelMPlus;
src: url("/static/font/PixelMPlus/Bold.ttf");
font-weight: bold;
}
+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 %}