diff options
author | Deathamns <deathamns@gmail.com> | 2014-11-24 20:00:27 +0100 |
---|---|---|
committer | Deathamns <deathamns@gmail.com> | 2015-01-13 07:28:52 +0100 |
commit | 67f18d023ce220a9c6fc11c7fa0b64618b2e9cca (patch) | |
tree | e42324ebf905c6742628a0e312290cabce1a4dec /tools | |
parent | 2016eff2a1f5566bd395b6a9fb57b6e20ff22acd (diff) | |
download | uBlock-67f18d023ce220a9c6fc11c7fa0b64618b2e9cca.zip uBlock-67f18d023ce220a9c6fc11c7fa0b64618b2e9cca.tar.gz uBlock-67f18d023ce220a9c6fc11c7fa0b64618b2e9cca.tar.bz2 |
Initial Firefox port (base, messaging, locales)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/make-firefox.sh | 28 | ||||
-rw-r--r-- | tools/xpi-convert-locale.py | 49 |
2 files changed, 77 insertions, 0 deletions
diff --git a/tools/make-firefox.sh b/tools/make-firefox.sh new file mode 100644 index 0000000..aeb6c31 --- /dev/null +++ b/tools/make-firefox.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# +# This script assumes a linux environment + +echo "*** uBlock_xpi: Copying files" +# use underscore instead of a dot! +DES=dist/build/uBlock_xpi +rm -r $DES +mkdir -p $DES +cp -R assets $DES/ +rm $DES/assets/*.sh +cp -R src/css $DES/ +cp -R src/img $DES/ +cp -R src/js $DES/ +cp -R src/lib $DES/ +cp -R src/_locales $DES/ +cp src/*.html $DES/ +cp src/img/icon_128.png $DES/icon.png +cp platform/vapi-appinfo.js $DES/js/ +cp platform/firefox/vapi-*.js $DES/js/ +cp platform/firefox/bootstrap.js $DES/ +cp platform/firefox/frameScript.js $DES/ +cp platform/firefox/chrome.manifest $DES/ +cp platform/firefox/install.rdf $DES/ + +python tools/xpi-convert-locale.py $DES/ + +echo "*** uBlock_xpi: Package done." diff --git a/tools/xpi-convert-locale.py b/tools/xpi-convert-locale.py new file mode 100644 index 0000000..1467f36 --- /dev/null +++ b/tools/xpi-convert-locale.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 + +import os +import json +import sys +from shutil import rmtree as rmt +from collections import OrderedDict + +if not sys.argv[1]: + raise SystemExit('Build dir missing.') + +osp = os.path +pj = osp.join + + +def rmtree(path): + if osp.exists(path): + rmt(path) + + +def mkdirs(path): + try: + os.makedirs(path) + finally: + return osp.exists(path) + + +build_dir = osp.abspath(sys.argv[1]) +source_locale_dir = pj(build_dir, '_locales') +target_locale_dir = pj(build_dir, 'locale') + +for alpha2 in os.listdir(source_locale_dir): + locale_path = pj(source_locale_dir, alpha2, 'messages.json') + with open(locale_path, encoding='utf-8') as f: + string_data = json.load(f, object_pairs_hook=OrderedDict) + + alpha2 = alpha2.replace('_', '-') + + mkdirs(pj(target_locale_dir, alpha2)) + + locale_path = pj(target_locale_dir, alpha2, 'messages.properties') + with open(locale_path, 'wt', encoding='utf-8', newline='\n') as f: + for string_name in string_data: + f.write(string_name) + f.write('=') + f.write(string_data[string_name]['message'].replace('\n', r'\n')) + f.write('\n') + +rmtree(source_locale_dir) |