@@ -43,17 +43,17 @@ enum ServerUrlValidationError {
43
43
}
44
44
}
45
45
46
- String message () { // TODO(i18n)
46
+ String message (ZulipLocalizations zulipLocalizations ) {
47
47
switch (this ) {
48
48
case empty:
49
- return 'Please enter a URL.' ;
49
+ return zulipLocalizations.serverUrlValidationErrorEmpty ;
50
50
case invalidUrl:
51
- return 'Please enter a valid URL.' ;
51
+ return zulipLocalizations.serverUrlValidationErrorInvalidUrl ;
52
52
case noUseEmail:
53
- return 'Please enter the server URL, not your email.' ;
53
+ return zulipLocalizations.serverUrlValidationErrorNoUseEmail ;
54
54
case unsupportedSchemeZulip:
55
55
case unsupportedSchemeOther:
56
- return 'The server URL must start with http:// or https://.' ;
56
+ return zulipLocalizations.serverUrlValidationErrorUnsupportedScheme ;
57
57
}
58
58
}
59
59
}
@@ -136,11 +136,13 @@ class _AddAccountPageState extends State<AddAccountPage> {
136
136
}
137
137
138
138
Future <void > _onSubmitted (BuildContext context) async {
139
+ final zulipLocalizations = ZulipLocalizations .of (context);
139
140
final url = _parseResult.url;
140
141
final error = _parseResult.error;
141
142
if (error != null ) {
142
143
showErrorDialog (context: context,
143
- title: 'Invalid input' , message: error.message ());
144
+ title: zulipLocalizations.errorLoginInvalidInputTitle,
145
+ message: error.message (zulipLocalizations));
144
146
return ;
145
147
}
146
148
assert (url != null );
@@ -159,7 +161,8 @@ class _AddAccountPageState extends State<AddAccountPage> {
159
161
// TODO(#105) give more helpful feedback; see `fetchServerSettings`
160
162
// in zulip-mobile's src/message/fetchActions.js.
161
163
showErrorDialog (context: context,
162
- title: 'Could not connect' , message: 'Failed to connect to server:\n $url ' );
164
+ title: zulipLocalizations.errorLoginCouldNotConnectTitle,
165
+ message: zulipLocalizations.errorLoginCouldNotConnect (url.toString ()));
163
166
return ;
164
167
}
165
168
// https://github.com/dart-lang/linter/issues/4007
@@ -181,13 +184,14 @@ class _AddAccountPageState extends State<AddAccountPage> {
181
184
@override
182
185
Widget build (BuildContext context) {
183
186
assert (! PerAccountStoreWidget .debugExistsOf (context));
187
+ final zulipLocalizations = ZulipLocalizations .of (context);
184
188
final error = _parseResult.error;
185
189
final errorText = error == null || error.shouldDeferFeedback ()
186
190
? null
187
- : error.message ();
191
+ : error.message (zulipLocalizations );
188
192
189
193
return Scaffold (
190
- appBar: AppBar (title: const Text ('Add an account' ),
194
+ appBar: AppBar (title: Text (zulipLocalizations.loginAddAnAccount ),
191
195
bottom: _inProgress
192
196
? const PreferredSize (preferredSize: Size .fromHeight (4 ),
193
197
child: LinearProgressIndicator (minHeight: 4 )) // 4 restates default
@@ -212,7 +216,7 @@ class _AddAccountPageState extends State<AddAccountPage> {
212
216
// …but leave out unfocusing the input in case more editing is needed.
213
217
},
214
218
decoration: InputDecoration (
215
- labelText: 'Your Zulip server URL' ,
219
+ labelText: zulipLocalizations.loginServerUrlInputLabel ,
216
220
errorText: errorText,
217
221
helperText: kLayoutPinningHelperText,
218
222
hintText: 'your-org.zulipchat.com' )),
@@ -221,7 +225,7 @@ class _AddAccountPageState extends State<AddAccountPage> {
221
225
onPressed: ! _inProgress && errorText == null
222
226
? () => _onSubmitted (context)
223
227
: null ,
224
- child: const Text ('Continue' )),
228
+ child: Text (zulipLocalizations.loginAddAnAccountConfirm )),
225
229
])))));
226
230
}
227
231
}
@@ -292,7 +296,7 @@ class _PasswordLoginPageState extends State<PasswordLoginPage> {
292
296
// errors for deactivated user or realm (see zulip-mobile#4571).
293
297
final zulipLocalizations = ZulipLocalizations .of (context);
294
298
showErrorDialog (context: context,
295
- title: 'Login failed' ,
299
+ title: zulipLocalizations.errorLoginFailed ,
296
300
message: e.message (zulipLocalizations));
297
301
return ;
298
302
}
@@ -336,6 +340,7 @@ class _PasswordLoginPageState extends State<PasswordLoginPage> {
336
340
@override
337
341
Widget build (BuildContext context) {
338
342
assert (! PerAccountStoreWidget .debugExistsOf (context));
343
+ final zulipLocalizations = ZulipLocalizations .of (context);
339
344
final requireEmailFormatUsernames = widget.serverSettings.requireEmailFormatUsernames;
340
345
341
346
final usernameField = TextFormField (
@@ -351,8 +356,8 @@ class _PasswordLoginPageState extends State<PasswordLoginPage> {
351
356
validator: (value) {
352
357
if (value == null || value.trim ().isEmpty) {
353
358
return requireEmailFormatUsernames
354
- ? 'Please enter your email.'
355
- : 'Please enter your username.' ;
359
+ ? zulipLocalizations.loginValidationRequireEmail
360
+ : zulipLocalizations.loginValidationRequireUsername ;
356
361
}
357
362
if (requireEmailFormatUsernames) {
358
363
// TODO(#106): validate is in the shape of an email
@@ -361,7 +366,9 @@ class _PasswordLoginPageState extends State<PasswordLoginPage> {
361
366
},
362
367
textInputAction: TextInputAction .next,
363
368
decoration: InputDecoration (
364
- labelText: requireEmailFormatUsernames ? 'Email address' : 'Username' ,
369
+ labelText: requireEmailFormatUsernames
370
+ ? zulipLocalizations.loginValidationRequireEmailLabel
371
+ : zulipLocalizations.loginValidationRequireUsernameLabel,
365
372
helperText: kLayoutPinningHelperText,
366
373
));
367
374
@@ -373,14 +380,14 @@ class _PasswordLoginPageState extends State<PasswordLoginPage> {
373
380
autovalidateMode: AutovalidateMode .onUserInteraction,
374
381
validator: (value) {
375
382
if (value == null || value.isEmpty) {
376
- return 'Please enter your password.' ;
383
+ return zulipLocalizations.loginValidationPassword ;
377
384
}
378
385
return null ;
379
386
},
380
387
textInputAction: TextInputAction .go,
381
388
onFieldSubmitted: (value) => _submit (),
382
389
decoration: InputDecoration (
383
- labelText: 'Password' ,
390
+ labelText: zulipLocalizations.loginValidationPasswordLabel ,
384
391
helperText: kLayoutPinningHelperText,
385
392
// TODO(material-3): Simplify away `Semantics` by using IconButton's
386
393
// M3-only params `isSelected` / `selectedIcon`, after fixing
@@ -390,14 +397,14 @@ class _PasswordLoginPageState extends State<PasswordLoginPage> {
390
397
// [ButtonStyleButton].)
391
398
suffixIcon: Semantics (toggled: _obscurePassword,
392
399
child: IconButton (
393
- tooltip: 'Hide password' ,
400
+ tooltip: zulipLocalizations.loginHidePassword ,
394
401
onPressed: _handlePasswordVisibilityPress,
395
402
icon: _obscurePassword
396
403
? const Icon (Icons .visibility_off)
397
404
: const Icon (Icons .visibility)))));
398
405
399
406
return Scaffold (
400
- appBar: AppBar (title: const Text ('Log in' ),
407
+ appBar: AppBar (title: Text (zulipLocalizations.loginPageTitle ),
401
408
bottom: _inProgress
402
409
? const PreferredSize (preferredSize: Size .fromHeight (4 ),
403
410
child: LinearProgressIndicator (minHeight: 4 )) // 4 restates default
@@ -417,7 +424,7 @@ class _PasswordLoginPageState extends State<PasswordLoginPage> {
417
424
const SizedBox (height: 8 ),
418
425
ElevatedButton (
419
426
onPressed: _inProgress ? null : _submit,
420
- child: const Text ('Log in' )),
427
+ child: Text (zulipLocalizations.loginFormSubmitLabel )),
421
428
])))))));
422
429
}
423
430
}
0 commit comments