import subprocess
from pathlib import Path
from tof.management.commands.create_js_from_static_translation import Command
from . import _, get_language
from .views import ActionView
[docs]
class GenerateTranslationJSONFileAction(ActionView):
description = _('Generate translation JSON file for front')
short_description = _('Generate translation JSON file for front')
allow_empty = True
finished_message = _('Success')
[docs]
def processing(self, *args, **kwargs):
if Path(f'{Command.locale_dir}').exists():
current_lang_file = Path(f'{Command.locale_dir}') / f'{get_language()}.json'
if not current_lang_file.exists():
open(current_lang_file, 'a').close()
Command().handle()
return super().processing(*args, **kwargs)
return self.cancel(message=_("Can not create language files, the path {} is not exists").format(Command.locale_dir))