Skip to content

Commit

Permalink
Fix bug:- Po File pull does not show any translated text from server
Browse files Browse the repository at this point in the history
  • Loading branch information
anish committed Sep 19, 2014
1 parent a9ac7ea commit e0a5186
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions zanataclient/publicanutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ def save_to_pofile(self, path, translations, pot, create_skeletons, locale, doc_
@param pot: the json object of the pot retrieved from server
"""
po = polib.POFile(fpath=path)



potcontent = json.loads(pot)
# pylint: disable=E1103
textflows = potcontent.get('textFlows')
Expand All @@ -383,10 +384,11 @@ def save_to_pofile(self, path, translations, pot, create_skeletons, locale, doc_
re.sub(pattern, "charset=UTF-8", po.metadata['Content-Type'])
else:
po.metadata['Content-Type']="text/plain; charset=UTF-8"

for textflow in textflows:
poentry = polib.POEntry(occurrences=None)
poentry.msgid = textflow.get('content')
if textflow.get('extensions'):
poentry = polib.POEntry(occurrences=None)
entry_list = textflow.get('extensions')
for entry in entry_list:
if entry.get('object-type') == 'pot-entry-header':
Expand Down Expand Up @@ -415,15 +417,14 @@ def save_to_pofile(self, path, translations, pot, create_skeletons, locale, doc_
if entry.get('object-type') == 'comment':
#SimpleComment
poentry.comment = entry.get('value')

poentry.msgid = textflow.get('content')
if textflow.get('contents'):
poentry.msgid = textflow.get('contents')[0]
poentry.msgid_plural = textflow.get('contents')[1]
poentry.msgstr_plural[0] = ''
else:
poentry.msgstr = ''
po.append(poentry)

if textflow.get('contents'):
poentry.msgid = textflow.get('contents')[0]
poentry.msgid_plural = textflow.get('contents')[1]
poentry.msgstr_plural[0] = ''
else:
poentry.msgstr = ''
po.append(poentry)

#If the translation is exist, read the content of the po file
if translations:
Expand Down Expand Up @@ -452,7 +453,6 @@ def save_to_pofile(self, path, translations, pot, create_skeletons, locale, doc_
translationsByResId[resId] = translation

#"extensions":[{"object-type":"comment","value":"testcomment","space":"preserve"}]

# copy any other stuff you need to transfer
for poentry in po:
resId = self.get_resId(poentry)
Expand Down

0 comments on commit e0a5186

Please sign in to comment.