feat: ship the interface in eight languages, with per-language plurals and mirroring

This commit is contained in:
randogoth 2026-10-11 14:54:43 +03:00
parent 6de6672ae3
commit a4a49f41d7
28 changed files with 1795 additions and 32 deletions

View file

@ -15,15 +15,18 @@ import 'pages/mews_urls.dart';
class InternalActions {
InternalActions({
required MewsDatabase db,
required Future<void> Function() applyLanguage,
required ReaderSettingsController settings,
required BookmarksController bookmarks,
required SubscriptionsController subscriptions,
}) : _db = db,
_applyLanguage = applyLanguage,
_settings = settings,
_bookmarks = bookmarks,
_subscriptions = subscriptions;
final MewsDatabase _db;
final Future<void> Function() _applyLanguage;
final ReaderSettingsController _settings;
final BookmarksController _bookmarks;
final SubscriptionsController _subscriptions;
@ -37,6 +40,7 @@ class InternalActions {
'set-size' => _setSize(args['step']),
'set-theme' => _settings.setThemeMode(args['value'] ?? ''),
'set-colors' => _settings.setVariant(args['value'] ?? ''),
'set-language' => _setLanguage(args['value']),
'mark-read' => _markRead(args, read: true),
'mark-unread' => _markRead(args, read: false),
'refresh-subscriptions' => _refreshAll(),
@ -52,6 +56,15 @@ class InternalActions {
};
}
/// Changing the language has to load its messages before the page is built
/// again, or the rerender would still read the old ones.
Future<bool> _setLanguage(String? tag) async {
if (tag == null || tag.isEmpty) return false;
if (!await _settings.setLanguage(tag)) return false;
await _applyLanguage();
return true;
}
Future<bool> _setSize(String? step) => switch (step) {
'up' => _settings.increaseSize(),
'down' => _settings.decreaseSize(),