Skip to content

Commit b19c24f

Browse files
authored
Merge pull request #87 from google/pot-creation-date
Set POT-Creation-Date in newly generated POT files
2 parents d2eccdd + 0cdc55b commit b19c24f

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ description = "Plugins for a mdbook translation workflow based on Gettext."
1111

1212
[dependencies]
1313
anyhow = "1.0.68"
14+
chrono = { version = "0.4.31", default-features = false, features = ["alloc"] }
1415
mdbook = { version = "0.4.25", default-features = false }
1516
polib = "0.2.0"
1617
pulldown-cmark = { version = "0.9.2", default-features = false }

src/bin/mdbook-xgettext.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ fn create_catalog(ctx: &RenderContext) -> anyhow::Result<Catalog> {
4848
if let Some(lang) = &ctx.config.book.language {
4949
metadata.language = String::from(lang);
5050
}
51+
let now = chrono::Local::now();
52+
metadata.pot_creation_date = now.to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
5153
metadata.mime_version = String::from("1.0");
5254
metadata.content_type = String::from("text/plain; charset=UTF-8");
5355
metadata.content_transfer_encoding = String::from("8bit");
@@ -149,6 +151,8 @@ mod tests {
149151

150152
let catalog = create_catalog(&ctx).unwrap();
151153
assert_eq!(catalog.metadata.project_id_version, "");
154+
assert!(!catalog.metadata.pot_creation_date.is_empty());
155+
assert!(catalog.metadata.po_revision_date.is_empty());
152156
assert_eq!(catalog.metadata.language, "en");
153157
assert_eq!(catalog.metadata.mime_version, "1.0");
154158
assert_eq!(catalog.metadata.content_type, "text/plain; charset=UTF-8");

0 commit comments

Comments
 (0)