- changed status to resolved
Missing head-entry breaks projet push
Issue #3
resolved
I am using react-intl-po to convert react-intl message definitions to and from .po(t) files.
The problem I am currently facing with using zanata-js to be able to push these po-files is that react-intl-po does not add the head entry to the .pot-files.
Due to this zanata-js breaks here and here because the code just assumes everything to be fine and dandy.
My suggestion is to add the following "protection" to the code:
ext.entries = Object.keys(po.headers || []).map((k) => { // <- defaulting to empty headers
return {key: k, value: po.headers[k]};
});
if (po.translations && po.translations[''] && po.translations[''][''] && po.translations[''][''].comments) // <- Checking the entire depth of the object
ext.comment = po.translations[''][''].comments.translator;
An alternative approach if you do not want to support "invalid" .pot files is to throw a more informative error-message telling the user that the head entry is missing instead of cryptic TypeErrors.
Comments (2)
-
repo owner -
reporter Thank you for a prompt fix, works beautifully!
- Log in to comment
Fix a fail on converting an imcomplete POT to JSON
fixes
#3→ <<cset 320c2f437571>>