-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create binaries to support stand-alone usage #68
Comments
Howdy @mgeisler -- I would like to work on this :) Just to clarify - we want to read an MD file from std input, normalize the markdown, and convert to a PO file.
Please let me know if I am misunderstanding or need clarification! |
While building the translation machinery here, I realized that we don't need to tie it to mdbook. We are able to do the
My thinking is even simpler: the extraction binary should do what As you can see, for (lineno, msgid) in extract_messages(&chapter.content) {
let source = format!("{}:{}", path.display(), lineno);
add_message(&mut catalog, &msgid, &source);
} You'll then need a bit of boiler plate around it to parse command line arguments. You can probably find inspiration in the Similar for a translation program: it would take a Markdown file (or perhaps a directory of files?) plus a PO file and produce a translated output. That is essentially what See also https://po4a.org/. I've only skimmed the documentation for that project, but my understanding is that it can produce PO files for anything, including Markdown. It would be very interesting to compare our extraction mechanism with the one they have — I don't know how they compare at all right now. That comparison would go into a README or help text for the new binaries. We might even create a new crate for this, it could depend on the library part of mdbook-i18n-helpers. Users who install the new crate would avoid building the mdbook-specific parts which they don't need. |
The
mdbook-xgettext
plugin can currently only be used frommdbook
since it reads a special JSON format on standard input. However, it would be quite easy to use the same code to extract text from any Markdown file on disk. We should create a small binary which does this.Similarly for
mdbook-gettext
: we should create a small binary which will translate a Markdown file into another language using a PO file.Having these binaries would make it slightly easier to text our own code:
should be enough to produce a PO file on standard output (it would show that
*bar*
is normalized to_bar_
, for example). I could have used this kind of ad-hoc testing when I was battling corner-cases in #33.The text was updated successfully, but these errors were encountered: