Skip to content

Instantly share code, notes, and snippets.

@DrMartiner
Created July 20, 2017 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrMartiner/77d2c19f371eed96c4ac3b466ee823e1 to your computer and use it in GitHub Desktop.
Save DrMartiner/77d2c19f371eed96c4ac3b466ee823e1 to your computer and use it in GitHub Desktop.
Put po files to shuup project
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import os
import shutil
SHUUP_PATH = '~/.pyenv/versions/project/lib/python3.5/site-packages/shuup'
SOURCE_PATH = '~/projects/project'
for file_name in os.listdir(SOURCE_PATH):
m = re.match('^for_use_shuup_(.*)_ru.po$', file_name)
if m:
parts = m.group(1).split('-')
cur_path = os.path.join(
SHUUP_PATH, *parts, 'locale', 'ru', 'LC_MESSAGES'
)
if not os.path.exists(cur_path):
os.makedirs(cur_path)
src_path = os.path.join(SOURCE_PATH, file_name)
dst_path = os.path.join(cur_path, 'django.po')
shutil.copy(src_path, dst_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment