refactor: Use non nullable localizations builder and lazy load on web

This commit is contained in:
krille-chan 2024-10-06 08:35:37 +02:00
commit 0d4b7d67cc
No known key found for this signature in database
111 changed files with 879 additions and 883 deletions

View file

@ -30,7 +30,7 @@ extension LocalizedExceptionExtension on Object {
]) {
if (this is FileTooBigMatrixException) {
final exception = this as FileTooBigMatrixException;
return L10n.of(context)!.fileIsTooBigForServer(
return L10n.of(context).fileIsTooBigForServer(
_formatFileSize(exception.maxFileSize),
);
}
@ -38,17 +38,17 @@ extension LocalizedExceptionExtension on Object {
switch ((this as MatrixException).error) {
case MatrixError.M_FORBIDDEN:
if (exceptionContext == ExceptionContext.changePassword) {
return L10n.of(context)!.passwordIsWrong;
return L10n.of(context).passwordIsWrong;
}
return L10n.of(context)!.noPermission;
return L10n.of(context).noPermission;
case MatrixError.M_LIMIT_EXCEEDED:
return L10n.of(context)!.tooManyRequestsWarning;
return L10n.of(context).tooManyRequestsWarning;
default:
return (this as MatrixException).errorMessage;
}
}
if (this is InvalidPassphraseException) {
return L10n.of(context)!.wrongRecoveryKey;
return L10n.of(context).wrongRecoveryKey;
}
if (this is BadServerVersionsException) {
final serverVersions = (this as BadServerVersionsException)
@ -61,7 +61,7 @@ extension LocalizedExceptionExtension on Object {
.toString()
.replaceAll('{', '"')
.replaceAll('}', '"');
return L10n.of(context)!.badServerVersionsException(
return L10n.of(context).badServerVersionsException(
serverVersions,
supportedVersions,
serverVersions,
@ -79,7 +79,7 @@ extension LocalizedExceptionExtension on Object {
.toString()
.replaceAll('{', '"')
.replaceAll('}', '"');
return L10n.of(context)!.badServerLoginTypesException(
return L10n.of(context).badServerLoginTypesException(
serverVersions,
supportedVersions,
supportedVersions,
@ -89,16 +89,16 @@ extension LocalizedExceptionExtension on Object {
this is SocketException ||
this is SyncConnectionException ||
this is ClientException) {
return L10n.of(context)!.noConnectionToTheServer;
return L10n.of(context).noConnectionToTheServer;
}
if (this is FormatException &&
exceptionContext == ExceptionContext.checkHomeserver) {
return L10n.of(context)!.doesNotSeemToBeAValidHomeserver;
return L10n.of(context).doesNotSeemToBeAValidHomeserver;
}
if (this is String) return toString();
if (this is UiaException) return toString();
Logs().w('Something went wrong: ', this);
return L10n.of(context)!.oopsSomethingWentWrong;
return L10n.of(context).oopsSomethingWentWrong;
}
}