Dawnline 0.11.0
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions

- Russian translation. The admin pages, the LuCI menu and the router's
  messages (errors, Health checks, update steps, the service log) come in
  Russian with the new luci-i18n-dawnline-ru package, released beside the
  app. LuCI shows it when its language is Russian, or "auto" with a Russian
  browser
- The translation installs with install.sh when LuCI is in Russian (or with
  --lang ru), follows every Dawnline update and rollback, and can be added
  or removed in Components → Dawnline → Translation
- The portal speaks the visitor's language: it opens in the system's
  language and switches between English and Russian in place, from the
  language pill beside its QR code. It carries its own translation and needs
  no package
- Set-up steps quote the apps' own menus word for word, in Russian too:
  AmneziaVPN is "+ → Insert → Continue" (it has no "Add server"), and the
  Mac and Windows menus of WireGuard and AmneziaWG have their real names
- Questions in the portal (Reconnect, Remove) read from the left edge and
  close with Cancel, without ×
- Numbers, sizes and dates follow the page's language. A server that can't
  start says why in one sentence; event details and service log lines read
  as whole sentences
- README in Russian (README_ru.md). rules/i18n.md: how strings are written
  and translated; CI checks the catalogs (npm run i18n:check)
This commit is contained in:
Aemeath committed 2026-10-20 19:33:52 +03:00
1 parent caed976e63
commit 2f2aaf6c34
173 files changed
+25645 -2823

No files matched your search

+204 -15
View File
@@ -3,6 +3,8 @@
import type { LogEvent } from '../../shared/types';
import type { LogCategory, LogsInfo, ServiceLogEntry } from '../api';
import { fmt, known, plural } from '../../shared/i18n';
import { LOG_TEMPLATES } from './log-templates';
/** Mirrors CATEGORY in dawnline.live. */
const CATEGORY: Record<string, LogCategory> = {
@@ -27,21 +29,24 @@ const CATEGORY: Record<string, LogCategory> = {
export const CATEGORIES: LogCategory[] = ['connections', 'people', 'problems'];
export const CATEGORY_LABEL: Record<LogCategory, string> = {
connections: 'Connections',
people: 'People',
problems: 'Problems',
};
export function categoryLabel(c: LogCategory): string {
return { connections: _('Connections'), people: _('People'), problems: _('Problems') }[c];
}
export const CATEGORY_HELP: Record<LogCategory, string> = {
connections: 'Connects, disconnects and IP changes',
people: 'People and their devices added, changed, paused, removed',
problems: 'Blocked portal sign-ins (tunnels and services are in the service log)',
};
export function categoryHelp(c: LogCategory): string {
return {
connections: _('Connects, disconnects and IP changes'),
people: _('People and their devices added, changed, paused, removed'),
problems: _('Blocked portal sign-ins (tunnels and services are in the service log)'),
}[c];
}
export const categoryOf = (type: string): LogCategory => CATEGORY[type] ?? 'problems';
export const SYSTEM_SOURCE: Record<ServiceLogEntry['src'], string> = { awg: 'AmneziaWG', dawnline: 'Dawnline', portal: 'Portal' };
/** What a service log source is called; unknown ones by their id. */
export function sourceName(src: ServiceLogEntry['src']): string {
return { awg: 'AmneziaWG', dawnline: 'Dawnline', portal: _('Portal') }[src] ?? src;
}
const ADMIN_TYPES = ['person_added', 'person_removed', 'person_changed'];
@@ -65,10 +70,194 @@ export const isProblem = (x: LogItem) =>
x.sys ? ['error', 'repair', 'down'].includes(x.sys.level) : categoryOf(x.ev!.type) === 'problems';
export function retentionText(p: LogsInfo['policy']): string {
const age = p.keep_days > 0 ? `${p.keep_days} day${p.keep_days === 1 ? '' : 's'}` : 'no age limit';
const age = p.keep_days > 0 ? plural(p.keep_days, '%s day', '%s days') : _('no age limit');
const where =
p.persist === 'off'
? 'kept in memory only (lost on reboot)'
: `saved to flash ${p.persist === '10min' ? 'every 10 minutes' : 'hourly'}`;
return `Kept for ${age}, up to ${p.max.toLocaleString('en-GB')} events, ${where}.`;
? _('kept in memory only (lost on reboot)')
: p.persist === '10min'
? _('saved to flash every 10 minutes')
: _('saved to flash hourly');
return fmt(_('Kept for %s, %s, %s.'), age, plural(p.max, 'up to %s event', 'up to %s events'), where);
}
/* ---------- the router's words, put into the page's language ----------
* Events and service log lines are written once, in English, by whoever was
* running (the agent has no language) and read later in any language: the
* words below are their fixed vocabulary, translated when shown. Anything
* else stays as written. */
/** Why someone was paused or resumed (the agent's REASON words). */
export function reasonText(detail: string): string {
const t: Record<string, string> = {
'paused by admin': _('paused by admin'),
'end date reached': _('end date reached'),
'data limit reached': _('data limit reached'),
'outside allowed hours': _('outside allowed hours'),
'no server': _('no server'),
'server turned off': _('server turned off'),
};
return t[detail] ?? detail;
}
/** Days left in an "expiring" event's detail ("3 days"), or null. */
export function daysOf(detail: string): number | null {
const m = /^(\d+) days?$/.exec(detail);
return m ? Number(m[1]) : null;
}
/** The person's settings a person_changed event lists (option names, "moved to <server>"). */
export function changedText(detail: string): string {
const f: Record<string, string> = {
name: _('name'),
access: _('access'),
device_limit: _('device limit'),
expires: _('end date'),
expire_action: _('what happens at the end'),
expire_warn: _('warning before the end'),
quota_gb: _('data limit'),
quota_period: _('data limit period'),
bonus_gb: _('extra data'),
hours: _('allowed hours'),
dns_mode: _('DNS'),
paused: _('pause'),
services: _('home services'),
circle: _('circle', 'setting'),
home_nets: _('home networks'),
server: _('server'),
};
return detail
.split(', ')
.map((k) => {
const to = /^moved to (.+)$/.exec(k)?.[1];
return to ? fmt(_('moved to %s'), to) : (f[k] ?? k.replace(/_/g, ' '));
})
.join(', ');
}
/**
* The admin's own change in the service log ({ msg: 'changed', kind:
* 'server', who: 'Home' }), as one sentence: with %s for the name it names,
* or whole when the name is a fixed phrase ("the service log"); null for one
* this page does not know.
*/
export function adminSentence(msg: string, kind?: string | null, who?: string | null): { text: string; named: boolean } | null {
const fixed: Record<string, string> = {
'cleared|the service log': _('You cleared the service log'),
'cleared|the activity log': _('You cleared the activity log'),
'exported|all settings': _('You exported all settings'),
'imported|settings from a file': _('You imported settings from a file'),
'restored|from a file': _('You restored a backup from a file'),
'turned on|the personal portal': _('You turned on the personal portal'),
'turned off|the personal portal': _('You turned off the personal portal'),
'changed|the personal portal': _('You changed the personal portal'),
'turned on|the watchdog': _('You turned on the watchdog'),
'turned off|the watchdog': _('You turned off the watchdog'),
'reset traffic history|for everyone': _('You reset traffic history for everyone'),
};
const whole = fixed[`${msg}|${who ?? ''}`];
if (whole) return { text: whole, named: false };
const named: Record<string, string> = {
'created|server': _('You created server %s'),
'changed|server': _('You changed server %s'),
'removed|server': _('You removed server %s'),
'turned on|server': _('You turned on server %s'),
'turned off|server': _('You turned off server %s'),
'added|circle': _('You added circle %s'),
'changed|circle': _('You changed circle %s'),
'removed|circle': _('You removed circle %s'),
'restored|backup': _('You restored backup %s'),
};
const t = named[`${msg}|${kind ?? ''}`];
if (t) return { text: t, named: true };
// "reset traffic history" "for Anna": the name after "for".
const forWho = msg === 'reset traffic history' && /^for (.+)$/.exec(who ?? '')?.[1];
return forWho ? { text: _('You reset traffic history for %s'), named: true } : null;
}
/** The name in a sentence adminSentence() made with %s (its "for …" taken off). */
export const adminName = (msg: string, who: string) => (msg === 'reset traffic history' ? who.replace(/^for /, '') : who);
/** The note after an admin's change: its known pieces translated, the rest as written. */
export function noteText(note: string): string {
const one = (p: string): string => {
const t: Record<string, string> = {
'other addresses': _('other addresses'),
certificate: _('certificate'),
redirect: _('redirect'),
'devices kept apart': _('devices kept apart'),
'devices reach each other': _('devices reach each other'),
'devices reach each other in circles': _('devices reach each other in circles'),
'home network and internet path': _('home network and internet path'),
'the file holds private keys': _('the file holds private keys'),
'problems are only logged, nothing is repaired': _('problems are only logged, nothing is repaired'),
name: _('name'),
'public address': _('public address'),
'AmneziaWG port': _('AmneziaWG port'),
'tunnel network': _('tunnel network'),
connections: categoryLabel('connections'),
people: categoryLabel('people'),
problems: categoryLabel('problems'),
};
if (t[p]) return t[p];
let m: RegExpExecArray | null;
if ((m = /^port (\d+)$/.exec(p))) return fmt(_('port %s'), m[1]);
if ((m = /^address (.+)$/.exec(p))) return fmt(_('address %s'), m[1]);
if ((m = /^disguise: (.+)$/.exec(p))) return fmt(_('disguise: %s'), m[1]);
if ((m = /^(\d+) events?$/.exec(p))) return plural(Number(m[1]), '%s event', '%s events');
if ((m = /^older than (\d+) days$/.exec(p))) return plural(Number(m[1]), 'older than %s day', 'older than %s days');
if ((m = /^with (\d+) (person|people)$/.exec(p))) return plural(Number(m[1]), 'with %s person', 'with %s people');
if ((m = /^(\d+) entr(y|ies)( older than (\d+) days)?$/.exec(p)))
return m[4]
? `${plural(Number(m[1]), '%s entry', '%s entries')}, ${plural(Number(m[4]), 'older than %s day', 'older than %s days')}`
: plural(Number(m[1]), '%s entry', '%s entries');
return p;
};
return note
.split(' · ')
.map((part) => part.split(', ').map(one).join(', '))
.join(' · ');
}
/* ---------- the service log's lines ----------
* The router writes them in English from its L_() templates (the generated
* list in ./log-templates); a line is put into the page's language by the
* template it matches, its values (versions, ports, names, or another
* template's words) put back in place. Lines written before the plain dash
* have "—" where the templates have "-". */
let patterns: { t: string; re: RegExp }[] | null = null;
const LOG_EXACT = new Set(LOG_TEMPLATES);
/** The templates with values in them, the most specific (most fixed text) first. */
function logPatterns() {
return (patterns ??= LOG_TEMPLATES.filter((t) => /%[sd]/.test(t) && t.replace(/%[sd]/g, '').trim())
.map((t) => ({
t,
fixed: t.replace(/%[sd]/g, '').length,
re: new RegExp(
`^${t
.split(/(%[sd])/)
.map((p) => (p === '%s' ? '(.+?)' : p === '%d' ? '(\\d+)' : p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')))
.join('')}$`,
),
}))
.sort((a, b) => b.fixed - a.fixed));
}
/** A service log line (or its subject, or a line of its details) in the page's language; one it does not know as written. */
export function logText(line: string, depth = 0): string {
const s = line.replace(/ — /g, ' - ');
if (LOG_EXACT.has(s)) return known(s);
if (depth > 2) return line;
for (const p of logPatterns()) {
const m = p.re.exec(s);
if (m) return fmt(known(p.t), ...m.slice(1).map((v) => logText(v, depth + 1)));
}
// A list ("Dawnline 0.3.3, 2 system packages"): each item on its own.
return s.includes(', ')
? s
.split(', ')
.map((x) => logText(x, depth + 1))
.join(', ')
: line;
}