Update README.rst#116
Conversation
Adding example on how to save a modified entry, as this is no where documented and for starters requires a lot of time to find.
|
You probably don't want to save for each entry. Suggest moving the second line you added out of the |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #116 +/- ##
=======================================
Coverage 95.28% 95.28%
=======================================
Files 1 1
Lines 849 849
=======================================
Hits 809 809
Misses 40 40 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@kthy is right, please update the PR to match a real usecase, thanks ! |
Indeed, no one would realistically want to set all entries to the same, fixed string. (and surely not save after every entry. Besides, My suggestion:
Something like this: for entry in pofile:
print(entry.msgid, entry.msgstr)
entry = pofile.find("foo") # by default it searches by msgid
if entry is not None:
entry.msgstr = "bar"
pofile.save('/path/to/pofile.po') # or simply pofile.save() to overwrite
pofile.save_as_mofile('/path/to/mofile.mo') # automatically compiles to `.mo` ! |
Adding example on how to save a modified entry, as this is no where documented and for starters requires a lot of time to find.