XAMPPRocky/fluent-templates

Compile time i18n macro

Open

#53 创建于 2023年9月7日

在 GitHub 查看
 (8 评论) (0 反应) (0 负责人)Rust (38 fork)auto 404
enhancementgood first issuehelp wanted

仓库指标

Star
 (167 star)
PR 合并指标
 (PR 指标待抓取)

描述

Discussed in https://github.com/XAMPPRocky/fluent-templates/discussions/52

Originally posted by patefacio September 5, 2023 For compile-time support is it possible to get a compile error when compiling if the lookup fails? I tried cargo-i18n with i18n-embed and in that setup a mispelling will trigger a compile error. My issue with that setup was I could not figure out how to make it work in wasm. This project works just fine in wasm but the forced breakage at compile time would be great.

assert_eq!("Hello World!", LOCALES.lookup(&US_ENGLISH, "hello-world-ooops"));

Thank you for question! I think this should be possible if implemented as procedural macro. I don't have much time to work on this at the moment, but I'd be happy to review a PR for it. We already have a macro crate, so what would work would be to add a new macro similar to the existing one, but that uses the ArcLoader to load localisations into the macro itself, and then provides a panic message when it's not found using a separate lookup macro.

贡献者指南