Localize service-module messages via t! and add French translations (partial)
This commit is contained in:
parent
d207c3d60d
commit
b28bd2777f
5 changed files with 408 additions and 29 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use echo_api::{NetView, Sender, ServiceCtx, Store};
|
||||
use echo_api::{t, NetView, Sender, ServiceCtx, Store};
|
||||
|
||||
// A channel with this many ops isn't opless and needs no fix.
|
||||
const OP_THRESHOLD: usize = 3;
|
||||
|
|
@ -16,17 +16,17 @@ pub fn handle(me: &str, from: &Sender, chan: Option<&str>, ctx: &mut ServiceCtx,
|
|||
};
|
||||
// Defer to ChanServ for anything it owns.
|
||||
if db.channel(chan).is_some() {
|
||||
ctx.notice(me, from.uid, format!("\x02{chan}\x02 is registered — use \x02ChanServ\x02 to manage it."));
|
||||
ctx.notice(me, from.uid, t!(ctx, "\x02{chan}\x02 is registered — use \x02ChanServ\x02 to manage it.", chan = chan));
|
||||
return;
|
||||
}
|
||||
if net.op_count(chan) >= OP_THRESHOLD {
|
||||
ctx.notice(me, from.uid, format!("\x02{chan}\x02 already has ops — nothing to fix."));
|
||||
ctx.notice(me, from.uid, t!(ctx, "\x02{chan}\x02 already has ops — nothing to fix.", chan = chan));
|
||||
return;
|
||||
}
|
||||
let scores = net.chanfix_scores(chan);
|
||||
let highscore = scores.first().map(|(_, s)| *s).unwrap_or(0);
|
||||
if highscore < MIN_FIX_SCORE {
|
||||
ctx.notice(me, from.uid, format!("\x02{chan}\x02 doesn't have enough op-time history to fix yet."));
|
||||
ctx.notice(me, from.uid, t!(ctx, "\x02{chan}\x02 doesn't have enough op-time history to fix yet.", chan = chan));
|
||||
return;
|
||||
}
|
||||
let threshold = ((highscore as f64 * FIX_STEP) as u32).max(1);
|
||||
|
|
@ -47,8 +47,8 @@ pub fn handle(me: &str, from: &Sender, chan: Option<&str>, ctx: &mut ServiceCtx,
|
|||
}
|
||||
}
|
||||
if opped == 0 {
|
||||
ctx.notice(me, from.uid, format!("None of \x02{chan}\x02's trusted regulars are here right now."));
|
||||
ctx.notice(me, from.uid, t!(ctx, "None of \x02{chan}\x02's trusted regulars are here right now.", chan = chan));
|
||||
} else {
|
||||
ctx.notice(me, from.uid, format!("Reopped \x02{opped}\x02 trusted regular(s) in \x02{chan}\x02."));
|
||||
ctx.notice(me, from.uid, t!(ctx, "Reopped \x02{opped}\x02 trusted regular(s) in \x02{chan}\x02.", opped = opped, chan = chan));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
//! SCORES <#channel> shows the standings; CHANFIX <#channel> performs the fix.
|
||||
//! `lib.rs` holds the dispatcher; each command lives in its own file.
|
||||
|
||||
use echo_api::{HelpEntry, NetView, Sender, Service, ServiceCtx, Store};
|
||||
use echo_api::{t, HelpEntry, NetView, Sender, Service, ServiceCtx, Store};
|
||||
|
||||
#[path = "scores.rs"]
|
||||
mod scores;
|
||||
|
|
@ -58,7 +58,7 @@ impl Service for ChanFix {
|
|||
Some("SCORES") => scores::handle(me, from, args.get(1).copied(), ctx, net),
|
||||
Some("CHANFIX") | Some("FIX") => fix::handle(me, from, args.get(1).copied(), ctx, net, db),
|
||||
Some("HELP") | None => echo_api::help(me, from, ctx, BLURB, TOPICS, args.get(1).copied()),
|
||||
Some(other) => ctx.notice(me, from.uid, format!("I don't know \x02{other}\x02. Try \x02SCORES\x02 or \x02CHANFIX\x02 <#channel>.")),
|
||||
Some(other) => ctx.notice(me, from.uid, t!(ctx, "I don't know \x02{other}\x02. Try \x02SCORES\x02 or \x02CHANFIX\x02 <#channel>.", other = other)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use echo_api::{NetView, Sender, ServiceCtx};
|
||||
use echo_api::{t, NetView, Sender, ServiceCtx};
|
||||
|
||||
// SCORES <#channel>: show the op-time standings ChanFix would reop from.
|
||||
pub fn handle(me: &str, from: &Sender, chan: Option<&str>, ctx: &mut ServiceCtx, net: &dyn NetView) {
|
||||
|
|
@ -8,11 +8,11 @@ pub fn handle(me: &str, from: &Sender, chan: Option<&str>, ctx: &mut ServiceCtx,
|
|||
};
|
||||
let scores = net.chanfix_scores(chan);
|
||||
if scores.is_empty() {
|
||||
ctx.notice(me, from.uid, format!("No op-time recorded for \x02{chan}\x02 yet."));
|
||||
ctx.notice(me, from.uid, t!(ctx, "No op-time recorded for \x02{chan}\x02 yet.", chan = chan));
|
||||
return;
|
||||
}
|
||||
for (id, score) in scores.iter().take(15) {
|
||||
ctx.notice(me, from.uid, format!(" \x02{score}\x02 {id}"));
|
||||
ctx.notice(me, from.uid, t!(ctx, " \x02{score}\x02 {id}", score = score, id = id));
|
||||
}
|
||||
ctx.notice(me, from.uid, format!("Top {} of {} scored identit{} for \x02{chan}\x02.", scores.len().min(15), scores.len(), if scores.len() == 1 { "y" } else { "ies" }));
|
||||
ctx.notice(me, from.uid, t!(ctx, "Top {shown} of {total} scored identit{suffix} for \x02{chan}\x02.", shown = scores.len().min(15), total = scores.len(), suffix = if scores.len() == 1 { "y" } else { "ies" }, chan = chan));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue