-
Notifications
You must be signed in to change notification settings - Fork 4
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
Build process suggestions #8
Comments
As you might guess, I'm willing to work on this. :) But I'm not very knowledgeable about the way gettext works in general, especially the purpose of the different files (pot vs mo for example). Since you've already open this issue #4 maybe the whole process can be simplified |
Hello 🙂
The
I don't really like that, but I don't know if there is a better way… Otherwise, what you propose sounds good to me.
The idea is that you generate a template ( If you have any other question, I will be glad to answer. 😊 |
Yes... and when actually writing the code, I found out that every time a new msgid is added with i18n!, cargo build needs to be rerun. It's a bit like the table of contents in latex. On the other hand, if the .mo files are compiled after the build (like how it's currently done with compile_i18n!), then cargo build has to be run twice when a .po file is updated. |
Do translation platforms need the .mo files? |
No, only the app needs them. |
Then PR #9 is ready :) |
Ok, thank you. I will try to review it today or tomorrow. 🙂 |
The current build process is a bit complicated/fragile for the following reasons:
msgmerge
creates are not reported duringcargo build
po/$DOMAIN/
folder)include_i18n!
panics whentranslations/
doesn't exist, but this folder is only created bycompile_i18n!
, which is executed aftertranslations
folder, and.pot
files are compilation artifacts, but aren't intarget/
CARGO_TARGET_DIR
is only set by the user, Cargo only reads it (Set a target for build scripts' products rust-lang/cargo#5457), (gettext-macros/src/lib.rs
Line 366 in 27483fa
cargo build
has to be run twice to apply changes in.po
filesI suggest that:
init_i18n
andcompile_i18n
should be normal functions, that are to be called in a build script.Output of build scripts is inhibited by Cargo, except when it's formatted as
cargo:warning=...
, then it shows as a compilation warning. Warnings can be used to showmsgfmt --statistics
output (especially to see if there are new fuzzy translations).translations/
should betarget/translations/
target/debug/gettext_macros/$DOMAIN
should be insidetarget/translations
, because it's common to debug and release buildsSo.. an example of the new process would be:
Because build script are called before the actual compilation starts, the first time
compile_i18n
is called, it would only do whatinit_i18n!
does:.pot
/.mo
files for the new languages (though don't know which one it should create? cf. Make it possible to choose what is compiled #4,include_i18n!
reads from the.mo
, butinit_i18n!
creates a.pot
)po/$DOMAIN/$LANGUAGES.po
files withmsginit
cargo build
againThen during the first compilation,
i18n!
macros would populate the.pot
file, andinclude_i18n!
would silently include the contents of the (empty).mo
file (instead of crashing).During the next build,
compile_i18n
would do what's listed above, then callmsgmerge
with the populated.pot
files, andmsgfmt
to create the.mo
file. This would allowinclude_i18n!
to include the new translations directly, instead of having to callcargo build
twiceThe text was updated successfully, but these errors were encountered: