Browse Source

Compile PO files at build time

doc-issue-template
MrS0m30n3 7 years ago
parent
commit
c5e5f6a608
2 changed files with 26 additions and 1 deletions
  1. 1
      TODO
  2. 26
      setup.py

1
TODO

@ -20,7 +20,6 @@ Localization
============
* Add support for right to left languages (hebrew, arabic)
* Fix paths on R2L layouts
* Compile *.po files at build time
* Script to automatically check translations (use google-translate library)
* Send emails to update translations
* Update translation HOWTO, etc

26
setup.py

@ -20,6 +20,14 @@ Examples:
python setup.py bdist
Build the translations::
python setup.py build
Requirements:
* GNU gettext utilities
Notes:
If you get 'TypeError: decoding Unicode is not supported' when you run
py2exe then apply the following patch::
@ -45,6 +53,7 @@ import os
import sys
import glob
from shutil import copyfile
from subprocess import call
PY2EXE = len(sys.argv) >= 2 and sys.argv[1] == "py2exe"
@ -82,6 +91,22 @@ def create_scripts():
copyfile(os.path.join(__packagename__, "__main__.py"),
os.path.join(dest_dir, "youtube-dl-gui"))
def build_translations():
"""Build the MO files."""
exec_name = "msgfmt.exe" if os.name == "nt" else "msgfmt"
search_pattern = os.path.join("youtube_dl_gui", "locale", "*", "LC_MESSAGES", "*.po")
for po_file in glob.glob(search_pattern):
mo_file = po_file.replace(".po", ".mo")
try:
print "Building MO file for '%s'" % po_file
call([exec_name, "-o", mo_file, po_file])
except OSError:
print "Could not locate file '%s', exiting..." % exec_name
sys.exit(1)
##################################
@ -193,6 +218,7 @@ def windows_setup():
# Execute pre-build stuff
create_scripts()
build_translations()
if os.name == "nt":
params = windows_setup()

Loading…
Cancel
Save