sqlite_graphrag/i18n/validation/
messages_graph.rs1use crate::i18n::{current, Language};
6
7pub fn invalid_link_weight(weight: f64) -> String {
9 match current() {
10 Language::English => {
11 format!("--weight: must be between 0.0 and 1.0 (actual: {weight})")
12 }
13 Language::Portuguese => {
14 format!("--weight: deve estar entre 0.0 e 1.0 (atual: {weight})")
15 }
16 }
17}
18
19pub fn invalid_relationship_id(item_key: &str) -> String {
21 match current() {
22 Language::English => format!("invalid relationship id: {item_key}"),
23 Language::Portuguese => format!("id de relacionamento inválido: {item_key}"),
24 }
25}
26
27pub fn invalid_relationship_strength(strength: f64, source: &str, target: &str) -> String {
29 match current() {
30 Language::English => format!(
31 "invalid strength {strength} for relationship '{source}' -> '{target}'; \
32 expected value in [0.0, 1.0]"
33 ),
34 Language::Portuguese => format!(
35 "força inválida {strength} para relacionamento '{source}' -> '{target}'; \
36 valor esperado em [0.0, 1.0]"
37 ),
38 }
39}
40
41pub fn non_canonical_relation(relation: &str, allowed: &str) -> String {
43 match current() {
44 Language::English => format!(
45 "non-canonical relation '{relation}': use --strict-relations=false or choose from: {allowed}"
46 ),
47 Language::Portuguese => format!(
48 "relação não canônica '{relation}': use --strict-relations=false ou escolha entre: {allowed}"
49 ),
50 }
51}
52
53pub fn relation_format_for_relationship(
55 err: &impl std::fmt::Display,
56 source: &str,
57 target: &str,
58) -> String {
59 match current() {
60 Language::English => format!("{err} for relationship '{source}' -> '{target}'"),
61 Language::Portuguese => {
62 format!("{err} para relacionamento '{source}' -> '{target}'")
63 }
64 }
65}
66
67pub fn self_referential_link() -> String {
69 match current() {
70 Language::English => "--from and --to must be different entities — self-referential relationships are not supported".to_string(),
71 Language::Portuguese => "--from e --to devem ser entidades diferentes — relacionamentos auto-referenciais não são suportados".to_string(),
72 }
73}