-
Notifications
You must be signed in to change notification settings - Fork 627
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
slint-tr-extractor: add -j option to join to an existing file
- Loading branch information
Showing
1 changed file
with
24 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,9 @@ struct Cli { | |
// help = "Set the reporting address for msgid bugs. This is the email address or URL to which the translators shall report bugs in the untranslated strings" | ||
// )] | ||
// msgid_bugs_address: Option<String>, | ||
#[arg(long = "join-existing", short = 'j')] | ||
/// Join messages with existing file | ||
join_existing: bool, | ||
} | ||
|
||
fn main() -> std::io::Result<()> { | ||
|
@@ -50,24 +53,29 @@ fn main() -> std::io::Result<()> { | |
format!("{}.po", args.domain.as_ref().map(String::as_str).unwrap_or("messages")).into() | ||
}); | ||
|
||
let package = args.package_name.as_ref().map(|x| x.as_ref()).unwrap_or("PACKAGE"); | ||
let version = args.package_version.as_ref().map(|x| x.as_ref()).unwrap_or("VERSION"); | ||
let metadata = polib::metadata::CatalogMetadata { | ||
project_id_version: format!("{package} {version}",), | ||
pot_creation_date: chrono::Utc::now().format("%Y-%m-%d %H:%M%z").to_string(), | ||
po_revision_date: "YEAR-MO-DA HO:MI+ZONE".into(), | ||
last_translator: "FULL NAME <EMAIL@ADDRESS>".into(), | ||
language_team: "LANGUAGE <[email protected]>".into(), | ||
mime_version: "1.0".into(), | ||
content_type: "text/plain; charset=UTF-8".into(), | ||
content_transfer_encoding: "8bit".into(), | ||
language: String::new(), | ||
plural_rules: Default::default(), | ||
// "Report-Msgid-Bugs-To: {address}" addess = output_details.bugs_address | ||
let mut messages = if args.join_existing { | ||
polib::po_file::parse(&output) | ||
.map_err(|x| std::io::Error::new(std::io::ErrorKind::Other, x))? | ||
} else { | ||
let package = args.package_name.as_ref().map(|x| x.as_ref()).unwrap_or("PACKAGE"); | ||
let version = args.package_version.as_ref().map(|x| x.as_ref()).unwrap_or("VERSION"); | ||
let metadata = polib::metadata::CatalogMetadata { | ||
project_id_version: format!("{package} {version}",), | ||
pot_creation_date: chrono::Utc::now().format("%Y-%m-%d %H:%M%z").to_string(), | ||
po_revision_date: "YEAR-MO-DA HO:MI+ZONE".into(), | ||
last_translator: "FULL NAME <EMAIL@ADDRESS>".into(), | ||
language_team: "LANGUAGE <[email protected]>".into(), | ||
mime_version: "1.0".into(), | ||
content_type: "text/plain; charset=UTF-8".into(), | ||
content_transfer_encoding: "8bit".into(), | ||
language: String::new(), | ||
plural_rules: Default::default(), | ||
// "Report-Msgid-Bugs-To: {address}" addess = output_details.bugs_address | ||
}; | ||
|
||
Messages::new(metadata) | ||
}; | ||
|
||
let mut messages = Messages::new(metadata); | ||
|
||
for path in args.paths { | ||
process_file(path, &mut messages)? | ||
} | ||
|