Skip to content

Conversation

@Sk7Str1p3
Copy link
Contributor

implement i18n for onefetch

resolves #1631

@Sk7Str1p3
Copy link
Contributor Author

currently CI build may fail because i used macro_vis crate, which produced warning `'macros' are experimental'. i dont know how to resolve it

@Sk7Str1p3
Copy link
Contributor Author

изображение made some progress

@Sk7Str1p3
Copy link
Contributor Author

just found one limitation - clap badly support i18n. trying to work around...

@Sk7Str1p3
Copy link
Contributor Author

изображение

yup, one issue fixed

@Sk7Str1p3
Copy link
Contributor Author

@o2sh i think this issue should be marked with "help-wanted"

Copy link
Collaborator

@spenserblack spenserblack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool idea. Before I look more into this, quick question: are the translations done at compile-time, or runtime?

i18n-embed-fl = "0.10.0"
rust-embed = "8.9.0"
macro-vis = "0.1.1"
clap-i18n-richformatter = { git = "https://github.com/Sk7Str1p3/clap-i18n-richformatter-0.1.4" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this dependency is going to need to be a published crate. Otherwise we won't be able to publish onefetch to crates.io

build.rs Outdated
.last()
.unwrap()
.as_os_str()
.to_str()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to convert to a str? Path::join should take several path-like types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was very stupid, not only because of conversion into str xdd. I'll fix it soon

build.rs Outdated
Comment on lines 47 to 50
create_dir_all(out_dir.join(lang)).unwrap();

let mut out_file =
BufWriter::new(File::create(out_dir.join(lang).join("onefetch.ftl"))?);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're calling out_dir.join twice, you probably would want to save the result to a variable instead.

@Sk7Str1p3
Copy link
Contributor Author

Sk7Str1p3 commented Nov 20, 2025

cargo-i18n checks locales during compilation and embeds them into binary, fluent loads and parses required locale at runtime. Tho I didn't notice any overhead, even on debug builds

@spenserblack
Copy link
Collaborator

cargo-i18n checks locales during compilation and embeds them into binary, fluent loads and parser required locale at runtime. Tho I didn't notice any overhead, even on debug builds

Perfect 👍

@Sk7Str1p3
Copy link
Contributor Author

almost finished cli. there're some issues with hard-coded values in clap

TODO: deal with `default` and `possible values`
@Sk7Str1p3 Sk7Str1p3 marked this pull request as draft November 22, 2025 12:51
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.

i18n

2 participants