Created Strings for popup

This commit is contained in:
2025-07-14 10:01:11 +02:00
parent 68477158e5
commit 0a0da96a3f
7 changed files with 91 additions and 11 deletions

View File

@@ -73,6 +73,22 @@
"kamikaze": "Kamikaze", "kamikaze": "Kamikaze",
"done": "Fertig", "done": "Fertig",
"next_round": "Nächste Runde", "next_round": "Nächste Runde",
"bonus_points_title": "Bonus-Punkte!",
"bonus_points_message": "{playerCount, plural, =1{{names} hat exakt das Punktelimit von {pointLimit} Punkten erreicht und bekommt deshalb {bonusPoints} Punkte abgezogen!} other{{names} haben exakt das Punktelimit von {pointLimit} Punkten erreicht und bekommen deshalb jeweils {bonusPoints} Punkte abgezogen!}}",
"@bonus_points_message": {
"placeholders": {
"names": {
"type": "String"
},
"pointLimit": {
"type": "int"
},
"bonusPoints": {
"type": "int"
}
}
},
"end_game": "Spiel beenden", "end_game": "Spiel beenden",
"delete_game": "Spiel löschen", "delete_game": "Spiel löschen",

View File

@@ -73,6 +73,22 @@
"kamikaze": "Kamikaze", "kamikaze": "Kamikaze",
"done": "Done", "done": "Done",
"next_round": "Next Round", "next_round": "Next Round",
"bonus_points_title": "Bonus-Points!",
"bonus_points_message": "{playerCount, plural, =1{{names} has reached exactly the point limit of {pointLimit} points and therefore gets {bonusPoints} points deducted!} other{{names} have reached exactly the point limit of {pointLimit} points and therefore get {bonusPoints} points deducted!}}",
"@bonus_points_message": {
"placeholders": {
"names": {
"type": "String"
},
"pointLimit": {
"type": "int"
},
"bonusPoints": {
"type": "int"
}
}
},
"end_game": "End Game", "end_game": "End Game",
"delete_game": "Delete Game", "delete_game": "Delete Game",

View File

@@ -416,6 +416,19 @@ abstract class AppLocalizations {
/// **'Nächste Runde'** /// **'Nächste Runde'**
String get next_round; String get next_round;
/// No description provided for @bonus_points_title.
///
/// In de, this message translates to:
/// **'Bonus-Punkte!'**
String get bonus_points_title;
/// No description provided for @bonus_points_message.
///
/// In de, this message translates to:
/// **'{playerCount, plural, =1{{names} hat exakt das Punktelimit von {pointLimit} Punkten erreicht und bekommt deshalb {bonusPoints} Punkte abgezogen!} other{{names} haben exakt das Punktelimit von {pointLimit} Punkten erreicht und bekommen deshalb jeweils {bonusPoints} Punkte abgezogen!}}'**
String bonus_points_message(
String names, int pointLimit, int bonusPoints, num playerCount);
/// No description provided for @end_game. /// No description provided for @end_game.
/// ///
/// In de, this message translates to: /// In de, this message translates to:

View File

@@ -178,6 +178,23 @@ class AppLocalizationsDe extends AppLocalizations {
@override @override
String get next_round => 'Nächste Runde'; String get next_round => 'Nächste Runde';
@override
String get bonus_points_title => 'Bonus-Punkte!';
@override
String bonus_points_message(
String names, int pointLimit, int bonusPoints, num playerCount) {
String _temp0 = intl.Intl.pluralLogic(
playerCount,
locale: localeName,
other:
'$names haben exakt das Punktelimit von $pointLimit Punkten erreicht und bekommen deshalb jeweils $bonusPoints Punkte abgezogen!',
one:
'$names hat exakt das Punktelimit von $pointLimit Punkten erreicht und bekommt deshalb $bonusPoints Punkte abgezogen!',
);
return '$_temp0';
}
@override @override
String get end_game => 'Spiel beenden'; String get end_game => 'Spiel beenden';

View File

@@ -175,6 +175,23 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get next_round => 'Next Round'; String get next_round => 'Next Round';
@override
String get bonus_points_title => 'Bonus-Points!';
@override
String bonus_points_message(
String names, int pointLimit, int bonusPoints, num playerCount) {
String _temp0 = intl.Intl.pluralLogic(
playerCount,
locale: localeName,
other:
'$names have reached exactly the point limit of $pointLimit points and therefore get $bonusPoints points deducted!',
one:
'$names has reached exactly the point limit of $pointLimit points and therefore gets $bonusPoints points deducted!',
);
return '$_temp0';
}
@override @override
String get end_game => 'End Game'; String get end_game => 'End Game';

View File

@@ -403,17 +403,18 @@ class _RoundViewState extends State<RoundView> {
int pointLimit = widget.gameSession.pointLimit; int pointLimit = widget.gameSession.pointLimit;
int bonusPoints = (pointLimit / 2).round(); int bonusPoints = (pointLimit / 2).round();
String resultText = _getPopupString(pointLimit, bonusPoints, bonusPlayers); String resultText =
_getBonusPopupMessageString(pointLimit, bonusPoints, bonusPlayers);
await showCupertinoDialog( await showCupertinoDialog(
context: context, context: context,
builder: (context) => CupertinoAlertDialog( builder: (context) => CupertinoAlertDialog(
title: const Text('Bonus!'), title: Text(AppLocalizations.of(context).bonus_points_title),
content: Text(resultText), content: Text(resultText),
actions: [ actions: [
CupertinoDialogAction( CupertinoDialogAction(
child: const Text('OK'), child: Text(AppLocalizations.of(context).ok),
onPressed: () => Navigator.of(context).pop(true), onPressed: () => Navigator.of(context).pop(),
), ),
], ],
), ),
@@ -421,23 +422,23 @@ class _RoundViewState extends State<RoundView> {
return true; return true;
} }
/// Generates the string for the bonus popup. /// Generates the message string for the bonus popup.
/// It takes the [pointLimit], [bonusPoints] and the list of [bonusPlayers] /// It takes the [pointLimit], [bonusPoints] and the list of [bonusPlayers]
/// and returns a formatted string. /// and returns a formatted string.
String _getPopupString( String _getBonusPopupMessageString(
int pointLimit, int bonusPoints, List<int> bonusPlayers) { int pointLimit, int bonusPoints, List<int> bonusPlayers) {
List<String> nameList = List<String> nameList =
bonusPlayers.map((i) => widget.gameSession.players[i]).toList(); bonusPlayers.map((i) => widget.gameSession.players[i]).toList();
String resultText = ''; String resultText = '';
if (nameList.length == 1) { if (nameList.length == 1) {
resultText = resultText = AppLocalizations.of(context).bonus_points_message(
'${nameList.first} hat exakt das Punktelimit von $pointLimit Punkten erreicht und bekommt deshalb $bonusPoints Punkte abgezogen!'; nameList.first, pointLimit, bonusPoints, nameList.length);
} else { } else {
resultText = nameList.length == 2 resultText = nameList.length == 2
? '${nameList[0]} & ${nameList[1]}' ? '${nameList[0]} & ${nameList[1]}'
: '${nameList.sublist(0, nameList.length - 1).join(', ')} & ${nameList.last}'; : '${nameList.sublist(0, nameList.length - 1).join(', ')} & ${nameList.last}';
resultText += resultText = AppLocalizations.of(context).bonus_points_message(
' haben exakt das Punktelimit von $pointLimit Punkten erreicht und bekommen deshalb $bonusPoints Punkte abgezogen!'; resultText, pointLimit, bonusPoints, nameList.length);
} }
return resultText; return resultText;
} }

View File

@@ -2,7 +2,7 @@ name: cabo_counter
description: "Mobile app for the card game Cabo" description: "Mobile app for the card game Cabo"
publish_to: 'none' publish_to: 'none'
version: 0.4.4+488 version: 0.4.5+492
environment: environment:
sdk: ^3.5.4 sdk: ^3.5.4