Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace rust-i18n with i18n-embed #1426

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nc7s
Copy link
Contributor

@nc7s nc7s commented Dec 11, 2024

As discussed in #1416. From there:

I'm also tempted to just do something akin to your patch, as doing this translation is simple enough that pulling in dependencies may be overkill.

Probably, if strings are to be fairly simple and keep that way. Optimize with phf, even.

Anyway, the new code is here for comparison.

This is a very crude draft with quite some points up for debate: code style and placement, workaround for locale override with config value (there's a comment about this), structure of i18n resources, and MSRV (enabling std::sync::LazyLock, but actually not very relevant to i18n).

Good news is this does not significantly affect compiled size (even down a few kilos actually).

@fujiapple852
Copy link
Owner

fujiapple852 commented Dec 12, 2024

Thanks, I'll review this properly later today.

One thing worth doing is re-introducing the locale::t! "wrapper" macro such that no changes are needed at the call site (i.e. everything in frontend::render).

I tested this locally and it seemed to work ok:

#[macro_export]
macro_rules! t {
    ($($all:tt)*) => {
        i18n_embed_fl::fl!($crate::locale::LANGUAGE_LOADER, $($all)*)
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants