Skip to content

Commit

Permalink
compile MO files using pyinstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanslack committed Jul 13, 2024
1 parent e5c1875 commit 355bfe7
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Sat, 13 July 2024 V.5.0.17
packages.
* Added `babel` as a new dependency needed for compiling language catalogs
when building binaries.
* Added compile MO files option before build standalone App using pyinstaller.

+------------------------------------+
Wed, 03 July 2024 V.5.0.16
Expand Down
1 change: 1 addition & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ videomass (5.0.17-1) UNRELEASED; urgency=medium
packages.
* Added `babel` as a new dependency needed for compiling language catalogs
when building binaries.
* Added compile MO files option before build standalone App using pyinstaller.

-- Gianluca Pernigotto <[email protected]> Sat, 13 Jul 2024 12:00:00 +0200

Expand Down
25 changes: 25 additions & 0 deletions develop/gettext_utils/babelutils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyleft (c) Videomass Development Team.
# Distributed under the terms of the GPL3 License.

import os
import sys
from babel.messages.frontend import compile_catalog


def build_translation_catalog(pathtolocale):
cmd = compile_catalog()
cmd.directory = pathtolocale
cmd.domain = "videomass"
cmd.statistics = True
cmd.finalize_options()
cmd.run()

if __name__ == '__main__':
if not len(sys.argv) > 1:
sys.exit('ERROR: Please provide path to locale directory.')

pathtolocale = sys.argv[1]
if os.path.exists(pathtolocale) and os.path.isdir(pathtolocale):
build = build_translation_catalog(pathtolocale)
else:
sys.exit(f'ERROR: Invalid pathname «{pathtolocale}».')
25 changes: 25 additions & 0 deletions develop/tools/pyinstaller_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import argparse
import time
import subprocess
from babel.messages.frontend import compile_catalog

this = os.path.realpath(os.path.abspath(__file__))
HERE = os.path.dirname(os.path.dirname(os.path.dirname(this)))
Expand All @@ -43,6 +44,28 @@
SPECFILE = os.path.join(HERE, f'{NAME}.spec')


def build_language_catalog(here=HERE):
"""
Before build standalone App make sure to compile
MO files for this macchine.
"""
while True:
quest = input('\nDo you want to compile MO files for '
'this macchine? (y/n)? ')
if quest.strip() in ('Y', 'y', 'n', 'N'):
break
print(f"\nInvalid option '{quest}'")
continue

if quest in ('y', 'Y'):
cmd = compile_catalog()
cmd.directory = os.path.join(here, 'videomass', 'data', 'locale')
cmd.domain = "videomass"
cmd.statistics = True
cmd.finalize_options()
cmd.run()


def videomass_data_source(here=HERE, name=NAME, release=about_app):
"""
Returns a dict object of the Videomass data
Expand Down Expand Up @@ -415,6 +438,7 @@ def main():
get_data_platform()

elif args.genspec_build:
build_language_catalog()
get_data_platform()
clean_buildingdirs()
backup = backup_sources()
Expand All @@ -424,6 +448,7 @@ def main():
restore_sources(backup)

elif args.start_build:
build_language_catalog()
clean_buildingdirs()
backup = backup_sources()
ret = make_portable()
Expand Down

0 comments on commit 355bfe7

Please sign in to comment.