use crate::i18n::{current, Language};
pub fn config_file_is_symlink(path: &str) -> String {
match current() {
Language::English => format!("config file is a symlink (potential attack): {path}"),
Language::Portuguese => {
format!("arquivo de config é um symlink (potencial ataque): {path}")
}
}
}
pub fn config_file_wrong_owner(path: &str, file_uid: u32, my_uid: u32) -> String {
match current() {
Language::English => format!(
"config file {path} owned by uid {file_uid}, not current uid {my_uid}; refusing to overwrite"
),
Language::Portuguese => format!(
"arquivo de config {path} pertence ao uid {file_uid}, não ao uid atual {my_uid}; recusando sobrescrever"
),
}
}
pub fn config_key_retired(key: &str, replacement: &str) -> String {
match current() {
Language::English => format!(
"config key '{key}' was never read by this binary; \
use '{replacement}' instead"
),
Language::Portuguese => format!(
"a chave de config '{key}' nunca foi lida por este binário; \
use '{replacement}' no lugar"
),
}
}
pub fn config_key_unknown(key: &str, suggestion: Option<&str>) -> String {
match (current(), suggestion) {
(Language::English, Some(s)) => format!(
"unknown config key '{key}'; did you mean '{s}'? \
list valid keys with `config doctor --json`"
),
(Language::English, None) => format!(
"unknown config key '{key}'; \
list valid keys with `config doctor --json`"
),
(Language::Portuguese, Some(s)) => format!(
"chave de config desconhecida '{key}'; você quis dizer '{s}'? \
liste as chaves válidas com `config doctor --json`"
),
(Language::Portuguese, None) => format!(
"chave de config desconhecida '{key}'; \
liste as chaves válidas com `config doctor --json`"
),
}
}
pub fn config_value_expectation(kind: crate::config::ValueKind) -> String {
use crate::config::ValueKind as K;
match (current(), kind) {
(Language::English, K::Unsigned) => "a non-negative integer".to_string(),
(Language::English, K::Float) => "a decimal number".to_string(),
(Language::English, K::Tz) => "an IANA timezone (e.g. America/Sao_Paulo)".to_string(),
(Language::English, K::Url) => "an http:// or https:// URL".to_string(),
(Language::English, K::Path) => "a non-empty filesystem path".to_string(),
(Language::English, K::LogDirective) => {
"a tracing directive (e.g. warn, or sqlite_graphrag=debug)".to_string()
}
(Language::Portuguese, K::Unsigned) => "um inteiro não negativo".to_string(),
(Language::Portuguese, K::Float) => "um número decimal".to_string(),
(Language::Portuguese, K::Tz) => {
"um fuso horário IANA (ex.: America/Sao_Paulo)".to_string()
}
(Language::Portuguese, K::Url) => "uma URL http:// ou https://".to_string(),
(Language::Portuguese, K::Path) => {
"um caminho de sistema de arquivos não vazio".to_string()
}
(Language::Portuguese, K::LogDirective) => {
"uma diretiva de tracing (ex.: warn, ou sqlite_graphrag=debug)".to_string()
}
(_, K::Bool) => "true|false (also 1|0, yes|no, on|off)".to_string(),
(_, K::Text) => String::new(),
(_, K::OneOf(options)) => options.join("|"),
}
}
pub fn config_value_invalid(key: &str, value: &str, expectation: &str) -> String {
match current() {
Language::English => {
format!("invalid value '{value}' for config key '{key}'; expected {expectation}")
}
Language::Portuguese => format!(
"valor inválido '{value}' para a chave de config '{key}'; esperado {expectation}"
),
}
}
pub fn config_parse_error(path: &str, err: &impl std::fmt::Display) -> String {
match current() {
Language::English => format!("config parse error in {path}: {err}"),
Language::Portuguese => format!("erro de parse de config em {path}: {err}"),
}
}
pub fn config_path_no_parent(path: &str) -> String {
match current() {
Language::English => format!("config path has no parent: {path}"),
Language::Portuguese => format!("caminho de config sem diretório pai: {path}"),
}
}
pub fn api_key_cannot_be_empty() -> String {
match current() {
Language::English => "API key cannot be empty".to_string(),
Language::Portuguese => "chave de API não pode ser vazia".to_string(),
}
}
pub fn invalid_namespace_config(path: &str, err: &str) -> String {
match current() {
Language::English => {
format!("invalid project namespace config '{path}': {err}")
}
Language::Portuguese => {
format!("configuração de namespace de projeto inválida '{path}': {err}")
}
}
}
pub fn invalid_projects_mapping(path: &str, err: &str) -> String {
match current() {
Language::English => format!("invalid projects mapping '{path}': {err}"),
Language::Portuguese => format!("mapeamento de projetos inválido '{path}': {err}"),
}
}