use crate::i18n::{current, Language};
fn did_you_mean(suggestions: &[String]) -> String {
if suggestions.is_empty() {
return String::new();
}
let list = suggestions.join(", ");
match current() {
Language::English => format!("; did you mean: {list}"),
Language::Portuguese => format!("; você quis dizer: {list}"),
}
}
pub fn target_not_designated() -> String {
match current() {
Language::English => String::from(
"this subcommand changes durable state and NOTHING named its target: \
no --db on the command line and no `db.path` in the configuration, \
so the write would land in the compiled default database. Name it \
with --db, or accept the default on purpose with --use-active",
),
Language::Portuguese => String::from(
"este subcomando altera estado durável e NADA nomeou o alvo: nenhum \
--db na linha de comando e nenhum `db.path` na configuração, então \
a escrita cairia no banco padrão compilado. Nomeie com --db, ou \
aceite o padrão de propósito com --use-active",
),
}
}
pub fn target_inherited_from_config() -> String {
match current() {
Language::English => String::from(
"this subcommand changes durable state and its target came from the \
`db.path` configuration key, not from this command line. That key is \
a HOST setting: it names one database for every directory on this \
machine, so it cannot designate the target of a single write. Name \
the database with --db, or accept the configured one on purpose with \
--use-active",
),
Language::Portuguese => String::from(
"este subcomando altera estado durável e o alvo dele veio da chave de \
configuração `db.path`, não desta linha de comando. Essa chave é do \
HOST: ela nomeia um banco para todos os diretórios desta máquina, \
então não designa o alvo de uma escrita específica. Nomeie o banco \
com --db, ou aceite o configurado de propósito com --use-active",
),
}
}
pub fn key_absent(flag: &str, key: &str, suggestions: &[String]) -> String {
let tail = did_you_mean(suggestions);
match current() {
Language::English => format!(
"{flag} names '{key}', which no result element carries, so the \
predicate would reject every row and the empty answer would be \
indistinguishable from missing data{tail}. Pass \
--allow-unknown-keys to accept an unresolvable key"
),
Language::Portuguese => format!(
"{flag} nomeia '{key}', que nenhum elemento de resultado carrega, \
então o predicado rejeitaria toda linha e a resposta vazia seria \
indistinguível de ausência de dado{tail}. Passe \
--allow-unknown-keys para aceitar uma chave irresolvível"
),
}
}
pub fn key_is_envelope_only(flag: &str, key: &str, array: &str) -> String {
match current() {
Language::English => format!(
"{flag} names '{key}', which is a member of the envelope and not a \
field of the '{array}' elements the predicate would run over. \
Applying it would empty '{array}' while '{key}' survived beside the \
result, contradicting the predicate. Filter on a field the elements \
carry, or read '{key}' from the unshaped envelope"
),
Language::Portuguese => format!(
"{flag} nomeia '{key}', que é membro do envelope e não campo dos \
elementos de '{array}' sobre os quais o predicado rodaria. \
Aplicá-lo esvaziaria '{array}' enquanto '{key}' sobreviveria ao lado \
do resultado, contradizendo o predicado. Filtre por um campo que os \
elementos carreguem, ou leia '{key}' do envelope sem reshaping"
),
}
}
pub fn knob_without_target(flags: &[String]) -> String {
let list = flags.join(", ");
match current() {
Language::English => format!(
"{list} was given, but this envelope carries no result array, so the \
flag can have no effect. Returning success while silently ignoring \
an argument the caller typed is what this refusal exists to prevent"
),
Language::Portuguese => format!(
"{list} foi passado, mas este envelope não carrega array de \
resultado, então a flag não pode ter efeito algum. Retornar sucesso \
ignorando em silêncio um argumento que o chamador digitou é \
exatamente o que esta recusa existe para impedir"
),
}
}
pub fn select_fully_unresolved(keys: &[String], suggestions: &[String]) -> String {
let list = keys.join(", ");
let tail = did_you_mean(suggestions);
match current() {
Language::English => format!(
"--select names only keys this envelope does not carry ({list}), so \
the projection would emit empty objects{tail}. Pass \
--allow-unknown-keys to accept that"
),
Language::Portuguese => format!(
"--select nomeia apenas chaves que este envelope não carrega \
({list}), então a projeção emitiria objetos vazios{tail}. Passe \
--allow-unknown-keys para aceitar isso"
),
}
}
pub fn filter_scope_is_a_page(observed: usize, total: usize, source: &str) -> String {
match current() {
Language::English => format!(
"the query returned {observed} of {total} rows, so --filter would \
judge only those {observed} and report an answer about a set it \
never saw (the ceiling came from the {source}). Raise the limit to \
cover the universe, or declare the narrower intent with \
--filter-scope page"
),
Language::Portuguese => format!(
"a consulta devolveu {observed} de {total} linhas, então --filter \
julgaria apenas essas {observed} e reportaria uma resposta sobre um \
conjunto que nunca observou (o teto veio do {source}). Amplie o \
limite para cobrir o universo, ou declare a intenção mais estreita \
com --filter-scope page"
),
}
}
pub fn knob_needs_a_whole_set(flags: &[String]) -> String {
let list = flags.join(", ");
match current() {
Language::English => format!(
"{list} needs a complete result set, but this subcommand emits one \
self-contained record per line. Applied here it would run once per \
record and answer about a single line instead of the stream. Narrow \
the query itself with --limit, or pipe the output to a tool that \
spans lines"
),
Language::Portuguese => format!(
"{list} precisa de um conjunto de resultados completo, mas este \
subcomando emite um registro autocontido por linha. Aplicado aqui, \
rodaria uma vez por registro e responderia sobre uma linha isolada \
em vez do stream. Estreite a própria consulta com --limit, ou \
canalize a saída para uma ferramenta que atravesse linhas"
),
}
}
pub fn filter_would_desync_a_tally() -> String {
match current() {
Language::English => "--filter cannot narrow a stream: this subcommand emits one record \
per line and its summary line counts the records the QUERY \
returned, so a predicate applied here would leave that count \
describing rows you never received. Narrow the query instead — \
--type, --namespace or --limit"
.to_string(),
Language::Portuguese => "--filter não pode estreitar um stream: este subcomando emite um \
registro por linha e a linha de sumário conta os registros que a \
CONSULTA devolveu, então um predicado aplicado aqui deixaria essa \
contagem descrevendo linhas que você nunca recebeu. Estreite a \
consulta em vez disso — --type, --namespace ou --limit"
.to_string(),
}
}
pub fn count_only_over_a_page(observed: usize, total: usize) -> String {
match current() {
Language::English => format!(
"--count-only would emit a bare number counted over {observed} of \
{total} rows, which a caller reads as the inventory. Raise the \
limit, or declare --filter-scope page to accept a count of the page"
),
Language::Portuguese => format!(
"--count-only emitiria um número isolado contado sobre {observed} de \
{total} linhas, que o chamador lê como o inventário. Amplie o \
limite, ou declare --filter-scope page para aceitar a contagem da \
página"
),
}
}