use super::*;
pub mod rejection {
pub const TARGET_POLICY_MISMATCH: &str = "turnframe.target.policy_mismatch";
pub const TARGET_UNAUTHORIZED: &str = "turnframe.target.unauthorized";
pub const TARGET_MISSING: &str = "turnframe.target.missing";
pub const TARGET_STALE: &str = "turnframe.target.stale";
pub const TARGET_UNRESOLVED: &str = "turnframe.target.unresolved";
pub const TARGET_TOO_MANY_CANDIDATES: &str = "turnframe.target.too_many_candidates";
pub const NO_ACTIVE_INTERACTION: &str = "turnframe.interaction.none_active";
pub const TEXT_RESOLUTION_NOT_ALLOWED: &str =
"turnframe.interaction.text_resolution_not_allowed";
pub const UNKNOWN_OPTION: &str = "turnframe.interaction.unknown_option";
pub const UNKNOWN_WORKFLOW: &str = "turnframe.workflow.unknown";
pub use turnframe_core::error::UNKNOWN_OPERATION;
pub const INVALID_ARGUMENTS: &str = "turnframe.operation.invalid_arguments";
pub const NOT_PROPOSABLE: &str = "turnframe.operation.not_proposable";
pub const PRECONDITION_UNMET: &str = "turnframe.workflow.precondition_unmet";
pub const SEVERAL_OPEN_CASES: &str = "turnframe.workflow.several_open_cases";
pub const BLOCKED_BY_CONSTRAINT: &str = "turnframe.constraint.blocked";
pub const BLOCKED_BY_MODE: &str = "turnframe.policy.blocked_by_mode";
pub const FORBIDDEN_RISK_CLASS: &str = "turnframe.policy.forbidden_risk_class";
pub const HUMAN_REVIEW_REQUIRED: &str = "turnframe.policy.human_review_required";
pub const PREREQUISITE_NOT_DONE: &str = "turnframe.operation.prerequisite_not_done";
}
pub mod notice {
pub const NOTHING_SUBMITTED: &str = "turnframe.notice.nothing_submitted";
pub const NOTHING_DELETED: &str = "turnframe.notice.nothing_deleted";
pub const DRAFT_ONLY: &str = "turnframe.notice.draft_only";
pub const NO_EXTERNAL_EFFECTS: &str = "turnframe.notice.no_external_effects";
pub const PARTIAL_RESULT: &str = "turnframe.notice.partial_result";
pub const ACT_REFUSED: &str = "turnframe.notice.act_refused";
pub const VALUE_ASKED_AGAIN: &str = "turnframe.notice.value_asked_again";
pub const ATTACHMENT_NOT_SHOWN: &str = "turnframe.notice.attachment_not_shown";
pub const ALREADY_ANSWERED: &str = "turnframe.notice.already_answered";
pub const NOT_UNDERSTOOD: &str = "turnframe.notice.not_understood";
pub const MESSAGE_UNREADABLE: &str = "turnframe.notice.message_unreadable";
pub const KEPT_UNCHANGED: &str = "turnframe.notice.kept_unchanged";
}
pub const CONDITION_HOLDS_ANSWER: &str = "turnframe.condition_holds";
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct NoticeCopy {
pub nothing_submitted: LocalizedText,
pub nothing_deleted: LocalizedText,
pub draft_only: LocalizedText,
pub no_external_effects: LocalizedText,
pub partial_result: LocalizedText,
pub select_target_title: LocalizedText,
pub select_target_cancel: LocalizedText,
pub condition_title: LocalizedText,
pub condition_yes: LocalizedText,
pub condition_no: LocalizedText,
pub act_refused: LocalizedText,
pub target_policy_mismatch: LocalizedText,
pub target_unauthorized: LocalizedText,
pub target_missing: LocalizedText,
pub target_stale: LocalizedText,
pub target_unresolved: LocalizedText,
pub target_too_many_candidates: LocalizedText,
pub several_open_cases: LocalizedText,
pub no_active_interaction: LocalizedText,
pub text_resolution_not_allowed: LocalizedText,
pub unknown_option: LocalizedText,
pub unknown_workflow: LocalizedText,
pub unknown_operation: LocalizedText,
pub already_answered_running: LocalizedText,
pub already_answered_done: LocalizedText,
pub already_answered_failed: LocalizedText,
pub already_answered_closed: LocalizedText,
pub invalid_arguments: LocalizedText,
pub not_proposable: LocalizedText,
pub blocked_by_mode: LocalizedText,
pub forbidden_risk_class: LocalizedText,
pub human_review_required: LocalizedText,
pub prerequisite_not_done: LocalizedText,
pub record_not_found: LocalizedText,
pub record_not_found_yet: LocalizedText,
pub record_not_unique: LocalizedText,
pub not_understood: LocalizedText,
pub message_unreadable: LocalizedText,
pub kept_unchanged: LocalizedText,
}
impl NoticeCopy {
#[must_use]
pub fn standard() -> Self {
crate::copy::ServerCopy::translated(Self::english(), "it", ITALIAN)
}
#[must_use]
pub fn english() -> Self {
Self {
nothing_submitted: LocalizedText::new("Nothing has been submitted."),
nothing_deleted: LocalizedText::new("Nothing has been deleted."),
draft_only: LocalizedText::new("Everything stayed a draft."),
no_external_effects: LocalizedText::new("No external effect was attempted."),
partial_result: LocalizedText::new("Part of this turn still needs your input."),
select_target_title: LocalizedText::new("Which one did you mean?"),
select_target_cancel: LocalizedText::new("None of these"),
condition_title: LocalizedText::new("Does that condition hold?"),
condition_yes: LocalizedText::new("Yes, apply it"),
condition_no: LocalizedText::new("No, leave it"),
act_refused: LocalizedText::new("One of the things you asked for could not be done."),
target_policy_mismatch: LocalizedText::new(
"I could not tell which record that was meant to change.",
),
target_unauthorized: LocalizedText::new(
"That record is not one you can reach from here.",
),
target_missing: LocalizedText::new("I could not find the record you meant."),
target_stale: LocalizedText::new(
"That record changed while we were talking, so I did not write over it.",
),
target_unresolved: LocalizedText::new(
"I could not tell which record you meant, so I wrote nothing.",
),
target_too_many_candidates: LocalizedText::new(
"Too many records match that description for me to pick one.",
),
several_open_cases: LocalizedText::new(
"You have more than one of those open already, so I did not start another. \
Tell me which one you mean.",
),
no_active_interaction: LocalizedText::new(
"There is no question on screen for that answer.",
),
text_resolution_not_allowed: LocalizedText::new(
"That one has to be answered with the buttons rather than in writing.",
),
unknown_option: LocalizedText::new("That is not one of the choices on offer."),
unknown_workflow: LocalizedText::new("That is not something this assistant handles."),
unknown_operation: LocalizedText::new("That is not something I can do here."),
already_answered_running: LocalizedText::new(
"I am still working on that one: no need to press it again.",
),
already_answered_done: LocalizedText::new("That one is already done."),
already_answered_failed: LocalizedText::new(
"That one did not go through, so nothing was changed by it.",
),
already_answered_closed: LocalizedText::new("That one is no longer open."),
invalid_arguments: LocalizedText::new(
"I did not have what that needed, so I did not do it.",
),
not_proposable: LocalizedText::new(
"That one only happens when you press the button for it.",
),
blocked_by_mode: LocalizedText::new("I am not set up to do that here."),
forbidden_risk_class: LocalizedText::new("I am not allowed to do that at all."),
human_review_required: LocalizedText::new("Someone else has to approve that one."),
prerequisite_not_done: LocalizedText::new(
"That depended on something else you asked for, which did not happen.",
),
record_not_found: LocalizedText::new("There is no {workflow} called «{named}»."),
record_not_found_yet: LocalizedText::new(
"There is no {workflow} called «{named}» yet: I can register it, or you can name another.",
),
record_not_unique: LocalizedText::new("More than one {workflow} is called «{named}»."),
not_understood: LocalizedText::new("I did not understand this part: «{words}»."),
message_unreadable: LocalizedText::new(
"I could not make sense of that message, so I did nothing with it. \
Could you say it another way?",
),
kept_unchanged: LocalizedText::new("Left as it is, as you asked: «{words}»."),
}
}
#[must_use]
pub fn already_answered(&self, progress: AnswerProgress) -> &LocalizedText {
match progress {
AnswerProgress::Running => &self.already_answered_running,
AnswerProgress::Done => &self.already_answered_done,
AnswerProgress::Failed => &self.already_answered_failed,
AnswerProgress::Closed | _ => &self.already_answered_closed,
}
}
#[must_use]
pub fn runtime_refusal(&self, code: &str) -> Option<(&'static str, &LocalizedText)> {
let found = match code {
rejection::TARGET_POLICY_MISMATCH => (
rejection::TARGET_POLICY_MISMATCH,
&self.target_policy_mismatch,
),
rejection::TARGET_UNAUTHORIZED => {
(rejection::TARGET_UNAUTHORIZED, &self.target_unauthorized)
}
rejection::TARGET_MISSING => (rejection::TARGET_MISSING, &self.target_missing),
rejection::TARGET_STALE => (rejection::TARGET_STALE, &self.target_stale),
rejection::TARGET_UNRESOLVED => (rejection::TARGET_UNRESOLVED, &self.target_unresolved),
rejection::TARGET_TOO_MANY_CANDIDATES => (
rejection::TARGET_TOO_MANY_CANDIDATES,
&self.target_too_many_candidates,
),
rejection::SEVERAL_OPEN_CASES => {
(rejection::SEVERAL_OPEN_CASES, &self.several_open_cases)
}
rejection::NO_ACTIVE_INTERACTION => (
rejection::NO_ACTIVE_INTERACTION,
&self.no_active_interaction,
),
rejection::TEXT_RESOLUTION_NOT_ALLOWED => (
rejection::TEXT_RESOLUTION_NOT_ALLOWED,
&self.text_resolution_not_allowed,
),
rejection::UNKNOWN_OPTION => (rejection::UNKNOWN_OPTION, &self.unknown_option),
rejection::UNKNOWN_WORKFLOW => (rejection::UNKNOWN_WORKFLOW, &self.unknown_workflow),
rejection::UNKNOWN_OPERATION => (rejection::UNKNOWN_OPERATION, &self.unknown_operation),
rejection::INVALID_ARGUMENTS => (rejection::INVALID_ARGUMENTS, &self.invalid_arguments),
rejection::NOT_PROPOSABLE => (rejection::NOT_PROPOSABLE, &self.not_proposable),
rejection::BLOCKED_BY_MODE => (rejection::BLOCKED_BY_MODE, &self.blocked_by_mode),
rejection::FORBIDDEN_RISK_CLASS => {
(rejection::FORBIDDEN_RISK_CLASS, &self.forbidden_risk_class)
}
rejection::HUMAN_REVIEW_REQUIRED => (
rejection::HUMAN_REVIEW_REQUIRED,
&self.human_review_required,
),
rejection::PREREQUISITE_NOT_DONE => (
rejection::PREREQUISITE_NOT_DONE,
&self.prerequisite_not_done,
),
_ => return None,
};
Some(found)
}
}
impl Default for NoticeCopy {
fn default() -> Self {
Self::standard()
}
}
crate::copy::server_copy!(
NoticeCopy,
[
nothing_submitted,
nothing_deleted,
draft_only,
no_external_effects,
partial_result,
select_target_title,
select_target_cancel,
condition_title,
condition_yes,
condition_no,
act_refused,
target_policy_mismatch,
target_unauthorized,
target_missing,
target_stale,
target_unresolved,
target_too_many_candidates,
several_open_cases,
no_active_interaction,
text_resolution_not_allowed,
unknown_option,
unknown_workflow,
unknown_operation,
already_answered_running,
already_answered_done,
already_answered_failed,
already_answered_closed,
invalid_arguments,
not_proposable,
blocked_by_mode,
forbidden_risk_class,
human_review_required,
prerequisite_not_done,
record_not_found,
record_not_found_yet,
record_not_unique,
not_understood,
message_unreadable,
kept_unchanged
]
);
const ITALIAN: &[(&str, &str)] = &[
("nothing_submitted", "Non è stato inviato nulla."),
("nothing_deleted", "Non è stato eliminato nulla."),
("draft_only", "È rimasto tutto in bozza."),
(
"no_external_effects",
"Non è stata tentata nessuna operazione verso l'esterno.",
),
(
"partial_result",
"Una parte di questa richiesta aspetta ancora una tua risposta.",
),
("select_target_title", "Quale intendevi?"),
("select_target_cancel", "Nessuno di questi"),
("condition_title", "Quella condizione vale?"),
("condition_yes", "Sì, applicala"),
("condition_no", "No, lascia stare"),
(
"act_refused",
"Una delle cose che hai chiesto non si è potuta fare.",
),
(
"target_policy_mismatch",
"Non ho capito quale scheda andava modificata.",
),
(
"target_unauthorized",
"Da qui non puoi accedere a quella scheda.",
),
("target_missing", "Non ho trovato la scheda che intendevi."),
(
"target_stale",
"Quella scheda è cambiata mentre parlavamo, quindi non l'ho sovrascritta.",
),
(
"target_unresolved",
"Non ho capito quale scheda intendevi, quindi non ho scritto nulla.",
),
(
"target_too_many_candidates",
"Troppe schede corrispondono a quella descrizione perché possa sceglierne una.",
),
(
"several_open_cases",
"Ce n'è già più di una aperta, quindi non ne ho aperta un'altra. Dimmi quale intendi.",
),
(
"no_active_interaction",
"Non c'è nessuna domanda sullo schermo a cui rispondere così.",
),
(
"text_resolution_not_allowed",
"A questa si risponde con i pulsanti, non per iscritto.",
),
("unknown_option", "Non è una delle scelte disponibili."),
("unknown_workflow", "Questo assistente non se ne occupa."),
("unknown_operation", "Qui non posso farlo."),
(
"already_answered_running",
"Ci sto ancora lavorando: non serve premerlo di nuovo.",
),
("already_answered_done", "È già fatto."),
(
"already_answered_failed",
"Non è andato a buon fine, quindi non ha cambiato nulla.",
),
("already_answered_closed", "Non è più aperto."),
(
"invalid_arguments",
"Mancava quello che serviva, quindi non l'ho fatto.",
),
(
"not_proposable",
"Succede solo quando premi il pulsante apposito.",
),
("blocked_by_mode", "Qui non sono configurato per farlo."),
(
"forbidden_risk_class",
"Non mi è permesso farlo in nessun caso.",
),
("human_review_required", "Deve approvarlo qualcun altro."),
(
"prerequisite_not_done",
"Dipendeva da un'altra cosa che hai chiesto, che non è stata fatta.",
),
("record_not_found", "Non trovo «{named}» come {workflow}."),
(
"record_not_found_yet",
"Non trovo ancora «{named}» come {workflow}: posso registrarlo io, oppure puoi indicare un altro nome.",
),
(
"record_not_unique",
"Per «{named}» come {workflow} trovo più di un risultato.",
),
("not_understood", "Non ho capito questa parte: «{words}»."),
(
"message_unreadable",
"Non ho capito il messaggio, quindi non ho fatto nulla. Puoi dirlo in un altro modo?",
),
(
"kept_unchanged",
"Lasciato com'è, come mi hai chiesto: «{words}».",
),
];