Crates.io | fluent-fmt |
lib.rs | fluent-fmt |
version | 0.1.1 |
source | src |
created_at | 2021-03-28 11:06:09.217348 |
updated_at | 2021-03-29 07:15:15.187454 |
description | Configurable formatter for fluent `ftl` file |
homepage | |
repository | https://github.com/doki-land/doki-system-fluent |
max_upload_size | |
id | 374624 |
size | 11,051 |
Doki use fluent for localization,
// in notedown
// config.language is current language
\locale::SOME_FILED("title", lang=config.language)
// in template
<locale::SOME_FILED default="title" lang=config.language/>
Here are some auxiliary libraries:
ftl
file.call with doki locale fmt
use fluent_fmt::FluentFormatter;
use fluent_syntax::parser::parse;
#[test]
fn parsing() {
let mut ctx = FluentFormatter::default();
let ftl = r#"
### Resource Level Comment
### * Resource Level Comment2
### * Resource Level Comment3
# This is a message comment
time-elapsed = Time elapsed: {
NUMBER($duration, maximumFractionDigits: 0)
}s.
.placeholder = email@example.com
.aria-label = Login input value
.title = Type your login email
# Complex things are possible.
shared-photos =
{$userName} {$photoCount ->
[one] added a new photo
*[other] added {
$photoCount
} new photos
} to {
$userGender ->
[male] his stream
[female] her stream
*[other] their stream
}.
"#;
let out = parse(ftl).unwrap();
// println!("{:#?}", out);
println!("{}", ctx.pretty_print(out).unwrap())
}
call with doki locale mis