import os
import polib

from django.core.management.base import BaseCommand
from django.conf import settings


class Command(BaseCommand):
    help = "Populate .po file provided with fake data."

    def add_arguments(self, parser):
        parser.add_argument('language_code')

    def handle(self, *args, **options):
        locale_path = settings.LOCALE_PATHS[0]
        file_path = options['language_code'] + '/LC_MESSAGES/django.po'
        file_path = os.path.join(locale_path, file_path)
        po_file = polib.pofile(file_path)
        for entry in po_file:
            entry.msgstr = 'fakeTTTfake'
        po_file.save()
