Crates.io | mdbook-fluent |
lib.rs | mdbook-fluent |
version | 0.1.0 |
source | src |
created_at | 2020-03-21 18:10:24.425709 |
updated_at | 2020-03-21 18:10:24.425709 |
description | mdBook preprocessor for variable interpolation using the Fluent language |
homepage | |
repository | https://github.com/JakubKoralewski/mdbook-fluent |
max_upload_size | |
id | 221033 |
size | 77,325 |
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!
Check out the ./examples/example folder for a working example.
cargo install mdbook-fluent
Add this to your book.toml
:
[preprocessor.fluent]
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!
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.
Now simply build your book like you would normally:
mdbook build
I welcome any contributions, whether they would be issues, feature requests, pull requests or questions.