babel icon indicating copy to clipboard operation
babel copied to clipboard

`extract` overwrites existing template, and `update` comments unused

Open maxktz opened this issue 1 year ago • 2 comments

when i use pybabel extract or pybabel update there is no way to not remove existing translations, unused translations that existed in .pot or .po are being removed or commented.

Please add flag to save them while using this commands.

maxktz avatar May 18 '24 03:05 maxktz

extract never reads existing files – it just overwrites the given output file.

Have you tried --previous for pybabel update? Does it do what you need?

akx avatar Jul 17 '24 16:07 akx

--previous

About --previous, yes I guess it's what I need, it's just wasn't clear for me, what it really does. I would call it --keep-previous, or --keep-existing, something like that.

About --extract, I was wrong a little bit, that extract creates template, I thought it updates template file. But the problem is that it overwrites existing template.

There are some msgids that extract can't see in files, right? So I add them to template manually.

I want extract to have option to just update template file by extracted msgids, not overwrite, got it?

I have achieved that behavior by doing this (in case someone need it):

I just store manually added msgids in mymessages.pot template

Then run this commands:

# extract to messages.pot template
pybabel extract -F babel.cfg -o messages.pot .

# merge mymessages template to messages.pot
cat mymessages.pot >> messages.pot

# then update catalogs
pybabel update -i messages.pot -d ./translations

maxktz avatar Aug 12 '24 02:08 maxktz