sqlite_graphrag/i18n/validation/
messages_config.rs1use crate::i18n::{current, Language};
7
8pub fn config_file_is_symlink(path: &str) -> String {
10 match current() {
11 Language::English => format!("config file is a symlink (potential attack): {path}"),
12 Language::Portuguese => {
13 format!("arquivo de config é um symlink (potencial ataque): {path}")
14 }
15 }
16}
17
18pub fn config_file_wrong_owner(path: &str, file_uid: u32, my_uid: u32) -> String {
20 match current() {
21 Language::English => format!(
22 "config file {path} owned by uid {file_uid}, not current uid {my_uid}; refusing to overwrite"
23 ),
24 Language::Portuguese => format!(
25 "arquivo de config {path} pertence ao uid {file_uid}, não ao uid atual {my_uid}; recusando sobrescrever"
26 ),
27 }
28}
29
30pub fn config_key_retired(key: &str, replacement: &str) -> String {
36 match current() {
37 Language::English => format!(
38 "config key '{key}' was never read by this binary; \
39 use '{replacement}' instead"
40 ),
41 Language::Portuguese => format!(
42 "a chave de config '{key}' nunca foi lida por este binário; \
43 use '{replacement}' no lugar"
44 ),
45 }
46}
47
48pub fn config_key_unknown(key: &str, suggestion: Option<&str>) -> String {
53 match (current(), suggestion) {
54 (Language::English, Some(s)) => format!(
55 "unknown config key '{key}'; did you mean '{s}'? \
56 list valid keys with `config doctor --json`"
57 ),
58 (Language::English, None) => format!(
59 "unknown config key '{key}'; \
60 list valid keys with `config doctor --json`"
61 ),
62 (Language::Portuguese, Some(s)) => format!(
63 "chave de config desconhecida '{key}'; você quis dizer '{s}'? \
64 liste as chaves válidas com `config doctor --json`"
65 ),
66 (Language::Portuguese, None) => format!(
67 "chave de config desconhecida '{key}'; \
68 liste as chaves válidas com `config doctor --json`"
69 ),
70 }
71}
72
73pub fn config_value_expectation(kind: crate::config::ValueKind) -> String {
78 use crate::config::ValueKind as K;
79 match (current(), kind) {
80 (Language::English, K::Unsigned) => "a non-negative integer".to_string(),
81 (Language::English, K::Float) => "a decimal number".to_string(),
82 (Language::English, K::Tz) => "an IANA timezone (e.g. America/Sao_Paulo)".to_string(),
83 (Language::English, K::Url) => "an http:// or https:// URL".to_string(),
84 (Language::English, K::Path) => "a non-empty filesystem path".to_string(),
85 (Language::English, K::LogDirective) => {
86 "a tracing directive (e.g. warn, or sqlite_graphrag=debug)".to_string()
87 }
88 (Language::Portuguese, K::Unsigned) => "um inteiro não negativo".to_string(),
89 (Language::Portuguese, K::Float) => "um número decimal".to_string(),
90 (Language::Portuguese, K::Tz) => {
91 "um fuso horário IANA (ex.: America/Sao_Paulo)".to_string()
92 }
93 (Language::Portuguese, K::Url) => "uma URL http:// ou https://".to_string(),
94 (Language::Portuguese, K::Path) => {
95 "um caminho de sistema de arquivos não vazio".to_string()
96 }
97 (Language::Portuguese, K::LogDirective) => {
98 "uma diretiva de tracing (ex.: warn, ou sqlite_graphrag=debug)".to_string()
99 }
100 (_, K::Bool) => "true|false (also 1|0, yes|no, on|off)".to_string(),
104 (_, K::Text) => String::new(),
105 (_, K::OneOf(options)) => options.join("|"),
106 }
107}
108
109pub fn config_value_invalid(key: &str, value: &str, expectation: &str) -> String {
115 match current() {
116 Language::English => {
117 format!("invalid value '{value}' for config key '{key}'; expected {expectation}")
118 }
119 Language::Portuguese => format!(
120 "valor inválido '{value}' para a chave de config '{key}'; esperado {expectation}"
121 ),
122 }
123}
124
125pub fn config_parse_error(path: &str, err: &impl std::fmt::Display) -> String {
127 match current() {
128 Language::English => format!("config parse error in {path}: {err}"),
129 Language::Portuguese => format!("erro de parse de config em {path}: {err}"),
130 }
131}
132
133pub fn config_path_no_parent(path: &str) -> String {
135 match current() {
136 Language::English => format!("config path has no parent: {path}"),
137 Language::Portuguese => format!("caminho de config sem diretório pai: {path}"),
138 }
139}
140
141pub fn api_key_cannot_be_empty() -> String {
143 match current() {
144 Language::English => "API key cannot be empty".to_string(),
145 Language::Portuguese => "chave de API não pode ser vazia".to_string(),
146 }
147}
148
149pub fn invalid_namespace_config(path: &str, err: &str) -> String {
151 match current() {
152 Language::English => {
153 format!("invalid project namespace config '{path}': {err}")
154 }
155 Language::Portuguese => {
156 format!("configuração de namespace de projeto inválida '{path}': {err}")
157 }
158 }
159}
160
161pub fn invalid_projects_mapping(path: &str, err: &str) -> String {
163 match current() {
164 Language::English => format!("invalid projects mapping '{path}': {err}"),
165 Language::Portuguese => format!("mapeamento de projetos inválido '{path}': {err}"),
166 }
167}