How to automatically remove unused gettext strings?

I have a web application in which I have multiple translations using gettext. But now I have made a big redistribution of the application, and although most of the lines are the same, there are also many that have been significantly modified or deleted.

I use xgettext to create .po files, and it’s great when you can find new lines in the code and add them to the .po files, but I don’t see the possibility of deleting lines that are not found in the code.

Is there an automatic way to remove lines from .po files that are no longer in code?

+5
source share
2 answers

, PO, , PO messages.pot, PO message.po, :

msgattrib --set-obsolete --ignore-file=messages.pot -o messages.po messages.po

. --set-obsolete msgattrib , --ignore-file , ( PO ).

, :

msgattrib --no-obsolete -o messages.po messages.po

msgattrib .

+3

find . -name '*.po' -print0 | while read -d '' -r file; do msgattrib --output-file="$file" --no-obsolete "$file"; done
0

All Articles