from recpermissions import __version__
from recpermissions.i18n import _ # Import the translation function
from os import system


def pytest():
    system("pytest")
    
def coverage():
    system("coverage run --omit='recpermissions/tests/*' -m pytest && coverage report && coverage html")

def release():
    print(_("New Release:"))
    print(_("  * Create a Github issue with the new version tag"))
    print(_("  * Change version and datetime in version.py and in pyproject.toml"))
    print("  * poe translate")
    print("  * Use IA to translate with vscode")
    print("  * poe translate")
    print("  * poe coverage")
    print("  * git commit -a -m 'recpermissions-{}'".format(__version__))
    print("  * git push")
    print(_("  * Make a pull request to main branch"))
    print(_("  * Make a new tag in github"))
    print("  * poetry publish")
    print(_("  * Create a new gentoo ebuild with the new version and install it"))
    print(_("  * Upload to portage repository")) 


def translate():
    #es
    system("xgettext -L Python --no-wrap --no-location --from-code='UTF-8' -o recpermissions/locale/recpermissions.pot recpermissions/*.py")
    system("msgmerge -N --no-wrap -U recpermissions/locale/es.po recpermissions/locale/recpermissions.pot")
    system("msgmerge -N --no-wrap -U recpermissions/locale/fr.po recpermissions/locale/recpermissions.pot")
    system("msgfmt -cv -o recpermissions/locale/es/LC_MESSAGES/recpermissions.mo recpermissions/locale/es.po")
    system("msgfmt -cv -o recpermissions/locale/fr/LC_MESSAGES/recpermissions.mo recpermissions/locale/fr.po")
