Register functions in translation
This commit is contained in:
parent
66daca1a85
commit
6782a190f2
2 changed files with 3 additions and 2 deletions
|
|
@ -192,7 +192,7 @@ pub fn fluent_bundle(
|
|||
Ok(Some(bundle))
|
||||
}
|
||||
|
||||
fn register_functions(bundle: &mut FluentBundle) {
|
||||
pub fn register_functions<R, M>(bundle: &mut fluent_bundle::bundle::FluentBundle<R, M>) {
|
||||
bundle
|
||||
.add_function("STREQ", |positional, _named| match positional {
|
||||
[FluentValue::String(a), FluentValue::String(b)] => format!("{}", (a == b)).into(),
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ use std::env;
|
|||
use std::error::Report;
|
||||
use std::sync::Arc;
|
||||
|
||||
use rustc_error_messages::langid;
|
||||
pub use rustc_error_messages::{FluentArgs, LazyFallbackBundle};
|
||||
use rustc_error_messages::{langid, register_functions};
|
||||
use tracing::{debug, trace};
|
||||
|
||||
use crate::error::{TranslateError, TranslateErrorKind};
|
||||
|
|
@ -91,6 +91,7 @@ impl Translator {
|
|||
let mut bundle = fluent_bundle::FluentBundle::new(vec![langid!("en-US")]);
|
||||
bundle.set_use_isolating(false);
|
||||
bundle.add_resource(resource).unwrap();
|
||||
register_functions(&mut bundle);
|
||||
let message = bundle.get_message(GENERATED_MSG_ID).unwrap();
|
||||
let value = message.value().unwrap();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue