locale, factor, shuf: Example of deferred locale loading for clap#10911
locale, factor, shuf: Example of deferred locale loading for clap#10911ChrisDryden wants to merge 3 commits intouutils:mainfrom
Conversation
|
Whoops didn't realize, uudoc calls uuapp directly, should be a simple fix to swap the names of the two uuapp functions and it should work backwards compatible. Just waiting to see the perf numbers and the gnu test results |
|
GNU testsuite comparison: |
Merging this PR will degrade performance by 4.94%
Performance Changes
Comparing Footnotes
|
|
This should also unblock us from doing translations in all of the shared libraries because there will no longer be the performance penalty hit from adding a bunch of translations into the shared locale file |
|
GNU testsuite comparison: |
| /// .help_template(localized_help_template("myutil")); | ||
| /// ``` | ||
| pub fn localized_help_template(util_name: &str) -> clap::builder::StyledStr { | ||
| pub fn localized_help_template(_util_name: &str) -> clap::builder::StyledStr { |
There was a problem hiding this comment.
maybe remove _util_name if we don't use it anymore?
| let name = cmd.get_name().to_string(); | ||
|
|
||
| cmd = cmd | ||
| .about(crate::locale::get_message(&format!("{name}-about"))) |
There was a problem hiding this comment.
i wonder if we follow the same standard everywhere ?
|
Hi ! I've also tried to work a bit on the localization system and your defer implementation is really game changer. I just have a few remarks :
|
A few month ago I attempted the same thing but now I've got a much better understanding of the project to attempt it again. The change here is that there is a parse_deferred handler now that attempts to parse the clap arguments and it it fails it will reattempt it with the locale files loaded. This combined with changes in the default locale initialization to take the util_name at the beginning from the arguments allows us to not have to load the locale file until the translation is actually required.
This requires migrating each utility to this new format, but I already started the process for factor and shuf to start.
This change is also required for the
ls/stat-free-symlinkgnu test and it should make the valgrind tests much more stable since it runs twice as fast in local testing and less likely to timeout.