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 reclassify_batch_no_targets(from_type: &str, namespace: &str) -> String {
60 match current() {
61 Language::English => format!(
62 "--from-type '{from_type}' matches no entity in namespace '{namespace}'; \
63 list the stored types with `graph entities` before retrying"
64 ),
65 Language::Portuguese => format!(
66 "--from-type '{from_type}' não corresponde a nenhuma entidade no namespace '{namespace}'; \
67 liste os tipos gravados com `graph entities` antes de repetir"
68 ),
69 }
70}
71
72pub fn relation_format_for_relationship(
74 err: &impl std::fmt::Display,
75 source: &str,
76 target: &str,
77) -> String {
78 match current() {
79 Language::English => format!("{err} for relationship '{source}' -> '{target}'"),
80 Language::Portuguese => {
81 format!("{err} para relacionamento '{source}' -> '{target}'")
82 }
83 }
84}
85
86pub fn self_referential_link() -> String {
88 match current() {
89 Language::English => "--from and --to must be different entities — self-referential relationships are not supported".to_string(),
90 Language::Portuguese => "--from e --to devem ser entidades diferentes — relacionamentos auto-referenciais não são suportados".to_string(),
91 }
92}