1use super::*;
4
5pub mod rejection {
10 pub const TARGET_POLICY_MISMATCH: &str = "turnframe.target.policy_mismatch";
12 pub const TARGET_UNAUTHORIZED: &str = "turnframe.target.unauthorized";
14 pub const TARGET_MISSING: &str = "turnframe.target.missing";
16 pub const TARGET_STALE: &str = "turnframe.target.stale";
18 pub const TARGET_UNRESOLVED: &str = "turnframe.target.unresolved";
20 pub const TARGET_TOO_MANY_CANDIDATES: &str = "turnframe.target.too_many_candidates";
22 pub const NO_ACTIVE_INTERACTION: &str = "turnframe.interaction.none_active";
24 pub const TEXT_RESOLUTION_NOT_ALLOWED: &str =
26 "turnframe.interaction.text_resolution_not_allowed";
27 pub const UNKNOWN_OPTION: &str = "turnframe.interaction.unknown_option";
29 pub const UNKNOWN_WORKFLOW: &str = "turnframe.workflow.unknown";
31 pub use turnframe_core::error::UNKNOWN_OPERATION;
38 pub const INVALID_ARGUMENTS: &str = "turnframe.operation.invalid_arguments";
40 pub const NOT_PROPOSABLE: &str = "turnframe.operation.not_proposable";
42 pub const PRECONDITION_UNMET: &str = "turnframe.workflow.precondition_unmet";
45 pub const SEVERAL_OPEN_CASES: &str = "turnframe.workflow.several_open_cases";
48 pub const BLOCKED_BY_CONSTRAINT: &str = "turnframe.constraint.blocked";
50 pub const BLOCKED_BY_MODE: &str = "turnframe.policy.blocked_by_mode";
52 pub const FORBIDDEN_RISK_CLASS: &str = "turnframe.policy.forbidden_risk_class";
54 pub const HUMAN_REVIEW_REQUIRED: &str = "turnframe.policy.human_review_required";
56 pub const PREREQUISITE_NOT_DONE: &str = "turnframe.operation.prerequisite_not_done";
58}
59
60pub mod notice {
62 pub const NOTHING_SUBMITTED: &str = "turnframe.notice.nothing_submitted";
64 pub const NOTHING_DELETED: &str = "turnframe.notice.nothing_deleted";
66 pub const DRAFT_ONLY: &str = "turnframe.notice.draft_only";
68 pub const NO_EXTERNAL_EFFECTS: &str = "turnframe.notice.no_external_effects";
70 pub const PARTIAL_RESULT: &str = "turnframe.notice.partial_result";
72 pub const ACT_REFUSED: &str = "turnframe.notice.act_refused";
74 pub const VALUE_ASKED_AGAIN: &str = "turnframe.notice.value_asked_again";
76 pub const RECORD_NONE_YET: &str = "turnframe.notice.record_none_yet";
78 pub const ATTACHMENT_NOT_SHOWN: &str = "turnframe.notice.attachment_not_shown";
80 pub const ALREADY_ANSWERED: &str = "turnframe.notice.already_answered";
82 pub const NOT_UNDERSTOOD: &str = "turnframe.notice.not_understood";
84 pub const MESSAGE_UNREADABLE: &str = "turnframe.notice.message_unreadable";
86 pub const KEPT_UNCHANGED: &str = "turnframe.notice.kept_unchanged";
88}
89
90pub const CONDITION_HOLDS_ANSWER: &str = "turnframe.condition_holds";
93
94#[derive(Debug, Clone, PartialEq, Eq)]
96#[non_exhaustive]
97pub struct NoticeCopy {
98 pub nothing_submitted: LocalizedText,
100 pub nothing_deleted: LocalizedText,
102 pub draft_only: LocalizedText,
104 pub no_external_effects: LocalizedText,
106 pub partial_result: LocalizedText,
108 pub select_target_title: LocalizedText,
110 pub select_target_cancel: LocalizedText,
112 pub condition_title: LocalizedText,
114 pub condition_yes: LocalizedText,
116 pub condition_no: LocalizedText,
118 pub act_refused: LocalizedText,
123 pub target_policy_mismatch: LocalizedText,
125 pub target_unauthorized: LocalizedText,
127 pub target_missing: LocalizedText,
129 pub target_stale: LocalizedText,
131 pub target_unresolved: LocalizedText,
133 pub target_too_many_candidates: LocalizedText,
135 pub several_open_cases: LocalizedText,
137 pub no_active_interaction: LocalizedText,
139 pub text_resolution_not_allowed: LocalizedText,
141 pub unknown_option: LocalizedText,
143 pub unknown_workflow: LocalizedText,
145 pub unknown_operation: LocalizedText,
147 pub already_answered_running: LocalizedText,
149 pub already_answered_done: LocalizedText,
151 pub already_answered_failed: LocalizedText,
153 pub already_answered_closed: LocalizedText,
156 pub invalid_arguments: LocalizedText,
158 pub not_proposable: LocalizedText,
160 pub blocked_by_mode: LocalizedText,
162 pub forbidden_risk_class: LocalizedText,
164 pub human_review_required: LocalizedText,
166 pub prerequisite_not_done: LocalizedText,
168 pub record_not_found: LocalizedText,
171 pub record_not_found_yet: LocalizedText,
173 pub record_not_unique: LocalizedText,
175 pub record_none_yet: LocalizedText,
178 pub record_none: LocalizedText,
180 pub not_understood: LocalizedText,
182 pub message_unreadable: LocalizedText,
184 pub kept_unchanged: LocalizedText,
186}
187
188impl NoticeCopy {
189 #[must_use]
191 pub fn standard() -> Self {
192 crate::copy::ServerCopy::translated(Self::english(), "it", ITALIAN)
193 }
194
195 #[must_use]
197 pub fn english() -> Self {
198 Self {
199 nothing_submitted: LocalizedText::new("Nothing has been submitted."),
200 nothing_deleted: LocalizedText::new("Nothing has been deleted."),
201 draft_only: LocalizedText::new("Everything stayed a draft."),
202 no_external_effects: LocalizedText::new("No external effect was attempted."),
203 partial_result: LocalizedText::new("Part of this turn still needs your input."),
204 select_target_title: LocalizedText::new("Which one did you mean?"),
205 select_target_cancel: LocalizedText::new("None of these"),
206 condition_title: LocalizedText::new("Does that condition hold?"),
207 condition_yes: LocalizedText::new("Yes, apply it"),
208 condition_no: LocalizedText::new("No, leave it"),
209 act_refused: LocalizedText::new("One of the things you asked for could not be done."),
210 target_policy_mismatch: LocalizedText::new(
211 "I could not tell which record that was meant to change.",
212 ),
213 target_unauthorized: LocalizedText::new(
214 "That record is not one you can reach from here.",
215 ),
216 target_missing: LocalizedText::new("I could not find the record you meant."),
217 target_stale: LocalizedText::new(
218 "That record changed while we were talking, so I did not write over it.",
219 ),
220 target_unresolved: LocalizedText::new(
221 "I could not tell which record you meant, so I wrote nothing.",
222 ),
223 target_too_many_candidates: LocalizedText::new(
224 "Too many records match that description for me to pick one.",
225 ),
226 several_open_cases: LocalizedText::new(
227 "You have more than one of those open already, so I did not start another. \
228 Tell me which one you mean.",
229 ),
230 no_active_interaction: LocalizedText::new(
231 "There is no question on screen for that answer.",
232 ),
233 text_resolution_not_allowed: LocalizedText::new(
234 "That one has to be answered with the buttons rather than in writing.",
235 ),
236 unknown_option: LocalizedText::new("That is not one of the choices on offer."),
237 unknown_workflow: LocalizedText::new("That is not something this assistant handles."),
238 unknown_operation: LocalizedText::new("That is not something I can do here."),
239 already_answered_running: LocalizedText::new(
240 "I am still working on that one: no need to press it again.",
241 ),
242 already_answered_done: LocalizedText::new("That one is already done."),
243 already_answered_failed: LocalizedText::new(
244 "That one did not go through, so nothing was changed by it.",
245 ),
246 already_answered_closed: LocalizedText::new("That one is no longer open."),
247 invalid_arguments: LocalizedText::new(
248 "I did not have what that needed, so I did not do it.",
249 ),
250 not_proposable: LocalizedText::new(
251 "That one only happens when you press the button for it.",
252 ),
253 blocked_by_mode: LocalizedText::new("I am not set up to do that here."),
254 forbidden_risk_class: LocalizedText::new("I am not allowed to do that at all."),
255 human_review_required: LocalizedText::new("Someone else has to approve that one."),
256 prerequisite_not_done: LocalizedText::new(
257 "That depended on something else you asked for, which did not happen.",
258 ),
259 record_not_found: LocalizedText::new("There is no {workflow} called «{named}»."),
260 record_not_found_yet: LocalizedText::new(
261 "There is no {workflow} called «{named}» yet: I can register it, or you can name another.",
262 ),
263 record_not_unique: LocalizedText::new("More than one {workflow} is called «{named}»."),
264 record_none_yet: LocalizedText::new(
265 "There is no {workflow} yet to do that on: I can open one first.",
266 ),
267 record_none: LocalizedText::new("There is no {workflow} to do that on."),
268 not_understood: LocalizedText::new("I did not understand this part: «{words}»."),
269 message_unreadable: LocalizedText::new(
270 "I could not make sense of that message, so I did nothing with it. \
271 Could you say it another way?",
272 ),
273 kept_unchanged: LocalizedText::new("Left as it is, as you asked: «{words}»."),
274 }
275 }
276
277 #[must_use]
279 pub fn already_answered(&self, progress: AnswerProgress) -> &LocalizedText {
280 match progress {
281 AnswerProgress::Running => &self.already_answered_running,
282 AnswerProgress::Done => &self.already_answered_done,
283 AnswerProgress::Failed => &self.already_answered_failed,
284 AnswerProgress::Closed | _ => &self.already_answered_closed,
287 }
288 }
289
290 #[must_use]
301 pub fn runtime_refusal(&self, code: &str) -> Option<(&'static str, &LocalizedText)> {
302 let found = match code {
303 rejection::TARGET_POLICY_MISMATCH => (
304 rejection::TARGET_POLICY_MISMATCH,
305 &self.target_policy_mismatch,
306 ),
307 rejection::TARGET_UNAUTHORIZED => {
308 (rejection::TARGET_UNAUTHORIZED, &self.target_unauthorized)
309 }
310 rejection::TARGET_MISSING => (rejection::TARGET_MISSING, &self.target_missing),
311 rejection::TARGET_STALE => (rejection::TARGET_STALE, &self.target_stale),
312 rejection::TARGET_UNRESOLVED => (rejection::TARGET_UNRESOLVED, &self.target_unresolved),
313 rejection::TARGET_TOO_MANY_CANDIDATES => (
314 rejection::TARGET_TOO_MANY_CANDIDATES,
315 &self.target_too_many_candidates,
316 ),
317 rejection::SEVERAL_OPEN_CASES => {
318 (rejection::SEVERAL_OPEN_CASES, &self.several_open_cases)
319 }
320 rejection::NO_ACTIVE_INTERACTION => (
321 rejection::NO_ACTIVE_INTERACTION,
322 &self.no_active_interaction,
323 ),
324 rejection::TEXT_RESOLUTION_NOT_ALLOWED => (
325 rejection::TEXT_RESOLUTION_NOT_ALLOWED,
326 &self.text_resolution_not_allowed,
327 ),
328 rejection::UNKNOWN_OPTION => (rejection::UNKNOWN_OPTION, &self.unknown_option),
329 rejection::UNKNOWN_WORKFLOW => (rejection::UNKNOWN_WORKFLOW, &self.unknown_workflow),
330 rejection::UNKNOWN_OPERATION => (rejection::UNKNOWN_OPERATION, &self.unknown_operation),
331 rejection::INVALID_ARGUMENTS => (rejection::INVALID_ARGUMENTS, &self.invalid_arguments),
332 rejection::NOT_PROPOSABLE => (rejection::NOT_PROPOSABLE, &self.not_proposable),
333 rejection::BLOCKED_BY_MODE => (rejection::BLOCKED_BY_MODE, &self.blocked_by_mode),
334 rejection::FORBIDDEN_RISK_CLASS => {
335 (rejection::FORBIDDEN_RISK_CLASS, &self.forbidden_risk_class)
336 }
337 rejection::HUMAN_REVIEW_REQUIRED => (
338 rejection::HUMAN_REVIEW_REQUIRED,
339 &self.human_review_required,
340 ),
341 rejection::PREREQUISITE_NOT_DONE => (
342 rejection::PREREQUISITE_NOT_DONE,
343 &self.prerequisite_not_done,
344 ),
345 _ => return None,
346 };
347 Some(found)
348 }
349}
350
351impl Default for NoticeCopy {
352 fn default() -> Self {
353 Self::standard()
354 }
355}
356
357crate::copy::server_copy!(
358 NoticeCopy,
359 [
360 nothing_submitted,
361 nothing_deleted,
362 draft_only,
363 no_external_effects,
364 partial_result,
365 select_target_title,
366 select_target_cancel,
367 condition_title,
368 condition_yes,
369 condition_no,
370 act_refused,
371 target_policy_mismatch,
372 target_unauthorized,
373 target_missing,
374 target_stale,
375 target_unresolved,
376 target_too_many_candidates,
377 several_open_cases,
378 no_active_interaction,
379 text_resolution_not_allowed,
380 unknown_option,
381 unknown_workflow,
382 unknown_operation,
383 already_answered_running,
384 already_answered_done,
385 already_answered_failed,
386 already_answered_closed,
387 invalid_arguments,
388 not_proposable,
389 blocked_by_mode,
390 forbidden_risk_class,
391 human_review_required,
392 prerequisite_not_done,
393 record_not_found,
394 record_not_found_yet,
395 record_not_unique,
396 record_none_yet,
397 record_none,
398 not_understood,
399 message_unreadable,
400 kept_unchanged
401 ]
402);
403
404const ITALIAN: &[(&str, &str)] = &[
406 (
407 "record_none_yet",
408 "Per farlo manca ancora un {workflow}: posso aprirne uno io.",
409 ),
410 ("record_none", "Per farlo manca un {workflow}."),
411 ("nothing_submitted", "Non è stato inviato nulla."),
412 ("nothing_deleted", "Non è stato eliminato nulla."),
413 ("draft_only", "È rimasto tutto in bozza."),
414 (
415 "no_external_effects",
416 "Non è stata tentata nessuna operazione verso l'esterno.",
417 ),
418 (
419 "partial_result",
420 "Una parte di questa richiesta aspetta ancora una tua risposta.",
421 ),
422 ("select_target_title", "Quale intendevi?"),
423 ("select_target_cancel", "Nessuno di questi"),
424 ("condition_title", "Quella condizione vale?"),
425 ("condition_yes", "Sì, applicala"),
426 ("condition_no", "No, lascia stare"),
427 (
428 "act_refused",
429 "Una delle cose che hai chiesto non si è potuta fare.",
430 ),
431 (
432 "target_policy_mismatch",
433 "Non ho capito quale scheda andava modificata.",
434 ),
435 (
436 "target_unauthorized",
437 "Da qui non puoi accedere a quella scheda.",
438 ),
439 ("target_missing", "Non ho trovato la scheda che intendevi."),
440 (
441 "target_stale",
442 "Quella scheda è cambiata mentre parlavamo, quindi non l'ho sovrascritta.",
443 ),
444 (
445 "target_unresolved",
446 "Non ho capito quale scheda intendevi, quindi non ho scritto nulla.",
447 ),
448 (
449 "target_too_many_candidates",
450 "Troppe schede corrispondono a quella descrizione perché possa sceglierne una.",
451 ),
452 (
453 "several_open_cases",
454 "Ce n'è già più di una aperta, quindi non ne ho aperta un'altra. Dimmi quale intendi.",
455 ),
456 (
457 "no_active_interaction",
458 "Non c'è nessuna domanda sullo schermo a cui rispondere così.",
459 ),
460 (
461 "text_resolution_not_allowed",
462 "A questa si risponde con i pulsanti, non per iscritto.",
463 ),
464 ("unknown_option", "Non è una delle scelte disponibili."),
465 ("unknown_workflow", "Questo assistente non se ne occupa."),
466 ("unknown_operation", "Qui non posso farlo."),
467 (
468 "already_answered_running",
469 "Ci sto ancora lavorando: non serve premerlo di nuovo.",
470 ),
471 ("already_answered_done", "È già fatto."),
472 (
473 "already_answered_failed",
474 "Non è andato a buon fine, quindi non ha cambiato nulla.",
475 ),
476 ("already_answered_closed", "Non è più aperto."),
477 (
478 "invalid_arguments",
479 "Mancava quello che serviva, quindi non l'ho fatto.",
480 ),
481 (
482 "not_proposable",
483 "Succede solo quando premi il pulsante apposito.",
484 ),
485 ("blocked_by_mode", "Qui non sono configurato per farlo."),
486 (
487 "forbidden_risk_class",
488 "Non mi è permesso farlo in nessun caso.",
489 ),
490 ("human_review_required", "Deve approvarlo qualcun altro."),
491 (
492 "prerequisite_not_done",
493 "Dipendeva da un'altra cosa che hai chiesto, che non è stata fatta.",
494 ),
495 ("record_not_found", "Non trovo «{named}» come {workflow}."),
496 (
497 "record_not_found_yet",
498 "Non trovo ancora «{named}» come {workflow}: posso registrarlo io, oppure puoi indicare un altro nome.",
499 ),
500 (
501 "record_not_unique",
502 "Per «{named}» come {workflow} trovo più di un risultato.",
503 ),
504 ("not_understood", "Non ho capito questa parte: «{words}»."),
505 (
506 "message_unreadable",
507 "Non ho capito il messaggio, quindi non ho fatto nulla. Puoi dirlo in un altro modo?",
508 ),
509 (
510 "kept_unchanged",
511 "Lasciato com'è, come mi hai chiesto: «{words}».",
512 ),
513];