Askama base crate i18n support#845
Conversation
…ama into askama_base_crate_i18n_support
| with-rocket = ["askama_derive/with-rocket"] | ||
| with-tide = ["askama_derive/with-tide"] | ||
| with-warp = ["askama_derive/with-warp"] | ||
| i18n = ["askama_derive/i18n", "fluent-templates"] |
There was a problem hiding this comment.
as this is a fluid backed i18n, would it be appropriate to self-document that in the feature name? e.g. i18n_fluent?
Ben-PH
left a comment
There was a problem hiding this comment.
I'm by no means a heavy-hitter. I'm just passing through in my search of "the good way" to add i18n to my askama project, and thought I'd try to do my little part.
nothing in this review should be considered blocking. I didn't see any issues, but that by no means implies I didn't miss any. I hope this helps. I really look forward to askama + fluent being able to Just Work^tm
| for (k, v) in args { | ||
| buf.write(&format!("({:?}, ::askama::i18n::FluentValue::from(", k)); | ||
| self.visit_expr(buf, v)?; | ||
| buf.writeln(")),")?; |
| #[cfg(feature = "i18n")] | ||
| match i18n::load(_input) { | ||
| Ok(ts) => ts, | ||
| Err(err) => err.into_compile_error(), | ||
| } | ||
|
|
||
| #[cfg(not(feature = "i18n"))] | ||
| CompileError::from(r#"Activate the "i18n" feature to use i18n_load!()."#).into_compile_error() |
There was a problem hiding this comment.
If you mean the crate, I'd prefer not to add more dependencies unless we really need them.
| Call(Box<Expr<'a>>, Vec<Expr<'a>>), | ||
| RustMacro(Vec<&'a str>, &'a str), | ||
| Try(Box<Expr<'a>>), | ||
| #[allow(dead_code)] |
There was a problem hiding this comment.
Is it feasible to feature gate this instead?
| #[cfg(not(feature = "i18n"))] | ||
| fn expr_localize(i: &str) -> IResult<&str, Expr<'_>> { | ||
| let (i, _) = pair(tag("localize"), ws(tag("(")))(i)?; | ||
| eprintln!(r#"Activate the "i18n" feature to use {{ localize() }}."#); | ||
| Err(nom::Err::Failure(error_position!(i, ErrorKind::Tag))) | ||
| } | ||
|
|
||
| #[cfg(feature = "i18n")] |
| pub fn new(language: LanguageIdentifier, loader: &'static StaticLoader) -> Self { | ||
| Self { loader, language } | ||
| } | ||
|
|
5633250 to
704f8f1
Compare
Depends on #844 :
Localestruct behind feature flag,parking_lot, since it was used as part of the unsafe code