Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving accidentally removes obsolete Entry's previous_msgid #158

Open
planetis-m opened this issue Sep 15, 2024 · 1 comment
Open

Saving accidentally removes obsolete Entry's previous_msgid #158

planetis-m opened this issue Sep 15, 2024 · 1 comment

Comments

@planetis-m
Copy link

Repro:

# File: a.py
import polib

po_filepath = 'test_po_file.po'
# Create a new PO file
po = polib.POFile()

# Add a fuzzy entry
fuzzy_entry = polib.POEntry(
  msgid='fuzzy_message',
  msgstr='ασαφής_εικόνα',
  previous_msgid='fuzzy_image',
  fuzzy=True,  # Mark as fuzzy
  obsolete=True  # Mark as obsolete
)
po.append(fuzzy_entry)

# Save the PO file
po.save(po_filepath)

The .po file's contents:

#
msgid ""
msgstr ""

#~| msgid "fuzzy_image"
#~ msgid "fuzzy_message"
#~ msgstr "ασαφής_εικόνα"
# file: b.py
import polib

po_filepath = 'test_po_file.po'

# Reopen the PO file
po = polib.pofile(po_filepath)
po.save(po_filepath)

After running b.py

#
msgid ""
msgstr ""

#~ msgid "fuzzy_message"
#~ msgstr "ασαφής_εικόνα"
@planetis-m
Copy link
Author

planetis-m commented Sep 15, 2024

Oh boy:

polib/polib.py

Lines 1360 to 1361 in 85f6d1c

if tokens[0] == '#~|':
continue

Edit: dirty hack:

                if tokens[0] == '#~|':
                    # continue
                    tokens[0] = '#|'
                    line = '#|' + line[3:]
                    self.entry_obsolete = 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant