feat: add localisation

This commit is contained in:
2026-07-31 21:46:05 +02:00
parent b58c9a8722
commit f5b2041612
30 changed files with 4099 additions and 326 deletions
+18 -10
View File
@@ -4,6 +4,8 @@ import 'package:kooltab2/models/closed_tab.dart';
import 'package:kooltab2/models/closed_tab_item.dart';
import 'package:kooltab2/models/payment_method.dart';
import '../../l10n/app_localizations.dart';
class ClosedTabCard extends StatefulWidget {
final ClosedTab closedTab;
@@ -26,7 +28,9 @@ class _ClosedTabCardState extends State<ClosedTabCard> {
@override
Widget build(BuildContext context) {
final closedTab = widget.closedTab;
final dateFormat = DateFormat('MMM d, y · h:mm a');
final l10n = AppLocalizations.of(context);
final locale = Localizations.localeOf(context).toLanguageTag();
final dateFormat = DateFormat.yMMMd(locale).add_jm();
final scheme = Theme.of(context).colorScheme;
return Container(
@@ -91,7 +95,10 @@ class _ClosedTabCardState extends State<ClosedTabCard> {
),
const SizedBox(width: 4),
Text(
closedTab.formattedPaymentMethod,
switch (closedTab.paymentMethod) {
PaymentMethod.cash => l10n.cash,
PaymentMethod.payconiq => l10n.payconiq,
},
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w700,
@@ -105,7 +112,7 @@ class _ClosedTabCardState extends State<ClosedTabCard> {
),
const SizedBox(height: 2),
Text(
'${dateFormat.format(closedTab.closedAt)} · ${closedTab.itemCount} items',
'${dateFormat.format(closedTab.closedAt)} · ${l10n.tabItemCount(closedTab.itemCount)}',
style: Theme.of(context).textTheme.bodySmall,
),
],
@@ -164,12 +171,13 @@ class _ClosedTabItemRow extends StatelessWidget {
@override
Widget build(BuildContext context) {
final unitPrice = NumberFormat.simpleCurrency().format(
item.unitPriceInCents / 100,
);
final lineTotal = NumberFormat.simpleCurrency().format(
item.lineTotalInCents / 100,
);
final locale = Localizations.localeOf(context).toLanguageTag();
final unitPrice = NumberFormat.simpleCurrency(
locale: locale,
).format(item.unitPriceInCents / 100);
final lineTotal = NumberFormat.simpleCurrency(
locale: locale,
).format(item.lineTotalInCents / 100);
final scheme = Theme.of(context).colorScheme;
return Padding(
@@ -207,4 +215,4 @@ class _ClosedTabItemRow extends StatelessWidget {
),
);
}
}
}