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