mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 04:36:48 +00:00
The Turkish catalog had not been extracted since 2024: of the panel's 1727 messages, 817 were missing and 489 carried old fuzzy guesses, so most pages, dialogs and messages showed in English, and some fuzzy guesses said something else. The catalog is extracted again (obsolete entries dropped) and every message is translated, the earlier terms kept (Sanal Makine, Sunucu, Depolama havuzu, Birim, Anlık görüntü), placeholders and markup checked against the English. The Settings page's names and descriptions come from the database through migrations that did not mark them for translation; they are marked now (gettext_noop, the stored values unchanged), so they are in the catalog too.
38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
from django.core.management.color import no_style
|
|
from django.db import migrations
|
|
from django.utils.translation import gettext_noop as _
|
|
|
|
|
|
SETTINGS = [
|
|
(_("Login Failure Limit"), "LOGIN_FAILURE_LIMIT", "5",
|
|
_("Failed logins of a user from one address before it is locked")),
|
|
(_("Login Lockout Minutes"), "LOGIN_LOCKOUT_MINUTES", "15",
|
|
_("How long a locked login stays locked, in minutes")),
|
|
]
|
|
|
|
|
|
def add_settings(apps, schema_editor):
|
|
setting = apps.get_model("appsettings", "AppSettings")
|
|
db_alias = schema_editor.connection.alias
|
|
# Earlier migrations inserted the default rows with fixed ids, which a
|
|
# PostgreSQL id sequence does not see: move it past them before inserting
|
|
# without an id (a no-op on sqlite).
|
|
with schema_editor.connection.cursor() as cursor:
|
|
for sql in schema_editor.connection.ops.sequence_reset_sql(no_style(), [setting]):
|
|
cursor.execute(sql)
|
|
for name, key, value, description in SETTINGS:
|
|
setting.objects.using(db_alias).get_or_create(
|
|
key=key, defaults={"name": name, "value": value, "choices": "", "description": description}
|
|
)
|
|
|
|
|
|
def del_settings(apps, schema_editor):
|
|
setting = apps.get_model("appsettings", "AppSettings")
|
|
db_alias = schema_editor.connection.alias
|
|
setting.objects.using(db_alias).filter(key__in=[key for _, key, _, _ in SETTINGS]).delete()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [("appsettings", "0013_remove_qemu_console_default_type")]
|
|
|
|
operations = [migrations.RunPython(add_settings, del_settings)]
|