Skip to content

Commit

Permalink
Add czech and english translations
Browse files Browse the repository at this point in the history
  • Loading branch information
vyPal committed May 2, 2024
1 parent 413ac42 commit b3e53b7
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 32 deletions.
55 changes: 29 additions & 26 deletions lib/create_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:dio/dio.dart';
import 'package:eduapge2/api.dart';
import 'package:eduapge2/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class SendMessageScreen extends StatefulWidget {
const SendMessageScreen({super.key});
Expand All @@ -24,6 +25,7 @@ class SendMessageScreenState extends BaseState<SendMessageScreen> {
bool multipleSelection = false;
List<PollOption> pollOptions = [];
TextEditingController pollOptionController = TextEditingController();
AppLocalizations? loc;

@override
void initState() {
Expand All @@ -46,6 +48,7 @@ class SendMessageScreenState extends BaseState<SendMessageScreen> {

@override
Widget build(BuildContext context) {
loc = AppLocalizations.of(context);
return PopScope(
canPop: message.isEmpty,
onPopInvoked: (didPop) {
Expand All @@ -56,18 +59,17 @@ class SendMessageScreenState extends BaseState<SendMessageScreen> {
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Discard message?'),
content: const Text(
'You have not sent the message yet. Are you sure you want to discard it?'),
title: Text(loc!.createMessageDiscard),
content: Text(loc!.createMessageDiscardDescription),
actions: <Widget>[
TextButton(
child: const Text('Cancel'),
child: Text(loc!.createMessageDiscardCancel),
onPressed: () {
Navigator.pop(context);
},
),
TextButton(
child: const Text('Discard'),
child: Text(loc!.createMessageDiscardDiscard),
onPressed: () {
Navigator.pop(context);
Navigator.pop(context);
Expand All @@ -80,7 +82,7 @@ class SendMessageScreenState extends BaseState<SendMessageScreen> {
},
child: Scaffold(
appBar: AppBar(
title: const Text('Send Message'),
title: Text(loc!.createMessageTitle),
),
body: Padding(
padding: const EdgeInsets.all(8.0),
Expand Down Expand Up @@ -112,10 +114,10 @@ class SendMessageScreenState extends BaseState<SendMessageScreen> {
return TextFormField(
controller: textEditingController,
focusNode: focusNode,
decoration: const InputDecoration(
hintText: 'Select recipient',
contentPadding: EdgeInsets.all(8.0),
border: OutlineInputBorder(
decoration: InputDecoration(
hintText: loc!.createMessageSelectRecipient,
contentPadding: const EdgeInsets.all(8.0),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0),
),
Expand Down Expand Up @@ -155,10 +157,10 @@ class SendMessageScreenState extends BaseState<SendMessageScreen> {
minLines: 4,
onChanged: (value) => setState(() => message = value),
maxLines: null,
decoration: const InputDecoration(
hintText: 'Enter your message here',
contentPadding: EdgeInsets.all(8.0),
border: OutlineInputBorder(
decoration: InputDecoration(
hintText: loc!.createMessageMessageHere,
contentPadding: const EdgeInsets.all(8.0),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0),
),
Expand All @@ -167,7 +169,7 @@ class SendMessageScreenState extends BaseState<SendMessageScreen> {
),
),
SwitchListTile(
title: const Text('Important'),
title: Text(loc!.createMessageImportant),
value: isImportant,
onChanged: (bool value) {
setState(() {
Expand All @@ -176,7 +178,7 @@ class SendMessageScreenState extends BaseState<SendMessageScreen> {
},
),
SwitchListTile(
title: const Text('Include Poll'),
title: Text(loc!.createMessageIncludePoll),
value: includePoll,
onChanged: (bool value) {
setState(() {
Expand All @@ -191,7 +193,7 @@ class SendMessageScreenState extends BaseState<SendMessageScreen> {
child: Column(
children: [
SwitchListTile(
title: const Text('Multiple Selection'),
title: Text(loc!.createMessagePollEnableMultiple),
value: multipleSelection,
onChanged: (bool value) {
setState(() {
Expand All @@ -207,10 +209,11 @@ class SendMessageScreenState extends BaseState<SendMessageScreen> {
onChanged: (value) =>
setState(() => newOption = value),
maxLines: 1,
decoration: const InputDecoration(
hintText: 'New option',
contentPadding: EdgeInsets.all(8.0),
border: OutlineInputBorder(
decoration: InputDecoration(
hintText: loc!
.createMessageNewPollOptionPlaceholder,
contentPadding: const EdgeInsets.all(8.0),
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0),
),
Expand Down Expand Up @@ -286,17 +289,17 @@ class SendMessageScreenState extends BaseState<SendMessageScreen> {
EP2Data data = EP2Data.getInstance();

if (selectedRecipient == null) {
const snackBar = SnackBar(
content: Text('Please select a recipient'),
SnackBar snackBar = SnackBar(
content: Text(loc!.createMessageErrorSelectRecipient),
);

ScaffoldMessenger.of(context).showSnackBar(snackBar);
return;
}

if (message.isEmpty) {
const snackBar = SnackBar(
content: Text('Please enter a message'),
SnackBar snackBar = SnackBar(
content: Text(loc!.createMessageErrorNoMessage),
);

ScaffoldMessenger.of(context).showSnackBar(snackBar);
Expand Down Expand Up @@ -336,7 +339,7 @@ class SendMessageScreenState extends BaseState<SendMessageScreen> {
ScaffoldMessenger.of(context).showSnackBar(snackBar);
});
},
child: const Text('Send Message'),
child: Text(loc!.createMessageSend),
),
],
),
Expand Down
17 changes: 16 additions & 1 deletion lib/l10n/app_cs.arb
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,20 @@
"format": "compact"
}
}
}
},
"messagesPoll": "Anketa",
"createMessageDiscard": "Zahodit zprávu?",
"createMessageDiscardDescription": "Zpráva ještě nebyla odeslána. Opravdu ji chcete zahodit?",
"createMessageDiscardCancel": "Zrušit",
"createMessageDiscardDiscard": "Zahodit",
"createMessageTitle": "Nová zpráva",
"createMessageSelectRecipient": "Vyberte příjemce",
"createMessageMessageHere": "Vaše zpráva zde",
"createMessageImportant": "Důležité",
"createMessageIncludePoll": "Vložit anketu",
"createMessagePollEnableMultiple": "Povolit více odpovědí",
"createMessageNewPollOptionPlaceholder": "Nová možnost",
"createMessageErrorSelectRecipient": "Vyberte prosím příjemce",
"createMessageErrorNoMessage": "Napište prosím zprávu",
"createMessageSend": "Odeslat"
}
17 changes: 16 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,20 @@
"format": "compact"
}
}
}
},
"messagesPoll": "Poll",
"createMessageDiscard": "Discard message?",
"createMessageDiscardDescription": "The message has not been sent yet. Are you sure you want to discard it?",
"createMessageDiscardCancel": "Cancel",
"createMessageDiscardDiscard": "Discard",
"createMessageTitle": "New message",
"createMessageSelectRecipient": "Select recipient",
"createMessageMessageHere": "Your message here",
"createMessageImportant": "Important",
"createMessageIncludePoll": "Include poll",
"createMessagePollEnableMultiple": "Allow multiple answers",
"createMessageNewPollOptionPlaceholder": "New option",
"createMessageErrorSelectRecipient": "Please select a recipient",
"createMessageErrorNoMessage": "Please write a message",
"createMessageSend": "Send"
}
8 changes: 4 additions & 4 deletions lib/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,16 @@ class TimeTablePageState extends BaseState<MessagesPage> {
),
if (msg.data["Value"] != null &&
msg.data["Value"]["votingParams"] != null)
const Padding(
padding: EdgeInsets.only(top: 5),
Padding(
padding: const EdgeInsets.only(top: 5),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Icon(
const Icon(
Icons.poll_rounded,
size: 18,
),
Text("Poll"),
Text(loc!.messagesPoll),
],
),
),
Expand Down

0 comments on commit b3e53b7

Please sign in to comment.