mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 04:46:29 +03:00
make string 123 MiB of 456 MiB used translatable (#2723)
This commit is contained in:
@@ -6020,6 +6020,11 @@ void dc_event_unref(dc_event_t* event);
|
|||||||
/// Used as the default name for broadcast lists; a number may be added.
|
/// Used as the default name for broadcast lists; a number may be added.
|
||||||
#define DC_STR_BROADCAST_LIST 115
|
#define DC_STR_BROADCAST_LIST 115
|
||||||
|
|
||||||
|
/// "%1$s of %2$s used"
|
||||||
|
///
|
||||||
|
/// Used for describing resource usage, resulting string will be eg. "1.2 GiB of 3 GiB used".
|
||||||
|
#define DC_STR_PART_OF_TOTAL_USED 116
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -460,18 +460,26 @@ impl Context {
|
|||||||
ret += &match &resource.name {
|
ret += &match &resource.name {
|
||||||
Atom(resource_name) => {
|
Atom(resource_name) => {
|
||||||
format!(
|
format!(
|
||||||
"<b>{}:</b> {} of {} used",
|
"<b>{}:</b> {}",
|
||||||
&*escaper::encode_minimal(resource_name),
|
&*escaper::encode_minimal(resource_name),
|
||||||
resource.usage.to_string(),
|
stock_str::part_of_total_used(
|
||||||
resource.limit.to_string(),
|
self,
|
||||||
|
resource.usage.to_string(),
|
||||||
|
resource.limit.to_string()
|
||||||
|
)
|
||||||
|
.await,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Message => {
|
Message => {
|
||||||
format!(
|
format!(
|
||||||
"<b>{}:</b> {} of {} used",
|
"<b>{}:</b> {}",
|
||||||
stock_str::messages(self).await,
|
stock_str::messages(self).await,
|
||||||
resource.usage.to_string(),
|
stock_str::part_of_total_used(
|
||||||
resource.limit.to_string(),
|
self,
|
||||||
|
resource.usage.to_string(),
|
||||||
|
resource.limit.to_string()
|
||||||
|
)
|
||||||
|
.await,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Storage => {
|
Storage => {
|
||||||
@@ -487,7 +495,7 @@ impl Context {
|
|||||||
let limit = (resource.limit * 1024)
|
let limit = (resource.limit * 1024)
|
||||||
.file_size(file_size_opts::BINARY)
|
.file_size(file_size_opts::BINARY)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
format!("{} of {} used", usage, limit)
|
stock_str::part_of_total_used(self, usage, limit).await
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -314,6 +314,9 @@ pub enum StockMessage {
|
|||||||
|
|
||||||
#[strum(props(fallback = "Broadcast List"))]
|
#[strum(props(fallback = "Broadcast List"))]
|
||||||
BroadcastList = 115,
|
BroadcastList = 115,
|
||||||
|
|
||||||
|
#[strum(props(fallback = "%1$s of %2$s used"))]
|
||||||
|
PartOfTotallUsed = 116,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StockMessage {
|
impl StockMessage {
|
||||||
@@ -988,6 +991,18 @@ pub(crate) async fn messages(context: &Context) -> String {
|
|||||||
translated(context, StockMessage::Messages).await
|
translated(context, StockMessage::Messages).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Stock string: `%1$s of %2$s used`.
|
||||||
|
pub(crate) async fn part_of_total_used(
|
||||||
|
context: &Context,
|
||||||
|
part: impl AsRef<str>,
|
||||||
|
total: impl AsRef<str>,
|
||||||
|
) -> String {
|
||||||
|
translated(context, StockMessage::PartOfTotallUsed)
|
||||||
|
.await
|
||||||
|
.replace1(part)
|
||||||
|
.replace2(total)
|
||||||
|
}
|
||||||
|
|
||||||
/// Stock string: `Broadcast List`.
|
/// Stock string: `Broadcast List`.
|
||||||
/// Used as the default name for broadcast lists; a number may be added.
|
/// Used as the default name for broadcast lists; a number may be added.
|
||||||
pub(crate) async fn broadcast_list(context: &Context) -> String {
|
pub(crate) async fn broadcast_list(context: &Context) -> String {
|
||||||
|
|||||||
Reference in New Issue
Block a user