Skip to content

Further performance improvements to gettext

Lukas 'ai-pi' Eipert requested to merge 28597-further-gettext-improvements into master

What does this MR do and why?

Remove unnecessary escapes from externalized strings

We have three externalized strings which unnecessarily escape a single quote. This becomes apparent with a different HAML parser.

Implement "custom" haml gettext parser

We currently use GettextI18nRails::HamlParser which is using hamlit to convert haml to ruby and then RubyGettextExtractor (also part of the gettext_i18n_rails gem) to extract externalized strings from the converted ruby code. This however seems to be slower than the GetText::RubyParser from the gettext gem. The performance difference comes from ruby_parser vs ripper. The tool also seems to find more strings, that the previous parser wasn't able to find.

Add guard to backend gettext extractor

Only about 10% of our rb, haml and erb files seem to contain externalized strings. We can add a simple guard that checks whether a file contains _( and only parse it, if it does. This leads to a massive performance improvement.

Screenshots or screen recordings

N/A

How to set up and validate locally

tooling/bin/gettext_extractor locale/gitlab.pot

MR acceptance checklist

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

Related to #28597 (closed)

Edited by Peter Leitzen

Merge request reports