Refactoring l10n

This commit is contained in:
Christian Pauly 2020-05-07 07:52:40 +02:00
commit 6f1ed6120f
42 changed files with 287 additions and 287 deletions

View file

@ -1,7 +1,7 @@
import 'dart:async';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/views/chat_details.dart';
import 'package:fluffychat/views/chat_list.dart';
@ -56,19 +56,19 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
widget.room.pushRuleState == PushRuleState.notify
? PopupMenuItem<String>(
value: "mute",
child: Text(I18n.of(context).muteChat),
child: Text(L10n.of(context).muteChat),
)
: PopupMenuItem<String>(
value: "unmute",
child: Text(I18n.of(context).unmuteChat),
child: Text(L10n.of(context).unmuteChat),
),
PopupMenuItem<String>(
value: "call",
child: Text(I18n.of(context).videoCall),
child: Text(L10n.of(context).videoCall),
),
PopupMenuItem<String>(
value: "leave",
child: Text(I18n.of(context).leave),
child: Text(L10n.of(context).leave),
),
];
if (widget.displayChatDetails) {
@ -76,7 +76,7 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
0,
PopupMenuItem<String>(
value: "details",
child: Text(I18n.of(context).chatDetails),
child: Text(L10n.of(context).chatDetails),
),
);
}

View file

@ -1,6 +1,6 @@
import 'dart:async';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/material.dart';
import 'package:flutter_sound/flutter_sound.dart';
import 'package:intl/intl.dart';
@ -67,7 +67,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
SizedBox(width: 8),
Expanded(
child: Text(
"${I18n.of(context).recording}: $time",
"${L10n.of(context).recording}: $time",
style: TextStyle(
fontSize: 18,
),
@ -78,7 +78,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
actions: <Widget>[
FlatButton(
child: Text(
I18n.of(context).cancel.toUpperCase(),
L10n.of(context).cancel.toUpperCase(),
style: TextStyle(
color: Theme.of(context).textTheme.bodyText2.color.withAlpha(150),
),
@ -88,7 +88,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
FlatButton(
child: Row(
children: <Widget>[
Text(I18n.of(context).send.toUpperCase()),
Text(L10n.of(context).send.toUpperCase()),
SizedBox(width: 4),
Icon(Icons.send, size: 15),
],

View file

@ -1,4 +1,4 @@
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/material.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
@ -51,14 +51,14 @@ class SimpleDialogs {
FlatButton(
child: Text(
cancelText?.toUpperCase() ??
I18n.of(context).close.toUpperCase(),
L10n.of(context).close.toUpperCase(),
style: TextStyle(color: Colors.blueGrey)),
onPressed: () => Navigator.of(context).pop(),
),
FlatButton(
child: Text(
confirmText?.toUpperCase() ??
I18n.of(context).confirm.toUpperCase(),
L10n.of(context).confirm.toUpperCase(),
),
onPressed: () {
input = controller.text;
@ -81,20 +81,20 @@ class SimpleDialogs {
await showDialog(
context: context,
builder: (c) => AlertDialog(
title: Text(titleText ?? I18n.of(context).areYouSure),
title: Text(titleText ?? L10n.of(context).areYouSure),
content: contentText != null ? Text(contentText) : null,
actions: <Widget>[
FlatButton(
child: Text(
cancelText?.toUpperCase() ??
I18n.of(context).close.toUpperCase(),
L10n.of(context).close.toUpperCase(),
style: TextStyle(color: Colors.blueGrey)),
onPressed: () => Navigator.of(context).pop(),
),
FlatButton(
child: Text(
confirmText?.toUpperCase() ??
I18n.of(context).confirm.toUpperCase(),
L10n.of(context).confirm.toUpperCase(),
),
onPressed: () {
confirmed = true;
@ -142,7 +142,7 @@ class SimpleDialogs {
children: <Widget>[
CircularProgressIndicator(),
SizedBox(width: 16),
Text(I18n.of(context).loadingPleaseWait),
Text(L10n.of(context).loadingPleaseWait),
],
),
),

View file

@ -1,7 +1,7 @@
import 'dart:async';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/views/chat_encryption_settings.dart';
import 'package:flutter/material.dart';
@ -22,7 +22,7 @@ class _EncryptionButtonState extends State<EncryptionButton> {
void _enableEncryptionAction() async {
if (widget.room.encrypted) {
showToast(I18n.of(context).warningEncryptionInBeta);
showToast(L10n.of(context).warningEncryptionInBeta);
await Navigator.of(context).push(
AppRoute.defaultRoute(
context,
@ -32,15 +32,15 @@ class _EncryptionButtonState extends State<EncryptionButton> {
return;
}
if (!widget.room.client.encryptionEnabled) {
showToast(I18n.of(context).needPantalaimonWarning);
showToast(L10n.of(context).needPantalaimonWarning);
return;
}
if (await SimpleDialogs(context).askConfirmation(
titleText: I18n.of(context).enableEncryptionWarning,
titleText: L10n.of(context).enableEncryptionWarning,
contentText: widget.room.client.encryptionEnabled
? I18n.of(context).warningEncryptionInBeta
: I18n.of(context).needPantalaimonWarning,
confirmText: I18n.of(context).yes,
? L10n.of(context).warningEncryptionInBeta
: L10n.of(context).needPantalaimonWarning,
confirmText: L10n.of(context).yes,
) ==
true) {
await SimpleDialogs(context).tryRequestWithLoadingDialog(

View file

@ -5,7 +5,7 @@ import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
import 'package:pedantic/pedantic.dart';
import '../../i18n/i18n.dart';
import '../../l10n/l10n.dart';
import '../../utils/app_route.dart';
import '../../utils/date_time_extension.dart';
import '../../views/chat.dart';
@ -31,7 +31,7 @@ class ChatListItem extends StatelessWidget {
}
if (room.membership == Membership.ban) {
showToast(I18n.of(context).youHaveBeenBannedFromThisChat);
showToast(L10n.of(context).youHaveBeenBannedFromThisChat);
return;
}
@ -39,16 +39,16 @@ class ChatListItem extends StatelessWidget {
await showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
title: Text(I18n.of(context).archivedRoom),
content: Text(I18n.of(context).thisRoomHasBeenArchived),
title: Text(L10n.of(context).archivedRoom),
content: Text(L10n.of(context).thisRoomHasBeenArchived),
actions: <Widget>[
FlatButton(
child: Text(I18n.of(context).close.toUpperCase(),
child: Text(L10n.of(context).close.toUpperCase(),
style: TextStyle(color: Colors.blueGrey)),
onPressed: () => Navigator.of(context).pop(),
),
FlatButton(
child: Text(I18n.of(context).delete.toUpperCase(),
child: Text(L10n.of(context).delete.toUpperCase(),
style: TextStyle(color: Colors.red)),
onPressed: () async {
await archiveAction(context);
@ -56,7 +56,7 @@ class ChatListItem extends StatelessWidget {
},
),
FlatButton(
child: Text(I18n.of(context).rejoin.toUpperCase(),
child: Text(L10n.of(context).rejoin.toUpperCase(),
style: TextStyle(color: Colors.blue)),
onPressed: () async {
await SimpleDialogs(context)
@ -122,14 +122,14 @@ class ChatListItem extends StatelessWidget {
secondaryActions: <Widget>[
if ([Membership.join, Membership.invite].contains(room.membership))
IconSlideAction(
caption: I18n.of(context).leave,
caption: L10n.of(context).leave,
color: Colors.red,
icon: Icons.archive,
onTap: () => archiveAction(context),
),
if ([Membership.leave, Membership.ban].contains(room.membership))
IconSlideAction(
caption: I18n.of(context).delete,
caption: L10n.of(context).delete,
color: Colors.red,
icon: Icons.delete_forever,
onTap: () => archiveAction(context),
@ -151,7 +151,7 @@ class ChatListItem extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
room.getLocalizedDisplayname(I18n.of(context)),
room.getLocalizedDisplayname(L10n.of(context)),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
@ -181,13 +181,13 @@ class ChatListItem extends StatelessWidget {
Expanded(
child: room.membership == Membership.invite
? Text(
I18n.of(context).youAreInvitedToThisChat,
L10n.of(context).youAreInvitedToThisChat,
style: TextStyle(
color: Theme.of(context).primaryColor,
),
)
: Text(
room.lastEvent.getLocalizedBody(I18n.of(context),
room.lastEvent.getLocalizedBody(L10n.of(context),
withSenderNamePrefix: true, hideReply: true),
maxLines: 1,
overflow: TextOverflow.ellipsis,

View file

@ -3,7 +3,7 @@ import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
import 'package:fluffychat/components/message_content.dart';
import 'package:fluffychat/components/reply_content.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/date_time_extension.dart';
import 'package:fluffychat/utils/event_extension.dart';
import 'package:fluffychat/utils/string_color.dart';
@ -114,7 +114,7 @@ class Message extends StatelessWidget {
RaisedButton(
color: color.withAlpha(100),
child: Text(
I18n.of(context).requestPermission,
L10n.of(context).requestPermission,
style: TextStyle(color: textColor),
),
onPressed: () => SimpleDialogs(context)

View file

@ -1,6 +1,6 @@
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/views/chat.dart';
import 'package:flutter/material.dart';
@ -65,19 +65,19 @@ class ParticipantListItem extends StatelessWidget {
Widget build(BuildContext context) {
Map<Membership, String> membershipBatch = {
Membership.join: "",
Membership.ban: I18n.of(context).banned,
Membership.invite: I18n.of(context).invited,
Membership.leave: I18n.of(context).leftTheChat,
Membership.ban: L10n.of(context).banned,
Membership.invite: L10n.of(context).invited,
Membership.leave: L10n.of(context).leftTheChat,
};
final String permissionBatch = user.powerLevel == 100
? I18n.of(context).admin
: user.powerLevel >= 50 ? I18n.of(context).moderator : "";
? L10n.of(context).admin
: user.powerLevel >= 50 ? L10n.of(context).moderator : "";
List<PopupMenuEntry<String>> items = <PopupMenuEntry<String>>[];
if (user.id != Matrix.of(context).client.userID) {
items.add(
PopupMenuItem(
child: Text(I18n.of(context).sendAMessage), value: "message"),
child: Text(L10n.of(context).sendAMessage), value: "message"),
);
}
if (user.canChangePowerLevel &&
@ -85,7 +85,7 @@ class ParticipantListItem extends StatelessWidget {
user.powerLevel != 100) {
items.add(
PopupMenuItem(
child: Text(I18n.of(context).makeAnAdmin), value: "admin"),
child: Text(L10n.of(context).makeAnAdmin), value: "admin"),
);
}
if (user.canChangePowerLevel &&
@ -93,29 +93,29 @@ class ParticipantListItem extends StatelessWidget {
user.powerLevel != 50) {
items.add(
PopupMenuItem(
child: Text(I18n.of(context).makeAModerator), value: "moderator"),
child: Text(L10n.of(context).makeAModerator), value: "moderator"),
);
}
if (user.canChangePowerLevel && user.powerLevel != 0) {
items.add(
PopupMenuItem(
child: Text(I18n.of(context).revokeAllPermissions), value: "user"),
child: Text(L10n.of(context).revokeAllPermissions), value: "user"),
);
}
if (user.canKick) {
items.add(
PopupMenuItem(
child: Text(I18n.of(context).kickFromChat), value: "kick"),
child: Text(L10n.of(context).kickFromChat), value: "kick"),
);
}
if (user.canBan && user.membership != Membership.ban) {
items.add(
PopupMenuItem(child: Text(I18n.of(context).banFromChat), value: "ban"),
PopupMenuItem(child: Text(L10n.of(context).banFromChat), value: "ban"),
);
} else if (user.canBan && user.membership == Membership.ban) {
items.add(
PopupMenuItem(
child: Text(I18n.of(context).removeExile), value: "unban"),
child: Text(L10n.of(context).removeExile), value: "unban"),
);
}
return PopupMenuButton(

View file

@ -1,5 +1,5 @@
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/app_route.dart';
import 'package:fluffychat/views/chat.dart';
import 'package:flutter/material.dart';
@ -62,7 +62,7 @@ class PresenceListItem extends StatelessWidget {
actions: <Widget>[
if (presence.sender != Matrix.of(context).client.userID)
FlatButton(
child: Text(I18n.of(context).sendAMessage),
child: Text(L10n.of(context).sendAMessage),
onPressed: () async {
final String roomId = await User(
presence.sender,
@ -77,7 +77,7 @@ class PresenceListItem extends StatelessWidget {
},
),
FlatButton(
child: Text(I18n.of(context).close),
child: Text(L10n.of(context).close),
onPressed: () => Navigator.of(context).pop(),
),
],

View file

@ -2,7 +2,7 @@ import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/dialogs/simple_dialogs.dart';
import 'package:flutter/material.dart';
import '../../i18n/i18n.dart';
import '../../l10n/l10n.dart';
import '../../utils/app_route.dart';
import '../../views/chat.dart';
import '../avatar.dart';
@ -41,7 +41,7 @@ class PublicRoomListItem extends StatelessWidget {
subtitle: Text(
hasTopic
? publicRoomEntry.topic
: I18n.of(context).countParticipants(
: L10n.of(context).countParticipants(
publicRoomEntry.numJoinedMembers?.toString() ?? "0"),
maxLines: 1,
),

View file

@ -1,6 +1,6 @@
import 'package:bubble/bubble.dart';
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/material.dart';
class StateMessage extends StatelessWidget {
@ -21,7 +21,7 @@ class StateMessage extends StatelessWidget {
color: Theme.of(context).backgroundColor.withOpacity(0.66),
alignment: Alignment.center,
child: Text(
event.getLocalizedBody(I18n.of(context)),
event.getLocalizedBody(L10n.of(context)),
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).textTheme.bodyText2.color,

View file

@ -9,7 +9,7 @@ import 'package:flutter/material.dart';
import 'package:localstorage/localstorage.dart';
import 'package:url_launcher/url_launcher.dart';
import '../i18n/i18n.dart';
import '../l10n/l10n.dart';
import '../utils/beautify_string_extension.dart';
import '../utils/famedlysdk_store.dart';
import 'avatar.dart';
@ -106,7 +106,7 @@ class MatrixState extends State<Matrix> {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(I18n.of(context).videoCall),
title: Text(L10n.of(context).videoCall),
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
@ -165,11 +165,11 @@ class MatrixState extends State<Matrix> {
final Room room = request.room;
final User sender = room.getUserByMXIDSync(request.sender);
if (await SimpleDialogs(context).askConfirmation(
titleText: I18n.of(context).requestToReadOlderMessages,
titleText: L10n.of(context).requestToReadOlderMessages,
contentText:
"${sender.id}\n\n${I18n.of(context).device}:\n${request.requestingDevice.deviceId}\n\n${I18n.of(context).identity}:\n${request.requestingDevice.curve25519Key.beautified}",
confirmText: I18n.of(context).verify,
cancelText: I18n.of(context).deny,
"${sender.id}\n\n${L10n.of(context).device}:\n${request.requestingDevice.deviceId}\n\n${L10n.of(context).identity}:\n${request.requestingDevice.curve25519Key.beautified}",
confirmText: L10n.of(context).verify,
cancelText: L10n.of(context).deny,
)) {
await request.forwardKey();
}

View file

@ -1,7 +1,7 @@
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/audio_player.dart';
import 'package:fluffychat/components/image_bubble.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/material.dart';
import 'package:link_text/link_text.dart';
import 'package:url_launcher/url_launcher.dart';
@ -50,14 +50,14 @@ class MessageContent extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Icon(Icons.phone),
Text(I18n.of(context).videoCall),
Text(L10n.of(context).videoCall),
],
),
onPressed: () => launch(event.body),
);
}
return LinkText(
text: event.getLocalizedBody(I18n.of(context), hideReply: true),
text: event.getLocalizedBody(L10n.of(context), hideReply: true),
textStyle: TextStyle(
color: textColor,
decoration: event.redacted ? TextDecoration.lineThrough : null,
@ -67,7 +67,7 @@ class MessageContent extends StatelessWidget {
break;
default:
return Text(
I18n.of(context).userSentUnknownEvent(
L10n.of(context).userSentUnknownEvent(
event.sender.calcDisplayname(), event.typeKey),
style: TextStyle(
color: textColor,

View file

@ -1,5 +1,5 @@
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/material.dart';
import 'package:fluffychat/utils/matrix_file_extension.dart';
import 'package:fluffychat/utils/event_extension.dart';
@ -22,7 +22,7 @@ class MessageDownloadContent extends StatelessWidget {
RaisedButton(
color: Colors.blueGrey,
child: Text(
I18n.of(context).downloadFile,
L10n.of(context).downloadFile,
overflow: TextOverflow.fade,
softWrap: false,
maxLines: 1,

View file

@ -1,5 +1,5 @@
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/l10n/l10n.dart';
import 'package:flutter/material.dart';
class ReplyContent extends StatelessWidget {
@ -36,7 +36,7 @@ class ReplyContent extends StatelessWidget {
),
Text(
replyEvent?.getLocalizedBody(
I18n.of(context),
L10n.of(context),
withSenderNamePrefix: false,
hideReply: true,
) ??

View file

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import '../components/theme_switcher.dart';
import '../components/matrix.dart';
import '../i18n/i18n.dart';
import '../l10n/l10n.dart';
class ThemesSettings extends StatefulWidget {
@override
@ -25,7 +25,7 @@ class ThemesSettingsState extends State<ThemesSettings> {
children: <Widget>[
RadioListTile<Themes>(
title: Text(
I18n.of(context).systemTheme,
L10n.of(context).systemTheme,
),
value: Themes.system,
groupValue: _selectedTheme,
@ -39,7 +39,7 @@ class ThemesSettingsState extends State<ThemesSettings> {
),
RadioListTile<Themes>(
title: Text(
I18n.of(context).lightTheme,
L10n.of(context).lightTheme,
),
value: Themes.light,
groupValue: _selectedTheme,
@ -53,7 +53,7 @@ class ThemesSettingsState extends State<ThemesSettings> {
),
RadioListTile<Themes>(
title: Text(
I18n.of(context).darkTheme,
L10n.of(context).darkTheme,
),
value: Themes.dark,
groupValue: _selectedTheme,
@ -67,7 +67,7 @@ class ThemesSettingsState extends State<ThemesSettings> {
),
ListTile(
title: Text(
I18n.of(context).useAmoledTheme,
L10n.of(context).useAmoledTheme,
),
trailing: Switch(
value: _amoledEnabled,