@@ -8,7 +8,7 @@ use crate::events::EventType;
8
8
use crate :: quota:: {
9
9
QUOTA_ERROR_THRESHOLD_PERCENTAGE , QUOTA_MAX_AGE_SECONDS , QUOTA_WARN_THRESHOLD_PERCENTAGE ,
10
10
} ;
11
- use crate :: { config:: Config , dc_tools, scheduler:: Scheduler } ;
11
+ use crate :: { config:: Config , dc_tools, scheduler:: Scheduler , stock_str } ;
12
12
use crate :: { context:: Context , log:: LogExt } ;
13
13
use anyhow:: { anyhow, Result } ;
14
14
use humansize:: { file_size_opts, FileSize } ;
@@ -73,33 +73,33 @@ impl DetailedConnectivity {
73
73
}
74
74
}
75
75
76
- fn to_string_imap ( & self , _context : & Context ) -> String {
76
+ async fn to_string_imap ( & self , context : & Context ) -> String {
77
77
match self {
78
- DetailedConnectivity :: Error ( e) => format ! ( "Error: {}" , e) ,
78
+ DetailedConnectivity :: Error ( e) => stock_str :: error ( context , e) . await ,
79
79
DetailedConnectivity :: Uninitialized => "Not started" . to_string ( ) ,
80
- DetailedConnectivity :: Connecting => "Connecting…" . to_string ( ) ,
81
- DetailedConnectivity :: Working => "Getting new messages…" . to_string ( ) ,
80
+ DetailedConnectivity :: Connecting => stock_str :: connecting ( context ) . await ,
81
+ DetailedConnectivity :: Working => stock_str :: updating ( context ) . await ,
82
82
DetailedConnectivity :: InterruptingIdle | DetailedConnectivity :: Connected => {
83
- "Connected" . to_string ( )
83
+ stock_str :: connected ( context ) . await
84
84
}
85
85
DetailedConnectivity :: NotConfigured => "Not configured" . to_string ( ) ,
86
86
}
87
87
}
88
88
89
- fn to_string_smtp ( & self , _context : & Context ) -> String {
89
+ async fn to_string_smtp ( & self , context : & Context ) -> String {
90
90
match self {
91
- DetailedConnectivity :: Error ( e) => format ! ( "Error: {}" , e) ,
91
+ DetailedConnectivity :: Error ( e) => stock_str :: error ( context , e) . await ,
92
92
DetailedConnectivity :: Uninitialized => {
93
- "( You did not try to send a message recently) " . to_string ( )
93
+ "You did not try to send a message recently. " . to_string ( )
94
94
}
95
- DetailedConnectivity :: Connecting => "Connecting…" . to_string ( ) ,
96
- DetailedConnectivity :: Working => "Sending…" . to_string ( ) ,
95
+ DetailedConnectivity :: Connecting => stock_str :: connecting ( context ) . await ,
96
+ DetailedConnectivity :: Working => stock_str :: sending ( context ) . await ,
97
97
98
98
// We don't know any more than that the last message was sent successfully;
99
99
// since sending the last message, connectivity could have changed, which we don't notice
100
100
// until another message is sent
101
101
DetailedConnectivity :: InterruptingIdle | DetailedConnectivity :: Connected => {
102
- "Your last message was sent successfully" . to_string ( )
102
+ stock_str :: last_msg_sent_successfully ( context ) . await
103
103
}
104
104
DetailedConnectivity :: NotConfigured => "Not configured" . to_string ( ) ,
105
105
}
@@ -251,7 +251,7 @@ impl Context {
251
251
/// One of:
252
252
/// - DC_CONNECTIVITY_NOT_CONNECTED (1000-1999): Show e.g. the string "Not connected" or a red dot
253
253
/// - DC_CONNECTIVITY_CONNECTING (2000-2999): Show e.g. the string "Connecting…" or a yellow dot
254
- /// - DC_CONNECTIVITY_WORKING (3000-3999): Show e.g. the string "Getting new messages " or a spinning wheel
254
+ /// - DC_CONNECTIVITY_WORKING (3000-3999): Show e.g. the string "Updating… " or a spinning wheel
255
255
/// - DC_CONNECTIVITY_CONNECTED (>=4000): Show e.g. the string "Connected" or a green dot
256
256
///
257
257
/// We don't use exact values but ranges here so that we can split up
@@ -380,7 +380,7 @@ impl Context {
380
380
} ;
381
381
drop ( lock) ;
382
382
383
- ret += "<h3>Incoming messages </h3><ul>" ;
383
+ ret += & format ! ( "<h3>{} </h3><ul>" , stock_str :: incoming_messages ( self ) . await ) ;
384
384
for ( folder, watch, state) in & folders_states {
385
385
let w = self . get_config ( * watch) . await . ok_or_log ( self ) ;
386
386
@@ -395,7 +395,7 @@ impl Context {
395
395
ret += " <b>" ;
396
396
ret += & * escaper:: encode_minimal ( & foldername) ;
397
397
ret += ":</b> " ;
398
- ret += & * escaper:: encode_minimal ( & * detailed. to_string_imap ( self ) ) ;
398
+ ret += & * escaper:: encode_minimal ( & * detailed. to_string_imap ( self ) . await ) ;
399
399
ret += "</li>" ;
400
400
401
401
folder_added = true ;
@@ -410,18 +410,21 @@ impl Context {
410
410
ret += "<li>" ;
411
411
ret += & * detailed. to_icon ( ) ;
412
412
ret += " " ;
413
- ret += & * escaper:: encode_minimal ( & detailed. to_string_imap ( self ) ) ;
413
+ ret += & * escaper:: encode_minimal ( & detailed. to_string_imap ( self ) . await ) ;
414
414
ret += "</li>" ;
415
415
}
416
416
}
417
417
}
418
418
ret += "</ul>" ;
419
419
420
- ret += "<h3>Outgoing messages</h3><ul><li>" ;
420
+ ret += & format ! (
421
+ "<h3>{}</h3><ul><li>" ,
422
+ stock_str:: outgoing_messages( self ) . await
423
+ ) ;
421
424
let detailed = smtp. get_detailed ( ) . await ;
422
425
ret += & * detailed. to_icon ( ) ;
423
426
ret += " " ;
424
- ret += & * escaper:: encode_minimal ( & detailed. to_string_smtp ( self ) ) ;
427
+ ret += & * escaper:: encode_minimal ( & detailed. to_string_smtp ( self ) . await ) ;
425
428
ret += "</li></ul>" ;
426
429
427
430
let domain = dc_tools:: EmailAddress :: new (
@@ -431,7 +434,10 @@ impl Context {
431
434
. unwrap_or_default ( ) ,
432
435
) ?
433
436
. domain ;
434
- ret += & format ! ( "<h3>Storage on {}</h3><ul>" , domain) ;
437
+ ret += & format ! (
438
+ "<h3>{}</h3><ul>" ,
439
+ stock_str:: storage_on_domain( self , domain) . await
440
+ ) ;
435
441
let quota = self . quota . read ( ) . await ;
436
442
if let Some ( quota) = & * quota {
437
443
match & quota. recent {
@@ -462,7 +468,8 @@ impl Context {
462
468
}
463
469
Message => {
464
470
format ! (
465
- "<b>Messages:</b> {} of {} used" ,
471
+ "<b>{}:</b> {} of {} used" ,
472
+ stock_str:: messages( self ) . await ,
466
473
resource. usage. to_string( ) ,
467
474
resource. limit. to_string( ) ,
468
475
)
@@ -507,7 +514,7 @@ impl Context {
507
514
self . schedule_quota_update ( ) . await ?;
508
515
}
509
516
} else {
510
- ret += "<li>One moment... </li>" ;
517
+ ret += & format ! ( "<li>{} </li>" , stock_str :: one_moment ( self ) . await ) ;
511
518
self . schedule_quota_update ( ) . await ?;
512
519
}
513
520
ret += "</ul>" ;
0 commit comments