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

Add binary MO translation file support. #59276

Merged
merged 1 commit into from
Mar 22, 2022
Merged

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Mar 18, 2022

Adds support for binary MO files (same features, but smaller).

TODO:

  • Test context and plurals are loaded correctly (neither seems to be actively used by the engine)

Also, added an extra check for text PO loader, to prevent crash in case of invalid "Plural-Forms" string.

Node: with the currently enabled editor / class-ref translations, converting them to MO can decrease editor binary size by 1.6 MB (probably substantially more if incomplete translations are included).

@bruvzg bruvzg marked this pull request as ready for review March 18, 2022 21:23
@bruvzg bruvzg requested a review from a team as a code owner March 18, 2022 21:23
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Looks great!

I assume that to actually benefit from this in editor builds we'd need to add a buildsystem step using gettext to generate the MO files? (Probably optional, if gettext is found.)

@akien-mga akien-mga merged commit 4426732 into godotengine:master Mar 22, 2022
@akien-mga
Copy link
Member

Thanks!

@bruvzg bruvzg deleted the mo_trans branch March 22, 2022 11:50
@bruvzg
Copy link
Member Author

bruvzg commented Mar 22, 2022

I assume that to actually benefit from this in editor builds we'd need to add a buildsystem step using gettext to generate the MO files? (Probably optional, if gettext is found.)

Yes, we have to run msgfmt xx.po --no-hash -o xx.mo for each file, I have not added it since gettext is usually not available on Windows/MSVC setups, but I guess making it optional is also OK.

@Calinou
Copy link
Member

Calinou commented Mar 25, 2022

Like #59275, I wonder if this could benefit from a 3.x backport (along with #59483). It might not be too difficult for me to do, I'm just asking here in case there's a blocker or you've already started a 3.x backport.

@bruvzg
Copy link
Member Author

bruvzg commented Mar 25, 2022

Both should be easy to backport, but 3.x editor use smaller number of fonts so impact would be less as well.

@bruvzg
Copy link
Member Author

bruvzg commented Mar 25, 2022

I have not fully tested it, but it seems to remove almost 7 MB, so probably worth it - #59522

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

Successfully merging this pull request may close these issues.

3 participants