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

Fix plugins for multi languages #82

Merged
merged 1 commit into from May 21, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 14 additions & 5 deletions v7/upgrade_metadata/upgrade_metadata.py
Expand Up @@ -69,11 +69,20 @@ def _execute(self, options, args):
yesno = utils.ask_yesno("Proceed with metadata upgrade?")
if options['yes'] or yesno:
for post in flagged:
with io.open(post.metadata_path, 'r', encoding='utf-8') as fh:
meta = fh.readlines()
with io.open(post.metadata_path, 'w', encoding='utf-8') as fh:
for k, v in zip(self.fields, meta):
fh.write('.. {0}: {1}'.format(k, v))
for lang in post.translated_to:
if lang == post.default_lang or len(post.translated_to) == 1:
fname = post.metadata_path
else:
fname = self.site.config['TRANSLATIONS_PATTERN'].format(path=post.post_name, lang=lang, ext='meta')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s better to use os.path.splitext(post.translated_source_path(lang)) — this is more-or-less what post.py does to find the meta files. Fixed on master.


with io.open(fname, 'r', encoding='utf-8') as fh:
meta = fh.readlines()
L.debug("post " + fname + " updated")

with io.open(fname, 'w', encoding='utf-8') as fh:
for k, v in zip(self.fields, meta):
fh.write('.. {0}: {1}'.format(k, v))

L.info('{0} posts upgraded.'.format(len(flagged)))
else:
L.info('Metadata not upgraded.')
Expand Down