feat: ship the interface in eight languages, with per-language plurals and mirroring
This commit is contained in:
parent
6de6672ae3
commit
a4a49f41d7
28 changed files with 1795 additions and 32 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:signals/signals.dart';
|
||||
|
||||
import '../../database/database.dart';
|
||||
import '../../l10n/locales.dart';
|
||||
import '../fonts.dart';
|
||||
|
||||
/// The reader's presentation choices (spec 8.2) plus the per-app limits they
|
||||
|
|
@ -25,6 +26,10 @@ class ReaderSettingsController {
|
|||
final themeMode = signal('system');
|
||||
final variant = signal('site');
|
||||
|
||||
/// The interface language: a shipped locale tag, or [systemLanguage] to take
|
||||
/// whatever the device asks for.
|
||||
final language = signal(systemLanguage);
|
||||
|
||||
Future<void> load() async {
|
||||
final settings = await _db.readSettings();
|
||||
if (settings == null) return;
|
||||
|
|
@ -32,6 +37,7 @@ class ReaderSettingsController {
|
|||
fontScale.value = settings.fontScale;
|
||||
themeMode.value = settings.themeMode;
|
||||
variant.value = settings.variant;
|
||||
language.value = settings.language;
|
||||
}
|
||||
|
||||
Future<bool> setFont(String family) async {
|
||||
|
|
@ -71,10 +77,19 @@ class ReaderSettingsController {
|
|||
return true;
|
||||
}
|
||||
|
||||
Future<bool> setLanguage(String tag) async {
|
||||
if (tag != systemLanguage && matchLocale(tag) == null) return false;
|
||||
if (tag == language.value) return false;
|
||||
language.value = tag;
|
||||
await _persist();
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<void> _persist() => _db.saveSettings(
|
||||
font: font.value,
|
||||
fontScale: fontScale.value,
|
||||
themeMode: themeMode.value,
|
||||
variant: variant.value,
|
||||
language: language.value,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue