Mark format strings in po files

This allows msgfmt to detect issues with translations of format strings.
The detection used here is very simple. It just checks if a string contains '%',
and if it does, the entry in the po file is preceded by '#, c-format'.
Any entries with this marker are checked by msgfmt in our tests, so if an issue
arises, we will notice before it is merged.
This commit is contained in:
Daniel Rainer
2025-05-15 22:09:57 +02:00
parent cb31887941
commit e5fa047412

View File

@@ -44,9 +44,14 @@ begin
rm $cargo_expanded_file
# Sort the extracted strings and remove duplicates.
# Then, transform them into the po format
# Then, transform them into the po format.
# If a string contains a '%' it is considered a format string and marked with a '#, c-format'.
# This allows msgfmt to identify issues with translations whose format string does not match the
# original.
sort -u $rust_string_file |
sed -E 's/^(.*)$/msgid "\1"\nmsgstr ""\n/'
sed -E -e '/%/ i\
#, c-format
' -e 's/^(.*)$/msgid "\1"\nmsgstr ""\n/'
rm $rust_string_file