Skip to content

Improve gettext regeneration performance

Lukas Eipert requested to merge leipert-gettext-regenerate-performance into master

What does this MR do and why?

When regenerating our locale/gitlab.pot file with all externalized translation, we currently call the gettext:find command from the gettext_i18n_rails gem. Under the hood this task calls:

  • gettext:setup
  • gettext:po:update, which calls:
    • gettext:pot:create to create the pot file
    • gettext:po:*:update on every locale

We are actually not interested in updating the po files as part of this regeneration process, because we actively revert changes on them as part of our gettext:regenerate task. (Our po files are updated based on updates from Crowdin).

Therefore we can simplify our regeneration process to actively call:

  • gettext:setup
  • gettext:pot:create

This cuts down the regeneration time dramatically (157s => 48s) on my machine.

As an added benefit, I've just updated the gettext:updated_check command to use our updated gettext:regenerate, which also means we will have these performance benefits in CI.

Screenshots or screen recordings

N/A

How to set up and validate locally

  1. Change any externalized string
  2. Run bundle exec rake gettext:regenerate or bundle exec rake gettext:updated_check

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Leitzen

Merge request reports