Add localizations

This commit is contained in:
Christian Pauly 2020-01-20 13:46:39 +01:00
commit a776ac1513
28 changed files with 3406 additions and 249 deletions

View file

@ -1,6 +1,7 @@
import 'dart:async';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/views/chat_details.dart';
import 'package:fluffychat/views/chat_list.dart';
@ -39,25 +40,25 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
);
List<PopupMenuEntry<String>> items = <PopupMenuEntry<String>>[
widget.room.pushRuleState == PushRuleState.notify
? const PopupMenuItem<String>(
? PopupMenuItem<String>(
value: "mute",
child: Text('Mute chat'),
child: Text(I18n.of(context).muteChat),
)
: const PopupMenuItem<String>(
: PopupMenuItem<String>(
value: "unmute",
child: Text('Unmute chat'),
child: Text(I18n.of(context).unmuteChat),
),
const PopupMenuItem<String>(
PopupMenuItem<String>(
value: "leave",
child: Text('Leave'),
child: Text(I18n.of(context).leave),
),
];
if (widget.displayChatDetails) {
items.insert(
0,
const PopupMenuItem<String>(
PopupMenuItem<String>(
value: "details",
child: Text('Chat details'),
child: Text(I18n.of(context).chatDetails),
),
);
}

View file

@ -1,4 +1,5 @@
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:flutter/material.dart';
import '../matrix.dart';
@ -15,7 +16,7 @@ class RedactMessageDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text("Message will be removed for all participants"),
title: Text(I18n.of(context).messageWillBeRemovedWarning),
actions: <Widget>[
FlatButton(
child: Text("Close".toUpperCase(),
@ -24,7 +25,7 @@ class RedactMessageDialog extends StatelessWidget {
),
FlatButton(
child: Text(
"Remove".toUpperCase(),
I18n.of(context).remove.toUpperCase(),
style: TextStyle(color: Colors.red),
),
onPressed: () => removeAction(context),

View file

@ -1,4 +1,5 @@
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/utils/event_extension.dart';
import 'package:fluffychat/utils/date_time_extension.dart';
import 'package:fluffychat/utils/app_route.dart';
@ -27,7 +28,8 @@ class ChatListItem extends StatelessWidget {
}
if (room.membership == Membership.ban) {
Toast.show("You have been banned from this chat", context, duration: 5);
Toast.show(I18n.of(context).youHaveBeenBannedFromThisChat, context,
duration: 5);
return;
}
@ -35,16 +37,16 @@ class ChatListItem extends StatelessWidget {
await showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
title: Text("Archived Room"),
content: Text("This room has been archived."),
title: Text(I18n.of(context).archivedRoom),
content: Text(I18n.of(context).thisRoomHasBeenArchived),
actions: <Widget>[
FlatButton(
child: Text("Close".toUpperCase(),
child: Text(I18n.of(context).close.toUpperCase(),
style: TextStyle(color: Colors.blueGrey)),
onPressed: () => Navigator.of(context).pop(),
),
FlatButton(
child: Text("Forget".toUpperCase(),
child: Text(I18n.of(context).delete.toUpperCase(),
style: TextStyle(color: Colors.red)),
onPressed: () async {
await Matrix.of(context)
@ -54,7 +56,7 @@ class ChatListItem extends StatelessWidget {
},
),
FlatButton(
child: Text("Rejoin".toUpperCase(),
child: Text(I18n.of(context).rejoin.toUpperCase(),
style: TextStyle(color: Colors.blue)),
onPressed: () async {
await Matrix.of(context)
@ -112,7 +114,7 @@ class ChatListItem extends StatelessWidget {
Expanded(
child: room.membership == Membership.invite
? Text(
"You are invited to this chat",
I18n.of(context).youAreInvitedToThisChat,
style: TextStyle(
color: Theme.of(context).primaryColor,
),

View file

@ -2,6 +2,7 @@ import 'package:bubble/bubble.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/dialogs/redact_message_dialog.dart';
import 'package:fluffychat/components/message_content.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/utils/date_time_extension.dart';
import 'package:fluffychat/utils/string_color.dart';
@ -48,9 +49,9 @@ class Message extends StatelessWidget {
List<PopupMenuEntry<String>> popupMenuList = [];
if (event.canRedact && !event.redacted && event.status > 1) {
popupMenuList.add(
const PopupMenuItem<String>(
PopupMenuItem<String>(
value: "remove",
child: Text('Remove message'),
child: Text(I18n.of(context).removeMessage),
),
);
}
@ -75,24 +76,24 @@ class Message extends StatelessWidget {
if (!event.redacted) {
popupMenuList.add(
const PopupMenuItem<String>(
PopupMenuItem<String>(
value: "forward",
child: Text('Forward'),
child: Text(I18n.of(context).forward),
),
);
}
if (ownMessage && event.status == -1) {
popupMenuList.add(
const PopupMenuItem<String>(
PopupMenuItem<String>(
value: "resend",
child: Text('Send again'),
child: Text(I18n.of(context).tryToSendAgain),
),
);
popupMenuList.add(
const PopupMenuItem<String>(
PopupMenuItem<String>(
value: "delete",
child: Text('Delete message'),
child: Text(I18n.of(context).deleteMessage),
),
);
}
@ -100,7 +101,7 @@ class Message extends StatelessWidget {
List<Widget> rowChildren = [
Expanded(
child: PopupMenuButton(
tooltip: "Tap to show menu",
tooltip: I18n.of(context).tapToShowMenu,
onSelected: (String choice) async {
switch (choice) {
case "remove":
@ -141,7 +142,9 @@ class Message extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
ownMessage ? "You" : event.sender.calcDisplayname(),
ownMessage
? I18n.of(context).you
: event.sender.calcDisplayname(),
style: TextStyle(
color: ownMessage
? textColor

View file

@ -1,4 +1,5 @@
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/views/chat.dart';
import 'package:flutter/material.dart';
@ -43,45 +44,50 @@ class ParticipantListItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
const Map<Membership, String> membershipBatch = {
Map<Membership, String> membershipBatch = {
Membership.join: "",
Membership.ban: "Banned",
Membership.invite: "Invited",
Membership.leave: "Left",
Membership.ban: I18n.of(context).banned,
Membership.invite: I18n.of(context).invited,
Membership.leave: I18n.of(context).leftTheChat,
};
final String permissionBatch = user.powerLevel == 100
? "Admin"
: user.powerLevel >= 50 ? "Moderator" : "";
? I18n.of(context).admin
: user.powerLevel >= 50 ? I18n.of(context).moderator : "";
List<PopupMenuEntry<String>> items = <PopupMenuEntry<String>>[];
if (user.canChangePowerLevel &&
user.room.ownPowerLevel == 100 &&
user.powerLevel != 100) {
items.add(
PopupMenuItem(child: Text("Make an admin"), value: "admin"),
PopupMenuItem(
child: Text(I18n.of(context).makeAnAdmin), value: "admin"),
);
}
if (user.canChangePowerLevel && user.powerLevel != 0) {
items.add(
PopupMenuItem(child: Text("Revoke all permissions"), value: "user"),
PopupMenuItem(
child: Text(I18n.of(context).revokeAllPermissions), value: "user"),
);
}
if (user.canKick) {
items.add(
PopupMenuItem(child: Text("Kick from group"), value: "kick"),
PopupMenuItem(
child: Text(I18n.of(context).kickFromChat), value: "kick"),
);
}
if (user.canBan && user.membership != Membership.ban) {
items.add(
PopupMenuItem(child: Text("Ban from group"), value: "ban"),
PopupMenuItem(child: Text(I18n.of(context).banFromChat), value: "ban"),
);
} else if (user.canBan && user.membership == Membership.ban) {
items.add(
PopupMenuItem(child: Text("Remove exile"), value: "unban"),
PopupMenuItem(
child: Text(I18n.of(context).removeExile), value: "unban"),
);
}
if (user.id != Matrix.of(context).client.userID) {
items.add(
PopupMenuItem(child: Text("Send a message"), value: "message"),
PopupMenuItem(
child: Text(I18n.of(context).sendAMessage), value: "message"),
);
}
return PopupMenuButton(

View file

@ -3,6 +3,7 @@ import 'dart:convert';
import 'dart:io';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/utils/event_extension.dart';
import 'package:fluffychat/utils/room_extension.dart';
@ -131,7 +132,7 @@ class MatrixState extends State<Matrix> {
children: <Widget>[
CircularProgressIndicator(),
SizedBox(width: 16),
Text("Loading... Please wait"),
Text(I18n.of(context).loadingPleaseWait),
],
),
),
@ -167,9 +168,9 @@ class MatrixState extends State<Matrix> {
final String token = await _firebaseMessaging.getToken();
if (token?.isEmpty ?? true) {
return Toast.show(
"Push notifications disabled.",
I18n.of(context).noGoogleServicesWarning,
context,
duration: Toast.LENGTH_LONG,
duration: 10,
);
}
await client.setPushers(
@ -261,8 +262,9 @@ class MatrixState extends State<Matrix> {
// Calculate title
final String title = unread > 1
? "$unreadEvents unread messages in $unread chats"
: "$unreadEvents unread messages";
? I18n.of(context).unreadMessagesInChats(
unreadEvents.toString(), unread.toString())
: I18n.of(context).unreadMessages(unreadEvents.toString());
// Calculate the body
final String body = event.getLocalizedBody(context,
@ -300,7 +302,7 @@ class MatrixState extends State<Matrix> {
),
importance: Importance.Max,
priority: Priority.High,
ticker: 'New message in FluffyChat');
ticker: I18n.of(context).newMessageInFluffyChat);
var iOSPlatformChannelSpecifics = IOSNotificationDetails();
var platformChannelSpecifics = NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);

View file

@ -1,6 +1,7 @@
import 'package:bubble/bubble.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/utils/event_extension.dart';
import 'package:fluffychat/views/content_web_view.dart';
@ -63,7 +64,7 @@ class MessageContent extends StatelessWidget {
children: <Widget>[
Icon(Icons.play_arrow, color: Colors.white),
Text(
"Play ${event.body}",
I18n.of(context).play(event.body),
overflow: TextOverflow.fade,
softWrap: false,
maxLines: 1,
@ -88,7 +89,7 @@ class MessageContent extends StatelessWidget {
children: <Widget>[
Icon(Icons.play_arrow, color: Colors.white),
Text(
"Play ${event.body}",
I18n.of(context).play(event.body),
overflow: TextOverflow.fade,
softWrap: false,
maxLines: 1,
@ -110,7 +111,7 @@ class MessageContent extends StatelessWidget {
child: RaisedButton(
color: Colors.blueGrey,
child: Text(
"Download ${event.body}",
I18n.of(context).download(event.body),
overflow: TextOverflow.fade,
softWrap: false,
maxLines: 1,
@ -144,7 +145,8 @@ class MessageContent extends StatelessWidget {
);
default:
return Text(
"${event.sender.calcDisplayname()} sent a ${event.typeKey} event",
I18n.of(context).userSentUnknownEvent(
event.sender.calcDisplayname(), event.typeKey),
style: TextStyle(
color: textColor,
decoration: event.redacted ? TextDecoration.lineThrough : null,