#mdbook #fluent #variables #language #interpolation

bin+lib mdbook-fluent

mdBook preprocessor for variable interpolation using the Fluent language

1 unstable release

0.1.0 Mar 21, 2020

#350 in Internationalization (i18n)

MIT/Apache

24KB
256 lines

mdbook-fluent

A simple WIP preprocessor for mdBook. It uses the Fluent language to interpolate variables inside your book. Building on the shoulders of giants via the fluent-rs Rust implementation of the Fluent Project.

DISCLAIMER:
This preprocessor is not designed to be used to translate books! This is because mdBook itself is not designed this way!

Getting started

Check out the ./examples/example folder for a working example.

Install

cargo install mdbook-fluent

book.toml

Add this to your book.toml:

[preprocessor.fluent]

Fluent files

In the fluent directory create files with the .ftl extension containing your variables. The name of each file will be used to group the variables into logical chunks.

You can use the dir key in the config to change the name of the directory containing your .ftl files.

Example Fluent File:

# fluent/example.ftl
Hello-world = Hello, world!
some-variable =
    .some-attribute = xd
multi-line =
    This is a multi-line Fluent value.
    The spaces before these lines will be automatically
    removed!

Syntax:

In your books use the {{#fluent FILE_NAME.TAG}} or {{#fluent FILE_NAME.TAG.ATTRIBUTE syntax, like so:

# Chapter 1

```
{{#fluent ch01.Hello-world}}
```

```rust,include
{{#include ../listing/example.rs}}
```

As you can see above, you can put the same {{#fluent tags inside other files that will be included.

Build

Now simply build your book like you would normally:

mdbook build

Contributions

I welcome any contributions, whether they would be issues, feature requests, pull requests or questions.

License

MIT and APACHE

Dependencies

~17–29MB
~441K SLoC