Skip to content
Snippets Groups Projects
Select Git revision
  • fa9eae19ac3968531f7d84c282d18d6fe756d0b4
  • master default protected
  • network/gdev-800 protected
  • cgeek/issue-297-cpu
  • gdev-800-tests
  • update-docker-compose-rpc-squid-names
  • fix-252
  • 1000i100-test
  • hugo/tmp-0.9.1
  • network/gdev-803 protected
  • hugo/endpoint-gossip
  • network/gdev-802 protected
  • hugo/distance-precompute
  • network/gdev-900 protected
  • tuxmain/anonymous-tx
  • debug/podman
  • hugo/195-doc
  • hugo/195-graphql-schema
  • hugo-tmp-dockerfile-cache
  • release/client-800.2 protected
  • release/runtime-800 protected
  • gdev-900-0.10.1 protected
  • gdev-900-0.10.0 protected
  • gdev-900-0.9.2 protected
  • gdev-800-0.8.0 protected
  • gdev-900-0.9.1 protected
  • gdev-900-0.9.0 protected
  • gdev-803 protected
  • gdev-802 protected
  • runtime-801 protected
  • gdev-800 protected
  • runtime-800-bis protected
  • runtime-800 protected
  • runtime-800-backup protected
  • runtime-701 protected
  • runtime-700 protected
  • runtime-600 protected
  • runtime-500 protected
  • v0.4.1 protected
  • runtime-401 protected
  • v0.4.0 protected
41 results

gen-live-network-raw-spec.sh

Blame
  • gen_translations.py 2.24 KiB
    import sys, os, multiprocessing, subprocess, time, shutil
    
    gen_resources = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src'))
    ts = os.path.abspath(os.path.join(os.path.dirname(__file__), 'res', 'i18n', 'ts'))
    qm = os.path.abspath(os.path.join(os.path.dirname(__file__), 'res', 'i18n', 'qm'))
    if not os.path.exists(qm):
        os.mkdir(qm)
    
    translations = []
    qm_files = []
    qm_shortnames = []
    
    
    def prepare_qm():
        for root, dirs, files in os.walk(ts):
            for f in files:
                if f.endswith('.ts'):
                    tsfilename = os.path.join(root, f)
                    qmshort = "{0}qm".format(f[:-2])
                    qmfilename = os.path.join(qm, qmshort)
                    srcdest = (tsfilename, qmfilename)
                    translations.append(srcdest)
                    qm_shortnames.append(qmshort)
                else:
                    continue
                print(os.path.join(root, f))
    
        for (ts_file, qm_file) in translations:
            # avoid conflict with qt4 lrelease by running qtchooser directly
            if sys.platform.startswith('win') or shutil.which("qtchooser") == None:
                subprocess.call(["lrelease", ts_file, "-qm", qm_file])
            else:
                subprocess.call(["qtchooser", "-run-tool=lrelease", "-qt=5", ts_file, "-qm", qm_file])
            print(ts_file + " >> " + qm_file)
    
    
    def build_resources():
        files = ""
        for file in qm_shortnames:
            files += """
    <file alias="{0}">qm/{0}.qm</file>""".format(file[:-3])
        rccfile = """<RCC>
          <qresource prefix="i18n">{0}
          </qresource>
        </RCC>
        """.format(files)
        print(rccfile)
    
        qrc_filename = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                                    'res',
                                                    'i18n',
                                                    'langs-{0}.qrc'.format(int(time.time()))
                                                    ))
    
        pyc_filename = os.path.abspath(os.path.join(gen_resources, 'i18n_rc.py'))
        with open(qrc_filename, 'w') as outfile:
            outfile.write(rccfile)
    
        try:
            subprocess.call(["pyrcc5", "-o", pyc_filename, qrc_filename])
            print(qrc_filename + " >> " + pyc_filename)
        finally:
            os.remove(qrc_filename)
    
    
    prepare_qm()
    build_resources()