Skip to content

Commit

Permalink
Merge pull request #93 from google/wrap-sources
Browse files Browse the repository at this point in the history
Wrap the source lines like `msgmerge` does
  • Loading branch information
mgeisler authored Oct 2, 2023
2 parents 5e8f203 + e680e80 commit 94d3fb5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions i18n-helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pulldown-cmark-to-cmark = "11.0.0"
regex = "1.9.4"
semver = "1.0.16"
serde_json = "1.0.91"
textwrap = { version = "0.16.0", default-features = false }

[dev-dependencies]
pretty_assertions = "1.3.0"
Expand Down
5 changes: 4 additions & 1 deletion i18n-helpers/src/bin/mdbook-xgettext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ use polib::metadata::CatalogMetadata;
use std::{fs, io};

fn add_message(catalog: &mut Catalog, msgid: &str, source: &str) {
let wrap_options = textwrap::Options::new(76)
.break_words(false)
.word_splitter(textwrap::WordSplitter::NoHyphenation);
let sources = match catalog.find_message(None, msgid, None) {
Some(msg) => format!("{}\n{}", msg.source(), source),
Some(msg) => textwrap::refill(&format!("{}\n{}", msg.source(), source), wrap_options),
None => String::from(source),
};
let message = Message::build_singular()
Expand Down

0 comments on commit 94d3fb5

Please sign in to comment.