Michael Koper
Michael Koper

Reputation: 9781

How to delete obsolete translations in gettext

i use gettext for a rails project and every time i start my server i get messages like

Warning: obsolete msgid exists.
     #~ "some tranlation: "
Warning: obsolete msgid exists.
     #~ "some tranlation: "
...
...

Now i know these are just translations that arent used anymore. I would like to delete them but instead of modifying all the .po files i would like to do it with a command.

Is there an easy way to quickly get rid of those translations?

Gems used:

 gem 'gettext', '>=1.9.3', :require => false
 gem 'gettext_i18n_rails'

Upvotes: 3

Views: 2169

Answers (3)

fisharebest
fisharebest

Reputation: 1350

The gettext utilities include a command to do exactly this

msgattrib --output-file=xxx.po --no-obsolete xxx.po

Upvotes: 6

karellm
karellm

Reputation: 1923

I ran into the same problem and I used PoEdit to delete them.

Go in Catalog>Purge deleted translations. Then you can run rake gettext:pack again and the messages should go.

Note: by default, poedit will create a .mo file sitting next to the .po file. You may want to turn off the option in the settings or just delete the .mo manually.

Upvotes: 1

Martin Vidner
Martin Vidner

Reputation: 2337

I don't know how to do it without deleting them, but here's how to automate the deletion with a shell command:

find -name \*.po | xargs sed -i.bak -e '/^#~/d'

Upvotes: 0

Related Questions