Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

LRC-LIB-SMARTCOLL: hints name each field's own operator; Russian operator labels

Nathaniel Ledford633775e5ed96
diff --git a/crates/catalog/src/rules.rs b/crates/catalog/src/rules.rs
index ce98972e9..8eaa7f894 100644
--- a/crates/catalog/src/rules.rs
+++ b/crates/catalog/src/rules.rs
@@ -185,6 +185,9 @@ pub enum Issue {
NotAChoice,
NeedsTextOrEmpty,
NeedsTextOrNotEmpty,
+ /// Keywords and People: their operators say "are empty".
+ NeedsNamesOrEmpty,
+ NeedsNamesOrNotEmpty,
NeedsText,
NoRatingMatches,
ChooseAlbum,
@@ -195,7 +198,7 @@ pub enum Issue {
}
impl Issue {
- pub const ALL: [Issue; 20] = [
+ pub const ALL: [Issue; 22] = [
Issue::UnknownField,
Issue::NoSuchOperator,
Issue::NotYesNo,
@@ -209,6 +212,8 @@ impl Issue {
Issue::NotAChoice,
Issue::NeedsTextOrEmpty,
Issue::NeedsTextOrNotEmpty,
+ Issue::NeedsNamesOrEmpty,
+ Issue::NeedsNamesOrNotEmpty,
Issue::NeedsText,
Issue::NoRatingMatches,
Issue::ChooseAlbum,
@@ -234,6 +239,8 @@ impl Issue {
Issue::NotAChoice => "isn't one of the choices",
Issue::NeedsTextOrEmpty => "needs something to look for (or use “is empty”)",
Issue::NeedsTextOrNotEmpty => "needs something to look for (or use “isn't empty”)",
+ Issue::NeedsNamesOrEmpty => "needs something to look for (or use “are empty”)",
+ Issue::NeedsNamesOrNotEmpty => "needs something to look for (or use “aren't empty”)",
Issue::NeedsText => "needs text",
Issue::NoRatingMatches => "can't match any rating from 0 to 5",
Issue::ChooseAlbum => "needs an album",
@@ -278,10 +285,13 @@ fn field_problem(field: &str, op: &str, value: &Value, cat: &Catalog) -> Found {
Kind::Text | Kind::Keywords => match value {
Value::String(s) if !s.trim().is_empty() => None,
Value::String(_) | Value::Null => {
- let (issue, instead) = if matches!(op, "isNot" | "notContains") {
- (Issue::NeedsTextOrNotEmpty, "isn't empty")
- } else {
- (Issue::NeedsTextOrEmpty, "is empty")
+ // the hint names the operator as the menu does: Keywords and People say "are empty"
+ let not = matches!(op, "isNot" | "notContains");
+ let (issue, instead) = match (kind, not) {
+ (Kind::Keywords, false) => (Issue::NeedsNamesOrEmpty, "are empty"),
+ (Kind::Keywords, true) => (Issue::NeedsNamesOrNotEmpty, "aren't empty"),
+ (_, false) => (Issue::NeedsTextOrEmpty, "is empty"),
+ (_, true) => (Issue::NeedsTextOrNotEmpty, "isn't empty"),
};
Some((issue, format!("`{field}` needs something to look for (or use “{instead}”)")))
}
@@ -1408,6 +1418,10 @@ mod tests {
assert_eq!((p[0].field.as_deref(), p[0].issue), (Some("title"), Issue::NeedsTextOrEmpty));
let p = check(json!([{"field": "title", "op": "isNot", "value": ""}]));
assert_eq!(p[0].issue, Issue::NeedsTextOrNotEmpty);
+ // keywords and people say "are empty", and so does their hint
+ let p = check(json!([{"field": "keywords", "op": "contains", "value": ""}, {"field": "person", "op": "notContains", "value": " "}]));
+ assert_eq!((p[0].issue, p[1].issue), (Issue::NeedsNamesOrEmpty, Issue::NeedsNamesOrNotEmpty));
+ assert!(p[0].issue.text().contains("“are empty”") && p[0].message.contains("“are empty”"));
let p = check(json!([{"field": "rating", "op": "is", "value": 9}, {"group": {"rules": []}}]));
assert_eq!((p[0].field.as_deref(), p[0].issue), (Some("rating"), Issue::NoRatingMatches));
assert_eq!((p[1].field.as_deref(), p[1].issue), (None, Issue::EmptyGroup));
diff --git a/crates/ui-egui/locales/de.json b/crates/ui-egui/locales/de.json
index cb40d0200..782e2a441 100644
--- a/crates/ui-egui/locales/de.json
+++ b/crates/ui-egui/locales/de.json
@@ -1920,5 +1920,7 @@
"names an album that no longer exists": "nennt ein Album, das es nicht mehr gibt",
"can't test a smart album; choose a plain album": "kann kein Smart-Album prüfen; wähle ein normales Album",
"can't test a folder; choose an album in it": "kann keinen Ordner prüfen; wähle ein Album darin",
- "This group is empty: add a rule or remove it.": "Diese Gruppe ist leer: Füge eine Regel hinzu oder entferne sie."
+ "This group is empty: add a rule or remove it.": "Diese Gruppe ist leer: Füge eine Regel hinzu oder entferne sie.",
+ "needs something to look for (or use “are empty”)": "braucht einen Suchbegriff (oder „sind leer“)",
+ "needs something to look for (or use “aren't empty”)": "braucht einen Suchbegriff (oder „sind nicht leer“)"
}
diff --git a/crates/ui-egui/locales/es.json b/crates/ui-egui/locales/es.json
index a894ed841..61dacae42 100644
--- a/crates/ui-egui/locales/es.json
+++ b/crates/ui-egui/locales/es.json
@@ -1765,5 +1765,7 @@
"names an album that no longer exists": "indica un álbum que ya no existe",
"can't test a smart album; choose a plain album": "no puede comprobar un álbum inteligente; elige un álbum normal",
"can't test a folder; choose an album in it": "no puede comprobar una carpeta; elige un álbum dentro",
- "This group is empty: add a rule or remove it.": "Este grupo está vacío: añade una regla o quítalo."
+ "This group is empty: add a rule or remove it.": "Este grupo está vacío: añade una regla o quítalo.",
+ "needs something to look for (or use “are empty”)": "necesita algo que buscar (o usa «están vacíos»)",
+ "needs something to look for (or use “aren't empty”)": "necesita algo que buscar (o usa «no están vacíos»)"
}
diff --git a/crates/ui-egui/locales/ja.json b/crates/ui-egui/locales/ja.json
index b7fa0316b..99f0e8f27 100644
--- a/crates/ui-egui/locales/ja.json
+++ b/crates/ui-egui/locales/ja.json
@@ -1769,5 +1769,7 @@
"names an album that no longer exists": "存在しないアルバムが指定されています",
"can't test a smart album; choose a plain album": "スマートアルバムは判定できません。通常のアルバムを選択してください",
"can't test a folder; choose an album in it": "フォルダーは判定できません。中のアルバムを選択してください",
- "This group is empty: add a rule or remove it.": "このグループは空です。条件を追加するか、グループを削除してください。"
+ "This group is empty: add a rule or remove it.": "このグループは空です。条件を追加するか、グループを削除してください。",
+ "needs something to look for (or use “are empty”)": "検索する語句が必要です(または「が空」を使用)",
+ "needs something to look for (or use “aren't empty”)": "検索する語句が必要です(または「が空でない」を使用)"
}
diff --git a/crates/ui-egui/locales/pt-br.json b/crates/ui-egui/locales/pt-br.json
index 7e06fa7ae..3fddf2c9e 100644
--- a/crates/ui-egui/locales/pt-br.json
+++ b/crates/ui-egui/locales/pt-br.json
@@ -1765,5 +1765,7 @@
"names an album that no longer exists": "indica um álbum que não existe mais",
"can't test a smart album; choose a plain album": "não pode testar um álbum inteligente; escolha um álbum comum",
"can't test a folder; choose an album in it": "não pode testar uma pasta; escolha um álbum dentro dela",
- "This group is empty: add a rule or remove it.": "Este grupo está vazio: adicione uma regra ou remova-o."
+ "This group is empty: add a rule or remove it.": "Este grupo está vazio: adicione uma regra ou remova-o.",
+ "needs something to look for (or use “are empty”)": "precisa de algo para procurar (ou use “estão vazios”)",
+ "needs something to look for (or use “aren't empty”)": "precisa de algo para procurar (ou use “não estão vazios”)"
}
diff --git a/crates/ui-egui/locales/ru.json b/crates/ui-egui/locales/ru.json
index fd289e141..516c2636f 100644
--- a/crates/ui-egui/locales/ru.json
+++ b/crates/ui-egui/locales/ru.json
@@ -1437,5 +1437,27 @@
"names an album that no longer exists": "указан альбом, которого больше нет",
"can't test a smart album; choose a plain album": "нельзя проверять смарт-альбом; выберите обычный альбом",
"can't test a folder; choose an album in it": "нельзя проверять папку; выберите альбом в ней",
- "This group is empty: add a rule or remove it.": "Эта группа пуста: добавьте условие или удалите её."
+ "This group is empty: add a rule or remove it.": "Эта группа пуста: добавьте условие или удалите её.",
+ "needs something to look for (or use “are empty”)": "нужно указать, что искать (или выберите «пусты»)",
+ "needs something to look for (or use “aren't empty”)": "нужно указать, что искать (или выберите «не пусты»)",
+ "are empty": "пусты",
+ "aren't empty": "не пусты",
+ "contains": "содержит",
+ "doesn't contain": "не содержит",
+ "ends with": "заканчивается на",
+ "is": "равно",
+ "is <": "меньше",
+ "is >": "больше",
+ "is after": "после",
+ "is before": "до",
+ "is between": "между",
+ "is empty": "пусто",
+ "is in the last": "за последние",
+ "is unknown": "неизвестна",
+ "is ≤": "не больше",
+ "is ≥": "не меньше",
+ "isn't": "не равно",
+ "isn't empty": "не пусто",
+ "isn't in the last": "не за последние",
+ "starts with": "начинается с"
}
diff --git a/crates/ui-egui/locales/zh-hans.json b/crates/ui-egui/locales/zh-hans.json
index 335867dc8..e0b44b54b 100644
--- a/crates/ui-egui/locales/zh-hans.json
+++ b/crates/ui-egui/locales/zh-hans.json
@@ -1765,5 +1765,7 @@
"names an album that no longer exists": "指定的相册已不存在",
"can't test a smart album; choose a plain album": "无法判断智能相册;请选择普通相册",
"can't test a folder; choose an album in it": "无法判断文件夹;请选择其中的相册",
- "This group is empty: add a rule or remove it.": "此组为空:请添加规则或将其删除。"
+ "This group is empty: add a rule or remove it.": "此组为空:请添加规则或将其删除。",
+ "needs something to look for (or use “are empty”)": "需要要查找的内容(或使用“为空”)",
+ "needs something to look for (or use “aren't empty”)": "需要要查找的内容(或使用“不为空”)"
}
diff --git a/crates/ui-egui/locales/zh-hant.json b/crates/ui-egui/locales/zh-hant.json
index 1995f4e8b..ec8e63449 100644
--- a/crates/ui-egui/locales/zh-hant.json
+++ b/crates/ui-egui/locales/zh-hant.json
@@ -1765,5 +1765,7 @@
"names an album that no longer exists": "指定的相簿已不存在",
"can't test a smart album; choose a plain album": "無法判斷智慧型相簿;請選擇一般相簿",
"can't test a folder; choose an album in it": "無法判斷資料夾;請選擇其中的相簿",
- "This group is empty: add a rule or remove it.": "此群組為空:請新增規則或將其移除。"
+ "This group is empty: add a rule or remove it.": "此群組為空:請新增規則或將其移除。",
+ "needs something to look for (or use “are empty”)": "需要要尋找的內容(或使用「為空」)",
+ "needs something to look for (or use “aren't empty”)": "需要要尋找的內容(或使用「不為空」)"
}
diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rs
index 21ce65ddd..b1332170a 100644
--- a/crates/ui-egui/src/i18n.rs
+++ b/crates/ui-egui/src/i18n.rs
@@ -342,8 +342,10 @@ pub fn problem_line(problem: &lightcraft_catalog::rules::Problem) -> String {
fn problem_text_in(language: Locale, problem: &lightcraft_catalog::rules::Problem) -> String {
let issue = tr_in(language, problem.issue.text());
+ // Japanese and Chinese catalogs join a label and its text with a full-width colon
+ let colon = if matches!(language.script(), "Jpan" | "Hans" | "Hant") { ":" } else { ": " };
match problem.field.as_deref() {
- Some(field) => format!("{}: {issue}", tr_in(language, lightcraft_catalog::rules::field_label(field).unwrap_or(field))),
+ Some(field) => format!("{}{colon}{issue}", tr_in(language, lightcraft_catalog::rules::field_label(field).unwrap_or(field))),
None => issue.to_string(),
}
}
@@ -755,12 +757,20 @@ mod tests {
assert_eq!(problem_text_in(Locale::En, &p[0]), "Title: needs something to look for (or use “is empty”)");
assert_eq!(problem_text_in(Locale::De, &p[0]), "Titel: braucht einen Suchbegriff (oder „ist leer“)");
assert_eq!(problem_line_in(Locale::En, &p[0]), "#2 Title: needs something to look for (or use “is empty”)");
+ // Japanese and Chinese join with a full-width colon, as their catalogs do
+ assert_eq!(problem_text_in(Locale::Ja, &p[0]), "タイトル:検索する語句が必要です(または「が空」を使用)");
let g = problems(serde_json::json!([{"group": {"rules": []}}]));
assert_eq!(problem_text_in(Locale::En, &g[0]), "This group is empty: add a rule or remove it.");
+ // the issues, and the operators their hints name, in every language
for language in Locale::ALL.iter().filter(|l| **l != Locale::En) {
for issue in Issue::ALL {
assert!(language.catalog().contains_key(issue.text()), "{} lacks {:?}", language.code(), issue.text());
}
+ for (_, _, kind) in lightcraft_catalog::rules::FIELDS {
+ for (_, op) in lightcraft_catalog::rules::ops_for(*kind) {
+ assert!(language.catalog().contains_key(*op), "{} lacks the operator {op:?}", language.code());
+ }
+ }
}
}