Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization sweep #306

Merged
merged 17 commits into from
Oct 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
login: Add translations for ServerUrlValidationError enum
  • Loading branch information
sirpengi authored and gnprice committed Oct 9, 2023
commit 503d66da72be932246ca186b1c1d0dd2d4e9b46c
16 changes: 16 additions & 0 deletions assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
@@ -116,6 +116,22 @@
"httpStatus": {"type": "int", "example": "500"}
}
},
"serverUrlValidationErrorEmpty": "Please enter a URL.",
"@serverUrlValidationErrorEmpty": {
"description": "Error message when URL is empty"
},
"serverUrlValidationErrorInvalidUrl": "Please enter a valid URL.",
"@serverUrlValidationErrorInvalidUrl": {
"description": "Error message when URL is not in a valid format."
},
"serverUrlValidationErrorNoUseEmail": "Please enter the server URL, not your email.",
"@serverUrlValidationErrorNoUseEmail": {
"description": "Error message when URL looks like an email"
},
"serverUrlValidationErrorUnsupportedScheme": "The server URL must start with http:// or https://.",
"@serverUrlValidationErrorUnsupportedScheme": {
"description": "Error message when URL has an unsupported scheme."
},
"userRoleOwner": "Owner",
"@userRoleOwner": {
"description": "Label for UserRole.owner"
18 changes: 11 additions & 7 deletions lib/widgets/login.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/zulip_localizations.dart';

import '../api/core.dart';
import '../api/exception.dart';
@@ -42,17 +43,17 @@ enum ServerUrlValidationError {
}
}

String message() { // TODO(i18n)
String message(ZulipLocalizations zulipLocalizations) {
switch (this) {
case empty:
return 'Please enter a URL.';
return zulipLocalizations.serverUrlValidationErrorEmpty;
case invalidUrl:
return 'Please enter a valid URL.';
return zulipLocalizations.serverUrlValidationErrorInvalidUrl;
case noUseEmail:
return 'Please enter the server URL, not your email.';
return zulipLocalizations.serverUrlValidationErrorNoUseEmail;
case unsupportedSchemeZulip:
case unsupportedSchemeOther:
return 'The server URL must start with http:// or https://.';
return zulipLocalizations.serverUrlValidationErrorUnsupportedScheme;
}
}
}
@@ -135,11 +136,13 @@ class _AddAccountPageState extends State<AddAccountPage> {
}

Future<void> _onSubmitted(BuildContext context) async {
final zulipLocalizations = ZulipLocalizations.of(context);
final url = _parseResult.url;
final error = _parseResult.error;
if (error != null) {
showErrorDialog(context: context,
title: 'Invalid input', message: error.message());
title: 'Invalid input',
message: error.message(zulipLocalizations));
return;
}
assert(url != null);
@@ -180,10 +183,11 @@ class _AddAccountPageState extends State<AddAccountPage> {
@override
Widget build(BuildContext context) {
assert(!PerAccountStoreWidget.debugExistsOf(context));
final zulipLocalizations = ZulipLocalizations.of(context);
final error = _parseResult.error;
final errorText = error == null || error.shouldDeferFeedback()
? null
: error.message();
: error.message(zulipLocalizations);

return Scaffold(
appBar: AppBar(title: const Text('Add an account'),