Skip to content

Commit 1da78fc

Browse files
committed
Add version metadata handling in merge command
Introduced logic to set the `version` field in resources during the merge process. The version is derived from the first resource's metadata or defaults to "1.0" if not present. This enhancement ensures compatibility with xcstrings format and improves overall resource metadata management alongside the existing `source_language` handling.
1 parent f6f835f commit 1da78fc

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

langcodec-cli/src/merge.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,22 @@ pub fn run_merge_command(
8383

8484
println!("Setting metadata.source_language to: {}", source_language);
8585

86+
// Set version field in the resources to make sure xcstrings format would not throw an error
87+
let version = codec
88+
.resources
89+
.first()
90+
.and_then(|r| r.metadata.custom.get("version").cloned())
91+
.unwrap_or_else(|| "1.0".to_string());
92+
93+
println!("Setting metadata.version to: {}", version);
94+
8695
codec.iter_mut().for_each(|r| {
8796
r.metadata
8897
.custom
8998
.insert("source_language".to_string(), source_language.clone());
99+
r.metadata
100+
.custom
101+
.insert("version".to_string(), version.clone());
90102
});
91103

92104
if let Err(e) = converter::convert_resources_to_format(codec.resources, &output, format)

0 commit comments

Comments
 (0)