Skip to content

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

PR218: localize complete import messages & scale prepared path

Adrian D'souza7cf3719c6373
diff --git a/crates/engine/src/lightroom_job.rs b/crates/engine/src/lightroom_job.rs
index 0346dd625..e3e00ea6c 100644
--- a/crates/engine/src/lightroom_job.rs
+++ b/crates/engine/src/lightroom_job.rs
@@ -369,6 +369,61 @@ mod tests {
assert_eq!(session.undo.len(), 3);
}
+ #[test]
+ fn oversized_history_archive_keeps_prepared_import_successful_with_warning() {
+ let archive_dir = std::env::temp_dir().join(format!("lightcraft-lr-prepared-scale-{}", std::process::id()));
+ let mut data = empty_data();
+ data.photos = (0..5_000)
+ .map(|source_id| {
+ let image = std::collections::BTreeMap::from([
+ ("id_local".into(), serde_json::json!(source_id)),
+ ("fileFormat".into(), serde_json::json!("JPG")),
+ ("fileWidth".into(), serde_json::json!(1)),
+ ("fileHeight".into(), serde_json::json!(1)),
+ ]);
+ lightroom_catalog::CatalogPhoto {
+ source_id,
+ uuid: format!("scale-{source_id}"),
+ path: format!("/missing/scale-{source_id}.jpg"),
+ image,
+ settings: String::new(),
+ xmp: String::new(),
+ keywords: Vec::new(),
+ history: vec![std::collections::BTreeMap::from([(
+ "text".into(),
+ serde_json::json!(format!("history-{source_id}-{}", "x".repeat(8 * 1024))),
+ )])],
+ snapshots: Vec::new(),
+ }
+ })
+ .collect();
+ let archive_path = crate::lightroom_archive::store_best_effort(&archive_dir, &data).unwrap();
+ assert!(archive_path.is_none());
+ data.warnings.push("Lightroom source archive exceeded 32 MiB; archive skipped".into());
+ let mut session = crate::Session::new();
+ let token = LightroomLibraryToken::capture(&session);
+ let prepared = PreparedLightroom {
+ data,
+ normal: Prepared::default(),
+ index: ImportIndex::default(),
+ archive_path,
+ token,
+ missing_sources: HashSet::new(),
+ update_existing: false,
+ now: "2026-01-01T00:00:00".into(),
+ cancelled: false,
+ };
+ let completion = commit_prepared(&mut session, prepared).unwrap();
+ assert_eq!(completion.report["photos"], 5_000);
+ assert!(
+ completion.report["warnings"]
+ .as_array()
+ .is_some_and(|warnings| warnings.iter().any(|warning| warning == "Lightroom source archive exceeded 32 MiB; archive skipped"))
+ );
+ assert_eq!(session.catalog.len(), 5_000);
+ std::fs::remove_dir_all(archive_dir).unwrap();
+ }
+
#[test]
fn execute_fn_import_does_not_rewrite_source_sidecar() {
let dir = std::env::temp_dir().join(format!("lightcraft-lr-job-sidecar-{}", std::process::id()));
diff --git a/crates/ui-egui/locales/ja-formats.json b/crates/ui-egui/locales/ja-formats.json
index 1944d7b6a..77abbadd7 100644
--- a/crates/ui-egui/locales/ja-formats.json
+++ b/crates/ui-egui/locales/ja-formats.json
@@ -46,6 +46,7 @@
"Proof Preview · {}": "校正プレビュー・{}",
"Quick Develop · {n} photos": "クイック現像・{n}枚",
"Rated {}": "評価:{}",
+ "Reading Lightroom catalog… {done} of {total}": "Reading Lightroom catalog… {done} of {total}",
"Reading photos… {done} of {total}": "写真を読み込み中:{total}枚中{done}枚",
"Redo {}": "やり直す:{}",
"Remove “{}” from Favorites": "「{}」をお気に入りから削除",
@@ -109,6 +110,12 @@
"Build Smart Previews ({scope})": "スマートプレビューを作成({scope})",
"Build Standard-Sized Previews ({scope})": "標準プレビューを作成({scope})",
"Discard Smart Previews ({scope})": "スマートプレビューを破棄({scope})",
+ "Lightroom catalog inspected: {photos} photos, {collections} collections, {missing} missing": "Lightroom catalog inspected: {photos} photos, {collections} collections, {missing} missing",
+ "Lightroom import complete: {imported} photos added": "Lightroom import complete: {imported} photos added",
+ "Lightroom import complete: {imported} photos added, {failed} failed": "Lightroom import complete: {imported} photos added, {failed} failed",
+ "Lightroom import complete: {imported} photos added; index warning: {warning}": "Lightroom import complete: {imported} photos added; index warning: {warning}",
+ "Lightroom import failed: {e}{warning}": "Lightroom import failed: {e}{warning}",
+ "Lightroom inspection failed: {e}{warning}": "Lightroom inspection failed: {e}{warning}",
"Label Set: {name}": "ラベルセット:{name}",
"Quick Develop: {name}": "クイック現像: {name}",
"Reset {name}": "{name}をリセット",
diff --git a/crates/ui-egui/locales/pt-br-formats.json b/crates/ui-egui/locales/pt-br-formats.json
index 50b0f2abf..c79f96de8 100644
--- a/crates/ui-egui/locales/pt-br-formats.json
+++ b/crates/ui-egui/locales/pt-br-formats.json
@@ -43,6 +43,12 @@
"Imported {n} preset{}": "Importadas {n} predefinição{:.0}",
"Imported {n} preset{}, {f} file{} not readable": "Importadas {n} predefinição{:.0}, {f} arquivo{:.0} não legível",
"Imported {} photo{}": "Importadas {} foto{:.0}",
+ "Lightroom catalog inspected: {photos} photos, {collections} collections, {missing} missing": "Lightroom catalog inspected: {photos} photos, {collections} collections, {missing} missing",
+ "Lightroom import complete: {imported} photos added": "Lightroom import complete: {imported} photos added",
+ "Lightroom import complete: {imported} photos added, {failed} failed": "Lightroom import complete: {imported} photos added, {failed} failed",
+ "Lightroom import complete: {imported} photos added; index warning: {warning}": "Lightroom import complete: {imported} photos added; index warning: {warning}",
+ "Lightroom import failed: {e}{warning}": "Lightroom import failed: {e}{warning}",
+ "Lightroom inspection failed: {e}{warning}": "Lightroom inspection failed: {e}{warning}",
"Label Set: {name}": "Conjunto de rótulos: {name}",
"Matches: {}": "Correspondências: {}",
"Merging… {stage} {:.0}%": "Mesclando… {stage} {:.0}%",
@@ -58,6 +64,7 @@
"Quick Develop · {n} photos": "Revelação rápida · {n} fotos",
"Quick Develop: {name}": "Revelação rápida: {name}",
"Rated {}": "Avaliada {}",
+ "Reading Lightroom catalog… {done} of {total}": "Reading Lightroom catalog… {done} of {total}",
"Reading photos… {done} of {total}": "Lendo fotos… {done} de {total}",
"Reading photos… {} of {}": "Lendo fotos… {} de {}",
"Redo {}": "Refazer {}",
diff --git a/crates/ui-egui/locales/zh-hans-formats.json b/crates/ui-egui/locales/zh-hans-formats.json
index c3713eb18..bdd23fb3f 100644
--- a/crates/ui-egui/locales/zh-hans-formats.json
+++ b/crates/ui-egui/locales/zh-hans-formats.json
@@ -46,6 +46,7 @@
"Proof Preview · {}": "校样预览 · {0}",
"Quick Develop · {n} photos": "快速编辑 · {n} 张照片",
"Rated {}": "已评级 {0}",
+ "Reading Lightroom catalog… {done} of {total}": "Reading Lightroom catalog… {done} of {total}",
"Reading photos… {done} of {total}": "正在读取照片… {total} 张中的 {done} 张",
"Redo {}": "重做:{0}",
"Remove “{}” from Favorites": "从收藏夹中移除“{0}”",
@@ -109,6 +110,12 @@
"Build Smart Previews ({scope})": "生成智能预览({scope})",
"Build Standard-Sized Previews ({scope})": "生成标准尺寸预览({scope})",
"Discard Smart Previews ({scope})": "丢弃智能预览({scope})",
+ "Lightroom catalog inspected: {photos} photos, {collections} collections, {missing} missing": "Lightroom catalog inspected: {photos} photos, {collections} collections, {missing} missing",
+ "Lightroom import complete: {imported} photos added": "Lightroom import complete: {imported} photos added",
+ "Lightroom import complete: {imported} photos added, {failed} failed": "Lightroom import complete: {imported} photos added, {failed} failed",
+ "Lightroom import complete: {imported} photos added; index warning: {warning}": "Lightroom import complete: {imported} photos added; index warning: {warning}",
+ "Lightroom import failed: {e}{warning}": "Lightroom import failed: {e}{warning}",
+ "Lightroom inspection failed: {e}{warning}": "Lightroom inspection failed: {e}{warning}",
"Label Set: {name}": "标签集:{name}",
"Quick Develop: {name}": "快速编辑:{name}",
"Reset {name}": "重置{name}",
diff --git a/crates/ui-egui/locales/zh-hant-formats.json b/crates/ui-egui/locales/zh-hant-formats.json
index 816936c0f..0147db0c1 100644
--- a/crates/ui-egui/locales/zh-hant-formats.json
+++ b/crates/ui-egui/locales/zh-hant-formats.json
@@ -40,6 +40,12 @@
"Imported {n} preset{}": "已匯入 {n} 個預設集{:.0}",
"Imported {n} preset{}, {f} file{} not readable": "已匯入 {n} 個預設集{:.0},{f} 個檔案無法讀取{:.0}",
"Imported {} photo{}": "已匯入 {} 張照片{:.0}",
+ "Lightroom catalog inspected: {photos} photos, {collections} collections, {missing} missing": "Lightroom catalog inspected: {photos} photos, {collections} collections, {missing} missing",
+ "Lightroom import complete: {imported} photos added": "Lightroom import complete: {imported} photos added",
+ "Lightroom import complete: {imported} photos added, {failed} failed": "Lightroom import complete: {imported} photos added, {failed} failed",
+ "Lightroom import complete: {imported} photos added; index warning: {warning}": "Lightroom import complete: {imported} photos added; index warning: {warning}",
+ "Lightroom import failed: {e}{warning}": "Lightroom import failed: {e}{warning}",
+ "Lightroom inspection failed: {e}{warning}": "Lightroom inspection failed: {e}{warning}",
"Label Set: {name}": "標籤集:{name}",
"Matches: {}": "符合條件:{}",
"Merging… {stage} {:.0}%": "正在合併… {stage} {:.0}%",
@@ -55,6 +61,7 @@
"Quick Develop · {n} photos": "快速顯像 · {n} 張照片",
"Quick Develop: {name}": "快速顯像:{name}",
"Rated {}": "評分:{}",
+ "Reading Lightroom catalog… {done} of {total}": "Reading Lightroom catalog… {done} of {total}",
"Reading photos… {done} of {total}": "正在讀取照片… {done}/{total}",
"Reading photos… {} of {}": "正在讀取照片… {}/{}",
"Redo {}": "重做 {}",
diff --git a/crates/ui-egui/src/lightroom_import.rs b/crates/ui-egui/src/lightroom_import.rs
index f841651df..8cee63e39 100644
--- a/crates/ui-egui/src/lightroom_import.rs
+++ b/crates/ui-egui/src/lightroom_import.rs
@@ -188,28 +188,38 @@ fn inspect_report(data: lightcraft_engine::lightroom_catalog::CatalogImport) ->
fn terminal(app: &mut LightcraftApp, ctx: &egui::Context, kind: Kind, value: Value) {
let message = if let Some(e) = value.get("error").and_then(Value::as_str) {
let warning = value.get("indexWarning").and_then(Value::as_str).map_or(String::new(), |w| format!("; index warning: {w}"));
- format!(
- "{}: {e}{warning}",
- crate::i18n::tr(if matches!(kind, Kind::Inspect) { "Lightroom inspection failed" } else { "Lightroom import failed" })
- )
+ if matches!(kind, Kind::Inspect) {
+ crate::i18n::tr_format!("Lightroom inspection failed: {e}{warning}", e = e, warning = warning)
+ } else {
+ crate::i18n::tr_format!("Lightroom import failed: {e}{warning}", e = e, warning = warning)
+ }
} else if value.get("cancelled").and_then(Value::as_bool).unwrap_or(false) {
crate::i18n::tr(if matches!(kind, Kind::Inspect) { "Lightroom inspection cancelled" } else { "Lightroom import cancelled" }).into()
} else if matches!(kind, Kind::Inspect) {
let photos = value["photos"].as_u64().unwrap_or(0);
let collections = value["collections"].as_u64().unwrap_or(0);
let missing = value["missing"].as_array().map_or(0, Vec::len);
- format!("{}: {photos} photos, {collections} collections, {missing} missing", crate::i18n::tr("Lightroom catalog inspected"))
+ crate::i18n::tr_format!(
+ "Lightroom catalog inspected: {photos} photos, {collections} collections, {missing} missing",
+ photos = photos,
+ collections = collections,
+ missing = missing
+ )
} else {
let report = value.get("report").unwrap_or(&value);
let imported = report["imported"].as_u64().unwrap_or(0);
let failed = report["failed"].as_array().map_or(0, Vec::len);
let warning = value.get("indexWarning").and_then(Value::as_str);
if let Some(warning) = warning {
- format!("{}: {imported} photos added; index warning: {warning}", crate::i18n::tr("Lightroom import complete"))
+ crate::i18n::tr_format!(
+ "Lightroom import complete: {imported} photos added; index warning: {warning}",
+ imported = imported,
+ warning = warning
+ )
} else if failed == 0 {
- format!("{}: {imported} photos added", crate::i18n::tr("Lightroom import complete"))
+ crate::i18n::tr_format!("Lightroom import complete: {imported} photos added", imported = imported)
} else {
- format!("{}: {imported} photos added, {failed} failed", crate::i18n::tr("Lightroom import complete"))
+ crate::i18n::tr_format!("Lightroom import complete: {imported} photos added, {failed} failed", imported = imported, failed = failed)
}
};
app.lightroom_last = Some(value);
@@ -410,7 +420,7 @@ pub fn progress(app: &mut LightcraftApp, ctx: &egui::Context) {
};
let text = match task.phase {
Phase::Reading if total == 0 => crate::i18n::tr("Reading Lightroom catalog…").into(),
- Phase::Reading => format!("{} {done} of {total}", crate::i18n::tr("Reading Lightroom catalog…")),
+ Phase::Reading => crate::i18n::tr_format!("Reading Lightroom catalog… {done} of {total}", done = done, total = total),
Phase::Committing => crate::i18n::tr("Adding Lightroom photos…").into(),
Phase::Finalizing => crate::i18n::tr("Saving Lightroom import index…").into(),
};