feat: build v1 Mews client: reader UI, gestures, Drift store, fetch actor
This commit is contained in:
parent
d5a0fcbf48
commit
01a36e8aee
56 changed files with 7287 additions and 2 deletions
39
app/lib/l10n/strings.dart
Normal file
39
app/lib/l10n/strings.dart
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import 'package:fluent/fluent.dart';
|
||||
import 'package:flutter/services.dart' show rootBundle;
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
/// Loads and formats the app's Fluent messages. All user-facing strings come
|
||||
/// from locales/en-US/main.ftl; lookups fall back to the message ID when a
|
||||
/// message is missing so that missing translations are obvious in the UI.
|
||||
class Strings {
|
||||
final FluentBundle _bundle = FluentBundle('en-US');
|
||||
|
||||
/// Loads the messages from the app's asset bundle.
|
||||
Future<void> load() async {
|
||||
final source = await rootBundle.loadString('locales/en-US/main.ftl');
|
||||
loadSource(source);
|
||||
}
|
||||
|
||||
/// Loads messages from an already-read source, so tests can read the file
|
||||
/// from disk instead of the asset bundle.
|
||||
void loadSource(String source) {
|
||||
_bundle.addMessages(source);
|
||||
}
|
||||
|
||||
String t(String id, [Map<String, Object?> args = const {}]) {
|
||||
return _bundle.format(id, args: args) ?? id;
|
||||
}
|
||||
}
|
||||
|
||||
/// Provides [Strings] to the widget tree.
|
||||
class StringsScope extends InheritedWidget {
|
||||
const StringsScope({required this.strings, required super.child, super.key});
|
||||
|
||||
final Strings strings;
|
||||
|
||||
static Strings of(BuildContext context) =>
|
||||
context.getInheritedWidgetOfExactType<StringsScope>()!.strings;
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(StringsScope oldWidget) => false;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue